@@ -902,7 +902,7 @@ pub enum Message<B: WriteBackendMethods> {
902
902
worker_id : usize ,
903
903
} ,
904
904
Done {
905
- result : Result < CompiledModule , ( ) > ,
905
+ result : Result < CompiledModule , Option < WorkerFatalError > > ,
906
906
worker_id : usize ,
907
907
} ,
908
908
CodegenDone {
@@ -1474,9 +1474,12 @@ fn start_executing_work<B: ExtraBackendMethods>(
1474
1474
main_thread_worker_state = MainThreadWorkerState :: Idle ;
1475
1475
}
1476
1476
// If the thread failed that means it panicked, so we abort immediately.
1477
- Message :: Done { result : Err ( ( ) ) , worker_id : _ } => {
1477
+ Message :: Done { result : Err ( None ) , worker_id : _ } => {
1478
1478
bug ! ( "worker thread panicked" ) ;
1479
1479
}
1480
+ Message :: Done { result : Err ( Some ( WorkerFatalError ) ) , worker_id : _ } => {
1481
+ return Err ( ( ) ) ;
1482
+ }
1480
1483
Message :: CodegenItem => bug ! ( "the coordinator should not receive codegen requests" ) ,
1481
1484
}
1482
1485
}
@@ -1520,29 +1523,36 @@ fn start_executing_work<B: ExtraBackendMethods>(
1520
1523
1521
1524
pub const CODEGEN_WORKER_ID : usize = :: std:: usize:: MAX ;
1522
1525
1526
+ /// `FatalError` is explicitly not `Send`.
1527
+ #[ must_use]
1528
+ pub struct WorkerFatalError ;
1529
+
1523
1530
fn spawn_work < B : ExtraBackendMethods > ( cgcx : CodegenContext < B > , work : WorkItem < B > ) {
1524
1531
thread:: spawn ( move || {
1525
1532
// Set up a destructor which will fire off a message that we're done as
1526
1533
// we exit.
1527
1534
struct Bomb < B : ExtraBackendMethods > {
1528
1535
coordinator_send : Sender < Box < dyn Any + Send > > ,
1529
- result : Option < WorkItemResult < B > > ,
1536
+ result : Option < Result < WorkItemResult < B > , FatalError > > ,
1530
1537
worker_id : usize ,
1531
1538
}
1532
1539
impl < B : ExtraBackendMethods > Drop for Bomb < B > {
1533
1540
fn drop ( & mut self ) {
1534
1541
let worker_id = self . worker_id ;
1535
1542
let msg = match self . result . take ( ) {
1536
- Some ( WorkItemResult :: Compiled ( m) ) => {
1543
+ Some ( Ok ( WorkItemResult :: Compiled ( m) ) ) => {
1537
1544
Message :: Done :: < B > { result : Ok ( m) , worker_id }
1538
1545
}
1539
- Some ( WorkItemResult :: NeedsFatLTO ( m) ) => {
1546
+ Some ( Ok ( WorkItemResult :: NeedsFatLTO ( m) ) ) => {
1540
1547
Message :: NeedsFatLTO :: < B > { result : m, worker_id }
1541
1548
}
1542
- Some ( WorkItemResult :: NeedsThinLTO ( name, thin_buffer) ) => {
1549
+ Some ( Ok ( WorkItemResult :: NeedsThinLTO ( name, thin_buffer) ) ) => {
1543
1550
Message :: NeedsThinLTO :: < B > { name, thin_buffer, worker_id }
1544
1551
}
1545
- None => Message :: Done :: < B > { result : Err ( ( ) ) , worker_id } ,
1552
+ Some ( Err ( FatalError ) ) => {
1553
+ Message :: Done :: < B > { result : Err ( Some ( WorkerFatalError ) ) , worker_id }
1554
+ }
1555
+ None => Message :: Done :: < B > { result : Err ( None ) , worker_id } ,
1546
1556
} ;
1547
1557
drop ( self . coordinator_send . send ( Box :: new ( msg) ) ) ;
1548
1558
}
@@ -1562,7 +1572,7 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
1562
1572
// surface that there was an error in this worker.
1563
1573
bomb. result = {
1564
1574
let _prof_timer = cgcx. prof . generic_activity ( work. profiling_event_id ( ) ) ;
1565
- execute_work_item ( & cgcx, work) . ok ( )
1575
+ Some ( execute_work_item ( & cgcx, work) )
1566
1576
} ;
1567
1577
} ) ;
1568
1578
}
0 commit comments