about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-25 11:25:48 +0200
committerGitHub <noreply@github.com>2020-04-25 11:25:48 +0200
commitcbbf065425050a90126e0da070a92109faf62140 (patch)
tree54ddbd76c4c9dee23e88ceb16032d0b9c2c4d0a1
parent40008dcb494a00571123b7d59115068a200ebe34 (diff)
parent3eb1c43720fdd3fb1c9284dde5368832fbfe52bc (diff)
downloadrust-cbbf065425050a90126e0da070a92109faf62140.tar.gz
rust-cbbf065425050a90126e0da070a92109faf62140.zip
Rollup merge of #71364 - Amanieu:zprofile_compiler_builtins, r=cramertj
Ignore -Zprofile when building compiler_builtins

#70846 made the `compiler_builtins` crate ignore the default codegen-units setting and instead always split each function into a different codegen unit.

This unfortunately breaks `-Zprofile` which requires a single codegen unit per crate (see #71283). You can notice this when building with `cargo -Zbuild-std` and `RUSTFLAGS` containing `-Zprofile`.

This PR works around this issue by just ignoring `-Zprofile` for the `compiler-builtins` crate.
-rw-r--r--src/librustc_codegen_ssa/back/write.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs
index db60760e459..37034141bb7 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
@@ -406,6 +414,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
     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| {
@@ -422,9 +432,12 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
     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();