diff options
| author | bors <bors@rust-lang.org> | 2018-10-16 02:06:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-10-16 02:06:26 +0000 |
| commit | df0d6ad9c1510630b234f6bb96a69a081de0b307 (patch) | |
| tree | 3888a6b11bf0f8628561ab18c06d774d468258d8 /src/librustc_codegen_llvm | |
| parent | 46880f41b7aeb897b8245474196bba9dc11f0e88 (diff) | |
| parent | 1811f1322a46658c1b5b765b5cf6d52aace34e30 (diff) | |
| download | rust-df0d6ad9c1510630b234f6bb96a69a081de0b307.tar.gz rust-df0d6ad9c1510630b234f6bb96a69a081de0b307.zip | |
Auto merge of #55023 - euclio:llvm-error-handler, r=cuviper
Exit with code 101 on fatal codegen errors Fixes #54992. This PR installs a custom fatal error handler that prints the error from LLVM and exits with 101. There should be no visible change in the output from LLVM. This allows distinguishing a fatal LLVM error with a compilation error by exit code. This PR also modifies the LLVM codegen backend to ICE instead of emitting a fatal error when encountering a LLVM worker thread panic for the same reason. r? @cuviper
Diffstat (limited to 'src/librustc_codegen_llvm')
| -rw-r--r-- | src/librustc_codegen_llvm/back/write.rs | 6 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/llvm/ffi.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/llvm_util.rs | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index 02ef690b942..95281e2445a 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -2031,9 +2031,7 @@ fn start_executing_work(tcx: TyCtxt, main_thread_worker_state = MainThreadWorkerState::Idle; } Message::Done { result: Err(()), worker_id: _ } => { - shared_emitter.fatal("aborting due to worker thread failure"); - // Exit the coordinator thread - return Err(()) + bug!("worker thread panicked"); } Message::CodegenItem => { bug!("the coordinator should not receive codegen requests") @@ -2392,7 +2390,7 @@ impl OngoingCodegen { panic!("expected abort due to worker thread errors") }, Err(_) => { - sess.fatal("Error during codegen/LLVM phase."); + bug!("panic during codegen/LLVM phase"); } }; diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index c9f51efdc50..6108af6c884 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -482,6 +482,8 @@ pub mod debuginfo { extern { pub type ModuleBuffer; } extern "C" { + pub fn LLVMRustInstallFatalErrorHandler(); + // Create and destroy contexts. pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context; pub fn LLVMContextDispose(C: &'static mut Context); diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 8456cf2f480..0a80fdddbf9 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -56,6 +56,8 @@ unsafe fn configure_llvm(sess: &Session) { let mut llvm_c_strs = Vec::with_capacity(n_args + 1); let mut llvm_args = Vec::with_capacity(n_args + 1); + llvm::LLVMRustInstallFatalErrorHandler(); + { let mut add = |arg: &str| { let s = CString::new(arg).unwrap(); |
