about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-07 00:57:40 +0100
committerGitHub <noreply@github.com>2024-03-07 00:57:40 +0100
commit8dc49e1b8ef4f6e67db9b5c97546df6b8319e398 (patch)
tree15258bed1f7c4e397228d39ac9fe6326c01a929a
parentd451faaab2e3075e42ce5b63ba61fae32521527e (diff)
parentf7b621cfab6630494533b4997409fb5c4a7e2bb8 (diff)
downloadrust-8dc49e1b8ef4f6e67db9b5c97546df6b8319e398.tar.gz
rust-8dc49e1b8ef4f6e67db9b5c97546df6b8319e398.zip
Rollup merge of #122061 - workingjubilee:prefix-llvm-error, r=cuviper
Clarify FatalErrorHandler

- Identify rustc's LLVM ERRORs by prefixing them
- Comment heavily on its interior, while we are here
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp14
-rw-r--r--tests/ui/linkage-attr/common-linkage-non-zero-init.stderr2
2 files changed, 13 insertions, 3 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index cb7cce4da0d..2ab65218061 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -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);
diff --git a/tests/ui/linkage-attr/common-linkage-non-zero-init.stderr b/tests/ui/linkage-attr/common-linkage-non-zero-init.stderr
index 667bb3ec130..93015bb2bac 100644
--- a/tests/ui/linkage-attr/common-linkage-non-zero-init.stderr
+++ b/tests/ui/linkage-attr/common-linkage-non-zero-init.stderr
@@ -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!