@@ -1488,7 +1488,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
14881488 // Each LLVM module is automatically sent back to the coordinator for LTO if
14891489 // necessary. There's already optimizations in place to avoid sending work
14901490 // back to the coordinator if LTO isn't requested.
1491- return B :: spawn_named_thread ( cgcx. time_trace , "coordinator" . to_string ( ) , move || {
1491+ let f = move || {
1492+ let _profiler = if cgcx. time_trace { B :: thread_profiler ( ) } else { Box :: new ( ( ) ) } ;
1493+
14921494 // This is where we collect codegen units that have gone all the way
14931495 // through codegen and LLVM.
14941496 let mut compiled_modules = vec ! [ ] ;
@@ -1829,8 +1831,11 @@ fn start_executing_work<B: ExtraBackendMethods>(
18291831 B :: codegen ( & cgcx, & prof, & shared_emitter, allocator_module, & allocator_config)
18301832 } ) ,
18311833 } )
1832- } )
1833- . expect ( "failed to spawn coordinator thread" ) ;
1834+ } ;
1835+ return std:: thread:: Builder :: new ( )
1836+ . name ( "coordinator" . to_owned ( ) )
1837+ . spawn ( f)
1838+ . expect ( "failed to spawn coordinator thread" ) ;
18341839
18351840 // A heuristic that determines if we have enough LLVM WorkItems in the
18361841 // queue so that the main thread can do LLVM work instead of codegen
@@ -1909,7 +1914,10 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
19091914 let cgcx = cgcx. clone ( ) ;
19101915 let prof = prof. clone ( ) ;
19111916
1912- B :: spawn_named_thread ( cgcx. time_trace , work. short_description ( ) , move || {
1917+ let name = work. short_description ( ) ;
1918+ let f = move || {
1919+ let _profiler = if cgcx. time_trace { B :: thread_profiler ( ) } else { Box :: new ( ( ) ) } ;
1920+
19131921 let result = std:: panic:: catch_unwind ( AssertUnwindSafe ( || match work {
19141922 WorkItem :: Optimize ( m) => execute_optimize_work_item ( & cgcx, & prof, shared_emitter, m) ,
19151923 WorkItem :: CopyPostLtoArtifacts ( m) => WorkItemResult :: Finished (
@@ -1930,8 +1938,8 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
19301938 Err ( _) => Message :: WorkItem :: < B > { result : Err ( None ) } ,
19311939 } ;
19321940 drop ( coordinator_send. send ( msg) ) ;
1933- } )
1934- . expect ( "failed to spawn work thread" ) ;
1941+ } ;
1942+ std :: thread :: Builder :: new ( ) . name ( name ) . spawn ( f ) . expect ( "failed to spawn work thread" ) ;
19351943}
19361944
19371945fn spawn_thin_lto_work < B : ExtraBackendMethods > (
@@ -1945,7 +1953,10 @@ fn spawn_thin_lto_work<B: ExtraBackendMethods>(
19451953 let cgcx = cgcx. clone ( ) ;
19461954 let prof = prof. clone ( ) ;
19471955
1948- B :: spawn_named_thread ( cgcx. time_trace , work. short_description ( ) , move || {
1956+ let name = work. short_description ( ) ;
1957+ let f = move || {
1958+ let _profiler = if cgcx. time_trace { B :: thread_profiler ( ) } else { Box :: new ( ( ) ) } ;
1959+
19491960 let result = std:: panic:: catch_unwind ( AssertUnwindSafe ( || match work {
19501961 ThinLtoWorkItem :: CopyPostLtoArtifacts ( m) => {
19511962 execute_copy_from_cache_work_item ( & cgcx, & prof, shared_emitter, m)
@@ -1968,8 +1979,8 @@ fn spawn_thin_lto_work<B: ExtraBackendMethods>(
19681979 Err ( _) => ThinLtoMessage :: WorkItem { result : Err ( None ) } ,
19691980 } ;
19701981 drop ( coordinator_send. send ( msg) ) ;
1971- } )
1972- . expect ( "failed to spawn work thread" ) ;
1982+ } ;
1983+ std :: thread :: Builder :: new ( ) . name ( name ) . spawn ( f ) . expect ( "failed to spawn work thread" ) ;
19731984}
19741985
19751986enum SharedEmitterMessage {
0 commit comments