@@ -119,7 +119,12 @@ pub struct ModuleConfig {
119
119
}
120
120
121
121
impl 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 {
123
128
// If it's a regular module, use `$regular`, otherwise use `$other`.
124
129
// `$regular` and `$other` are evaluated lazily.
125
130
macro_rules! if_regular {
@@ -160,7 +165,10 @@ impl ModuleConfig {
160
165
passes : if_regular ! (
161
166
{
162
167
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 {
164
172
passes. push( "insert-gcov-profiling" . to_owned( ) ) ;
165
173
}
166
174
passes
@@ -405,6 +413,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
405
413
let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
406
414
let crate_hash = tcx. crate_hash ( LOCAL_CRATE ) ;
407
415
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) ;
408
418
let subsystem =
409
419
attr:: first_attr_value_str_by_name ( & tcx. hir ( ) . krate ( ) . item . attrs , sym:: windows_subsystem) ;
410
420
let windows_subsystem = subsystem. map ( |subsystem| {
@@ -421,9 +431,12 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
421
431
let linker_info = LinkerInfo :: new ( tcx) ;
422
432
let crate_info = CrateInfo :: new ( tcx) ;
423
433
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) ;
427
440
428
441
let ( shared_emitter, shared_emitter_main) = SharedEmitter :: new ( ) ;
429
442
let ( codegen_worker_send, codegen_worker_receive) = channel ( ) ;
0 commit comments