Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify FatalErrorHandler #122061

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,22 @@ static LLVM_THREAD_LOCAL char *LastError;
static void FatalErrorHandler(void *UserData,
const char* Reason,
bool GenCrashDiag) {
// Do the same thing that the default error handler does.
std::cerr << "LLVM ERROR: " << Reason << std::endl;
// Once upon a time we emitted "LLVM ERROR:" specifically to mimic LLVM. Then,
// we developed crater and other tools which only expose logs, not error codes.
// Use a more greppable prefix that will still match the "LLVM ERROR:" prefix.
std::cerr << "rustc-LLVM ERROR: " << Reason << std::endl;

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

exit(101);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/linkage-attr/common-linkage-non-zero-init.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'common' global must have a zero initializer!
ptr @TEST
LLVM ERROR: Broken module found, compilation aborted!
rustc-LLVM ERROR: Broken module found, compilation aborted!
Loading