Skip to content

Commit ae39829

Browse files
Clarify FatalErrorHandler
Clarify the FatalErrorHandler API that we use: - Identify rustc's LLVM ERRORs by prefixing them - Comment heavily on its interior, while we are here
1 parent 3c02972 commit ae39829

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,22 @@ static LLVM_THREAD_LOCAL char *LastError;
6666
static void FatalErrorHandler(void *UserData,
6767
const char* Reason,
6868
bool GenCrashDiag) {
69-
// Do the same thing that the default error handler does.
70-
std::cerr << "LLVM ERROR: " << Reason << std::endl;
69+
// Once upon a time we emitted "LLVM ERROR:" specifically to mimic LLVM. Then,
70+
// we developed crater and other tools which only expose logs, not error codes.
71+
// Use a more greppable prefix that will still match the "LLVM ERROR:" prefix.
72+
std::cerr << "rustc-LLVM ERROR: " << Reason << std::endl;
7173

7274
// Since this error handler exits the process, we have to run any cleanup that
7375
// LLVM would run after handling the error. This might change with an LLVM
7476
// upgrade.
77+
//
78+
// In practice, this will do nothing, because the only cleanup LLVM does is
79+
// to remove all files that were registered with it via a frontend calling
80+
// one of the `createOutputFile` family of functions in LLVM and passing true
81+
// to RemoveFileOnSignal, something that rustc does not do. However, it would
82+
// be... inadvisable to suddenly stop running these handlers, if LLVM gets
83+
// "interesting" ideas in the future about what cleanup should be done.
84+
// We might even find it useful for generating less artifacts.
7585
sys::RunInterruptHandlers();
7686

7787
exit(101);

0 commit comments

Comments
 (0)