]> git.lizzy.rs Git - rust.git/commitdiff
compile all crates under test w/ -Zemit-stack-sizes
authorJorge Aparicio <jorge@japaric.io>
Mon, 25 Mar 2019 21:50:07 +0000 (22:50 +0100)
committerJorge Aparicio <jorge@japaric.io>
Mon, 25 Mar 2019 21:50:07 +0000 (22:50 +0100)
src/bootstrap/bin/rustc.rs
src/bootstrap/compile.rs

index 6f68775a85fd38b0412f6dfae54acb53dc60a12c..28c8a75a13ab4a5a94f7e379330b33d79ec736d6 100644 (file)
@@ -181,28 +181,31 @@ fn main() {
             cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
         }
 
-        // Build `compiler_builtins` with `-Z emit-stack-sizes` to add stack usage information.
+        // Build all crates in the `std` facade with `-Z emit-stack-sizes` to add stack usage
+        // information.
         //
-        // When you use this flag with Cargo you get stack usage information on all crates compiled
-        // from source, and when you are using LTO you also get information on pre-compiled crates
-        // like `core` and `std`. However, there's an exception: `compiler_builtins`. This crate
-        // is special and doesn't participate in LTO because it's always linked as a separate object
-        // file. Due to this it's impossible to get information about this crate using `RUSTFLAGS`
-        // + Cargo, or `cargo rustc`.
+        // When you use this `-Z` flag with Cargo you get stack usage information on all crates
+        // compiled from source, and when you are using LTO you also get information on pre-compiled
+        // crates like `core` and `std`, even if they were not compiled with `-Z emit-stack-sizes`.
+        // However, there's an exception: `compiler_builtins`. This crate is special and doesn't
+        // participate in LTO because it's always linked as a separate object file. For this reason
+        // it's impossible to get stack usage information about `compiler-builtins` using
+        // `RUSTFLAGS` + Cargo, or `cargo rustc`.
         //
-        // To make the stack usage information of this crate available to Cargo based stack usage
-        // analysis tools we compile `compiler_builtins` with the `-Z emit-stack-sizes` flag. The
-        // flag is known to currently work with targets that produce ELF files so we limit the use
-        // of the flag to those targets.
+        // To make the stack usage information of all crates under the `std` facade available to
+        // Cargo based stack usage analysis tools, in both LTO and non-LTO mode, we compile them
+        // with the `-Z emit-stack-sizes` flag. The `RUSTC_EMIT_STACK_SIZES` var helps us apply this
+        // flag only to the crates in the `std` facade. The `-Z` flag is known to currently work
+        // with targets that produce ELF files so we limit its use flag to those targets.
         //
         // NOTE(japaric) if this ever causes problem with an LLVM upgrade or any PR feel free to
         // remove it or comment it out
-        if crate_name == "compiler_builtins"
+        if env::var_os("RUSTC_EMIT_STACK_SIZES").is_some()
             && (target.contains("-linux-")
                 || target.contains("-none-eabi")
                 || target.ends_with("-none-elf"))
         {
-            cmd.arg("-Z").arg("emit-stack-sizes");
+            cmd.arg("-Zemit-stack-sizes");
         }
 
         if let Ok(s) = env::var("RUSTC_CODEGEN_UNITS") {
index 9498dbb59523294c9a1ec26fca48757fb4245939..0d51d7c5ef3b8543952bea083da98cd457cbbdbd 100644 (file)
@@ -97,6 +97,8 @@ fn run(self, builder: &Builder<'_>) {
         let _folder = builder.fold_output(|| format!("stage{}-std", compiler.stage));
         builder.info(&format!("Building stage{} std artifacts ({} -> {})", compiler.stage,
                 &compiler.host, target));
+        // compile with `-Z emit-stack-sizes`; see bootstrap/src/rustc.rs for more details
+        cargo.env("RUSTC_EMIT_STACK_SIZES", "1");
         run_cargo(builder,
                   &mut cargo,
                   &libstd_stamp(builder, compiler, target),
@@ -382,6 +384,8 @@ fn run(self, builder: &Builder<'_>) {
         let _folder = builder.fold_output(|| format!("stage{}-test", compiler.stage));
         builder.info(&format!("Building stage{} test artifacts ({} -> {})", compiler.stage,
                 &compiler.host, target));
+        // compile with `-Z emit-stack-sizes`; see bootstrap/src/rustc.rs for more details
+        cargo.env("RUSTC_EMIT_STACK_SIZES", "1");
         run_cargo(builder,
                   &mut cargo,
                   &libtest_stamp(builder, compiler, target),