From f4e4ec7e6dedf61b86ae321cb93457d09a81c9fe Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 13 May 2016 15:26:41 -0700 Subject: [PATCH] rustbuild: Pass -O to tests based on configuration Currently rustbuild isn't detecting the `-O` flag for tests via the `--disable-optimize-tests` or not command line flag to `./configure`, and this commit patches up the support to pass `-O` by default. --- src/bootstrap/build/check.rs | 13 +++++++++++-- src/bootstrap/build/config.rs | 9 +++++++++ src/bootstrap/config.toml.example | 5 +++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/build/check.rs b/src/bootstrap/build/check.rs index f12b0dadeac..154d9556fd7 100644 --- a/src/bootstrap/build/check.rs +++ b/src/bootstrap/build/check.rs @@ -105,9 +105,18 @@ pub fn compiletest(build: &Build, cmd.arg("--host").arg(compiler.host); cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build)); + let mut flags = format!("-Crpath"); + if build.config.rust_optimize_tests { + flags.push_str(" -O"); + } + if build.config.rust_debuginfo_tests { + flags.push_str(" -g"); + } + + cmd.arg("--host-rustcflags").arg(&flags); + let linkflag = format!("-Lnative={}", build.test_helpers_out(target).display()); - cmd.arg("--host-rustcflags").arg("-Crpath"); - cmd.arg("--target-rustcflags").arg(format!("-Crpath {}", linkflag)); + cmd.arg("--target-rustcflags").arg(format!("{} {}", flags, linkflag)); // FIXME: needs android support cmd.arg("--android-cross-path").arg(""); diff --git a/src/bootstrap/build/config.rs b/src/bootstrap/build/config.rs index 533c1c93d5b..3c35b9a9516 100644 --- a/src/bootstrap/build/config.rs +++ b/src/bootstrap/build/config.rs @@ -59,6 +59,8 @@ pub struct Config { pub rust_rpath: bool, pub rustc_default_linker: Option, pub rustc_default_ar: Option, + pub rust_optimize_tests: bool, + pub rust_debuginfo_tests: bool, pub build: String, pub host: Vec, @@ -136,6 +138,8 @@ struct Rust { channel: Option, musl_root: Option, rpath: Option, + optimize_tests: Option, + debuginfo_tests: Option, } /// TOML representation of how each build target is configured. @@ -154,6 +158,7 @@ impl Config { config.llvm_optimize = true; config.use_jemalloc = true; config.rust_optimize = true; + config.rust_optimize_tests = true; config.submodules = true; config.docs = true; config.rust_rpath = true; @@ -219,6 +224,8 @@ impl Config { set(&mut config.rust_debug_assertions, rust.debug_assertions); set(&mut config.rust_debuginfo, rust.debuginfo); set(&mut config.rust_optimize, rust.optimize); + set(&mut config.rust_optimize_tests, rust.optimize_tests); + set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); set(&mut config.rust_rpath, rust.rpath); set(&mut config.debug_jemalloc, rust.debug_jemalloc); set(&mut config.use_jemalloc, rust.use_jemalloc); @@ -306,6 +313,8 @@ impl Config { ("JEMALLOC", self.use_jemalloc), ("DEBUG_JEMALLOC", self.debug_jemalloc), ("RPATH", self.rust_rpath), + ("OPTIMIZE_TESTS", self.rust_optimize_tests), + ("DEBUGINFO_TESTS", self.rust_debuginfo_tests), } match key { diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example index a0e6ab1a2d2..6f065842328 100644 --- a/src/bootstrap/config.toml.example +++ b/src/bootstrap/config.toml.example @@ -122,6 +122,11 @@ # desired in distributions, for example. #rpath = true +# Flag indicating whether tests are compiled with optimizations (the -O flag) or +# with debuginfo (the -g flag) +#optimize-tests = true +#debuginfo-tests = true + # ============================================================================= # Options for specific targets #