File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
compiler/rustc_codegen_ssa/src Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,12 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
383383 }
384384}
385385
386+ impl < B : CodegenBackend + WriteBackendMethods > CodegenContext < B > {
387+ pub fn parallel ( & self ) -> bool {
388+ self . backend . supports_parallel ( ) && !self . opts . unstable_opts . no_parallel_llvm
389+ }
390+ }
391+
386392fn generate_lto_work < B : ExtraBackendMethods > (
387393 cgcx : & CodegenContext < B > ,
388394 needs_fat_lto : Vec < FatLtoInput < B > > ,
@@ -1400,7 +1406,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14001406 . binary_search_by_key ( & cost, |& ( _, cost) | cost)
14011407 . unwrap_or_else ( |e| e) ;
14021408 work_items. insert ( insertion_index, ( work, cost) ) ;
1403- if ! cgcx. opts . unstable_opts . no_parallel_llvm {
1409+ if cgcx. parallel ( ) {
14041410 helper. request_token ( ) ;
14051411 }
14061412 }
@@ -1523,7 +1529,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
15231529 } ;
15241530 work_items. insert ( insertion_index, ( llvm_work_item, cost) ) ;
15251531
1526- if ! cgcx. opts . unstable_opts . no_parallel_llvm {
1532+ if cgcx. parallel ( ) {
15271533 helper. request_token ( ) ;
15281534 }
15291535 assert_eq ! ( main_thread_state, MainThreadState :: Codegenning ) ;
Original file line number Diff line number Diff line change @@ -115,6 +115,13 @@ pub trait CodegenBackend {
115115 codegen_results : CodegenResults ,
116116 outputs : & OutputFilenames ,
117117 ) -> Result < ( ) , ErrorGuaranteed > ;
118+
119+ /// Returns `true` if this backend can be safely called from multiple threads.
120+ ///
121+ /// Defaults to `true`.
122+ fn supports_parallel ( & self ) -> bool {
123+ true
124+ }
118125}
119126
120127pub trait ExtraBackendMethods :
You can’t perform that action at this time.
0 commit comments