@@ -903,7 +903,7 @@ pub enum Message<B: WriteBackendMethods> {
903
903
worker_id : usize ,
904
904
} ,
905
905
Done {
906
- result : Result < CompiledModule , ( ) > ,
906
+ result : Result < CompiledModule , Option < WorkerFatalError > > ,
907
907
worker_id : usize ,
908
908
} ,
909
909
CodegenDone {
@@ -1476,9 +1476,12 @@ fn start_executing_work<B: ExtraBackendMethods>(
1476
1476
main_thread_worker_state = MainThreadWorkerState :: Idle ;
1477
1477
}
1478
1478
// If the thread failed that means it panicked, so we abort immediately.
1479
- Message :: Done { result : Err ( ( ) ) , worker_id : _ } => {
1479
+ Message :: Done { result : Err ( None ) , worker_id : _ } => {
1480
1480
bug ! ( "worker thread panicked" ) ;
1481
1481
}
1482
+ Message :: Done { result : Err ( Some ( WorkerFatalError ) ) , worker_id : _ } => {
1483
+ return Err ( ( ) ) ;
1484
+ }
1482
1485
Message :: CodegenItem => bug ! ( "the coordinator should not receive codegen requests" ) ,
1483
1486
}
1484
1487
}
@@ -1527,6 +1530,10 @@ fn start_executing_work<B: ExtraBackendMethods>(
1527
1530
1528
1531
pub const CODEGEN_WORKER_ID : usize = :: std:: usize:: MAX ;
1529
1532
1533
+ /// `FatalError` is explicitly not `Send`.
1534
+ #[ must_use]
1535
+ pub struct WorkerFatalError ;
1536
+
1530
1537
fn spawn_work < B : ExtraBackendMethods > ( cgcx : CodegenContext < B > , work : WorkItem < B > ) {
1531
1538
let depth = time_depth ( ) ;
1532
1539
@@ -1537,23 +1544,26 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
1537
1544
// we exit.
1538
1545
struct Bomb < B : ExtraBackendMethods > {
1539
1546
coordinator_send : Sender < Box < dyn Any + Send > > ,
1540
- result : Option < WorkItemResult < B > > ,
1547
+ result : Option < Result < WorkItemResult < B > , FatalError > > ,
1541
1548
worker_id : usize ,
1542
1549
}
1543
1550
impl < B : ExtraBackendMethods > Drop for Bomb < B > {
1544
1551
fn drop ( & mut self ) {
1545
1552
let worker_id = self . worker_id ;
1546
1553
let msg = match self . result . take ( ) {
1547
- Some ( WorkItemResult :: Compiled ( m) ) => {
1554
+ Some ( Ok ( WorkItemResult :: Compiled ( m) ) ) => {
1548
1555
Message :: Done :: < B > { result : Ok ( m) , worker_id }
1549
1556
}
1550
- Some ( WorkItemResult :: NeedsFatLTO ( m) ) => {
1557
+ Some ( Ok ( WorkItemResult :: NeedsFatLTO ( m) ) ) => {
1551
1558
Message :: NeedsFatLTO :: < B > { result : m, worker_id }
1552
1559
}
1553
- Some ( WorkItemResult :: NeedsThinLTO ( name, thin_buffer) ) => {
1560
+ Some ( Ok ( WorkItemResult :: NeedsThinLTO ( name, thin_buffer) ) ) => {
1554
1561
Message :: NeedsThinLTO :: < B > { name, thin_buffer, worker_id }
1555
1562
}
1556
- None => Message :: Done :: < B > { result : Err ( ( ) ) , worker_id } ,
1563
+ Some ( Err ( FatalError ) ) => {
1564
+ Message :: Done :: < B > { result : Err ( Some ( WorkerFatalError ) ) , worker_id }
1565
+ }
1566
+ None => Message :: Done :: < B > { result : Err ( None ) , worker_id } ,
1557
1567
} ;
1558
1568
drop ( self . coordinator_send . send ( Box :: new ( msg) ) ) ;
1559
1569
}
@@ -1573,7 +1583,7 @@ fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>
1573
1583
// surface that there was an error in this worker.
1574
1584
bomb. result = {
1575
1585
let _prof_timer = cgcx. prof . generic_activity ( work. profiling_event_id ( ) ) ;
1576
- execute_work_item ( & cgcx, work) . ok ( )
1586
+ Some ( execute_work_item ( & cgcx, work) )
1577
1587
} ;
1578
1588
} ) ;
1579
1589
}
0 commit comments