@@ -119,7 +119,12 @@ pub struct ModuleConfig {
119119}
120120
121121impl ModuleConfig {
122- fn new ( kind : ModuleKind , sess : & Session , no_builtins : bool ) -> ModuleConfig {
122+ fn new (
123+ kind : ModuleKind ,
124+ sess : & Session ,
125+ no_builtins : bool ,
126+ is_compiler_builtins : bool ,
127+ ) -> ModuleConfig {
123128 // If it's a regular module, use `$regular`, otherwise use `$other`.
124129 // `$regular` and `$other` are evaluated lazily.
125130 macro_rules! if_regular {
@@ -160,7 +165,10 @@ impl ModuleConfig {
160165 passes : if_regular ! (
161166 {
162167 let mut passes = sess. opts. cg. passes. clone( ) ;
163- if sess. opts. debugging_opts. profile {
168+ // compiler_builtins overrides the codegen-units settings,
169+ // which is incompatible with -Zprofile which requires that
170+ // only a single codegen unit is used per crate.
171+ if sess. opts. debugging_opts. profile && !is_compiler_builtins {
164172 passes. push( "insert-gcov-profiling" . to_owned( ) ) ;
165173 }
166174 passes
@@ -405,6 +413,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
405413 let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
406414 let crate_hash = tcx. crate_hash ( LOCAL_CRATE ) ;
407415 let no_builtins = attr:: contains_name ( & tcx. hir ( ) . krate ( ) . item . attrs , sym:: no_builtins) ;
416+ let is_compiler_builtins =
417+ attr:: contains_name ( & tcx. hir ( ) . krate ( ) . item . attrs , sym:: compiler_builtins) ;
408418 let subsystem =
409419 attr:: first_attr_value_str_by_name ( & tcx. hir ( ) . krate ( ) . item . attrs , sym:: windows_subsystem) ;
410420 let windows_subsystem = subsystem. map ( |subsystem| {
@@ -421,9 +431,12 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
421431 let linker_info = LinkerInfo :: new ( tcx) ;
422432 let crate_info = CrateInfo :: new ( tcx) ;
423433
424- let regular_config = ModuleConfig :: new ( ModuleKind :: Regular , sess, no_builtins) ;
425- let metadata_config = ModuleConfig :: new ( ModuleKind :: Metadata , sess, no_builtins) ;
426- let allocator_config = ModuleConfig :: new ( ModuleKind :: Allocator , sess, no_builtins) ;
434+ let regular_config =
435+ ModuleConfig :: new ( ModuleKind :: Regular , sess, no_builtins, is_compiler_builtins) ;
436+ let metadata_config =
437+ ModuleConfig :: new ( ModuleKind :: Metadata , sess, no_builtins, is_compiler_builtins) ;
438+ let allocator_config =
439+ ModuleConfig :: new ( ModuleKind :: Allocator , sess, no_builtins, is_compiler_builtins) ;
427440
428441 let ( shared_emitter, shared_emitter_main) = SharedEmitter :: new ( ) ;
429442 let ( codegen_worker_send, codegen_worker_receive) = channel ( ) ;
0 commit comments