From 3eb1c43720fdd3fb1c9284dde5368832fbfe52bc Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Mon, 20 Apr 2020 20:31:32 +0100 Subject: [PATCH] Ignore -Zprofile when building compiler_builtins --- src/librustc_codegen_ssa/back/write.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index b1fb1ef0e331c..cf6c581afc98a 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -119,7 +119,12 @@ pub struct ModuleConfig { } impl ModuleConfig { - fn new(kind: ModuleKind, sess: &Session, no_builtins: bool) -> ModuleConfig { + fn new( + kind: ModuleKind, + sess: &Session, + no_builtins: bool, + is_compiler_builtins: bool, + ) -> ModuleConfig { // If it's a regular module, use `$regular`, otherwise use `$other`. // `$regular` and `$other` are evaluated lazily. macro_rules! if_regular { @@ -160,7 +165,10 @@ impl ModuleConfig { passes: if_regular!( { let mut passes = sess.opts.cg.passes.clone(); - if sess.opts.debugging_opts.profile { + // compiler_builtins overrides the codegen-units settings, + // which is incompatible with -Zprofile which requires that + // only a single codegen unit is used per crate. + if sess.opts.debugging_opts.profile && !is_compiler_builtins { passes.push("insert-gcov-profiling".to_owned()); } passes @@ -405,6 +413,8 @@ pub fn start_async_codegen( let crate_name = tcx.crate_name(LOCAL_CRATE); let crate_hash = tcx.crate_hash(LOCAL_CRATE); let no_builtins = attr::contains_name(&tcx.hir().krate().item.attrs, sym::no_builtins); + let is_compiler_builtins = + attr::contains_name(&tcx.hir().krate().item.attrs, sym::compiler_builtins); let subsystem = attr::first_attr_value_str_by_name(&tcx.hir().krate().item.attrs, sym::windows_subsystem); let windows_subsystem = subsystem.map(|subsystem| { @@ -421,9 +431,12 @@ pub fn start_async_codegen( let linker_info = LinkerInfo::new(tcx); let crate_info = CrateInfo::new(tcx); - let regular_config = ModuleConfig::new(ModuleKind::Regular, sess, no_builtins); - let metadata_config = ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins); - let allocator_config = ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins); + let regular_config = + ModuleConfig::new(ModuleKind::Regular, sess, no_builtins, is_compiler_builtins); + let metadata_config = + ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins, is_compiler_builtins); + let allocator_config = + ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins, is_compiler_builtins); let (shared_emitter, shared_emitter_main) = SharedEmitter::new(); let (codegen_worker_send, codegen_worker_receive) = channel();