Skip to content

Commit 692b94a

Browse files
committed
Auto merge of #45111 - aidanhs:aphs-bubble-worker-failures, r=alexcrichton
Don't panic in the coordinator thread, bubble up the failure Fixes #43402 (take 2) Followup to #45019, this makes the coordinator thread not panic on worker failures since they can be reported reasonably back in the main thread. The output also now has no evidence of backtraces at all, unlike the previous PR: ``` $ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc -o "" x.rs error: could not write output to : No such file or directory error: aborting due to previous error ``` r? @alexcrichton
2 parents 72d6501 + 911d95b commit 692b94a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/librustc_trans/back/write.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ fn start_executing_work(tcx: TyCtxt,
12471247
modules_config: Arc<ModuleConfig>,
12481248
metadata_config: Arc<ModuleConfig>,
12491249
allocator_config: Arc<ModuleConfig>)
1250-
-> thread::JoinHandle<CompiledModules> {
1250+
-> thread::JoinHandle<Result<CompiledModules, ()>> {
12511251
let coordinator_send = tcx.tx_to_llvm_workers.clone();
12521252
let mut exported_symbols = FxHashMap();
12531253
exported_symbols.insert(LOCAL_CRATE, tcx.exported_symbols(LOCAL_CRATE));
@@ -1695,7 +1695,7 @@ fn start_executing_work(tcx: TyCtxt,
16951695
Message::Done { result: Err(()), worker_id: _ } => {
16961696
shared_emitter.fatal("aborting due to worker thread failure");
16971697
// Exit the coordinator thread
1698-
panic!("aborting due to worker thread failure")
1698+
return Err(())
16991699
}
17001700
Message::TranslateItem => {
17011701
bug!("the coordinator should not receive translation requests")
@@ -1721,11 +1721,11 @@ fn start_executing_work(tcx: TyCtxt,
17211721
let compiled_metadata_module = compiled_metadata_module
17221722
.expect("Metadata module not compiled?");
17231723

1724-
CompiledModules {
1724+
Ok(CompiledModules {
17251725
modules: compiled_modules,
17261726
metadata_module: compiled_metadata_module,
17271727
allocator_module: compiled_allocator_module,
1728-
}
1728+
})
17291729
});
17301730

17311731
// A heuristic that determines if we have enough LLVM WorkItems in the
@@ -2018,15 +2018,19 @@ pub struct OngoingCrateTranslation {
20182018
coordinator_send: Sender<Box<Any + Send>>,
20192019
trans_worker_receive: Receiver<Message>,
20202020
shared_emitter_main: SharedEmitterMain,
2021-
future: thread::JoinHandle<CompiledModules>,
2021+
future: thread::JoinHandle<Result<CompiledModules, ()>>,
20222022
output_filenames: Arc<OutputFilenames>,
20232023
}
20242024

20252025
impl OngoingCrateTranslation {
20262026
pub fn join(self, sess: &Session, dep_graph: &DepGraph) -> CrateTranslation {
20272027
self.shared_emitter_main.check(sess, true);
20282028
let compiled_modules = match self.future.join() {
2029-
Ok(compiled_modules) => compiled_modules,
2029+
Ok(Ok(compiled_modules)) => compiled_modules,
2030+
Ok(Err(())) => {
2031+
sess.abort_if_errors();
2032+
panic!("expected abort due to worker thread errors")
2033+
},
20302034
Err(_) => {
20312035
sess.fatal("Error during translation/LLVM phase.");
20322036
}

0 commit comments

Comments
 (0)