mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Preserve PrettyStackTrace context in the interface worker thread.
Because we block the calling thread, this should be safe for the existing implementation of PrettyStackTrace; however, it would be much nicer if LLVM provided direct support for this. The most important thing from the trace that we want to print is the original command line, so an alternative would be to just make a PrettyStackTrace that printed all of the CompilerInvocation context; I think that's accessible somewhere. But this is a nice, simple improvement.
This commit is contained in:
@@ -244,8 +244,18 @@ bool ModuleInterfaceBuilder::collectDepsForSerialization(
|
||||
bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
|
||||
StringRef OutPath, bool ShouldSerializeDeps,
|
||||
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer) {
|
||||
|
||||
auto outerPrettyStackState = llvm::SavePrettyStackState();
|
||||
|
||||
bool SubError = false;
|
||||
bool RunSuccess = llvm::CrashRecoveryContext().RunSafelyOnThread([&] {
|
||||
// Pretend we're on the original thread for pretty-stack-trace purposes.
|
||||
auto savedInnerPrettyStackState = llvm::SavePrettyStackState();
|
||||
llvm::RestorePrettyStackState(outerPrettyStackState);
|
||||
SWIFT_DEFER {
|
||||
llvm::RestorePrettyStackState(savedInnerPrettyStackState);
|
||||
};
|
||||
|
||||
// Note that we don't assume cachePath is the same as the Clang
|
||||
// module cache path at this point.
|
||||
if (!moduleCachePath.empty())
|
||||
|
||||
Reference in New Issue
Block a user