diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index a5a90980c3a..9f577ba83d2 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -903,7 +903,7 @@ pub enum Message { worker_id: usize, }, Done { - result: Result, + result: Result>, worker_id: usize, }, CodegenDone { @@ -1476,9 +1476,12 @@ fn start_executing_work( main_thread_worker_state = MainThreadWorkerState::Idle; } // If the thread failed that means it panicked, so we abort immediately. - Message::Done { result: Err(()), worker_id: _ } => { + Message::Done { result: Err(None), worker_id: _ } => { bug!("worker thread panicked"); } + Message::Done { result: Err(Some(WorkerFatalError)), worker_id: _ } => { + return Err(()); + } Message::CodegenItem => bug!("the coordinator should not receive codegen requests"), } } @@ -1527,6 +1530,10 @@ fn maybe_start_llvm_timer(config: &ModuleConfig, llvm_start_time: &mut Option(cgcx: CodegenContext, work: WorkItem) { let depth = time_depth(); @@ -1537,23 +1544,26 @@ fn spawn_work(cgcx: CodegenContext, work: WorkItem // we exit. struct Bomb { coordinator_send: Sender>, - result: Option>, + result: Option, FatalError>>, worker_id: usize, } impl Drop for Bomb { fn drop(&mut self) { let worker_id = self.worker_id; let msg = match self.result.take() { - Some(WorkItemResult::Compiled(m)) => { + Some(Ok(WorkItemResult::Compiled(m))) => { Message::Done:: { result: Ok(m), worker_id } } - Some(WorkItemResult::NeedsFatLTO(m)) => { + Some(Ok(WorkItemResult::NeedsFatLTO(m))) => { Message::NeedsFatLTO:: { result: m, worker_id } } - Some(WorkItemResult::NeedsThinLTO(name, thin_buffer)) => { + Some(Ok(WorkItemResult::NeedsThinLTO(name, thin_buffer))) => { Message::NeedsThinLTO:: { name, thin_buffer, worker_id } } - None => Message::Done:: { result: Err(()), worker_id }, + Some(Err(FatalError)) => { + Message::Done:: { result: Err(Some(WorkerFatalError)), worker_id } + } + None => Message::Done:: { result: Err(None), worker_id }, }; drop(self.coordinator_send.send(Box::new(msg))); } @@ -1573,7 +1583,7 @@ fn drop(&mut self) { // surface that there was an error in this worker. bomb.result = { let _prof_timer = cgcx.prof.generic_activity(work.profiling_event_id()); - execute_work_item(&cgcx, work).ok() + Some(execute_work_item(&cgcx, work)) }; }); }