]> git.lizzy.rs Git - rust.git/commitdiff
rustbuild: Pass -O to tests based on configuration
authorAlex Crichton <alex@alexcrichton.com>
Fri, 13 May 2016 22:26:41 +0000 (15:26 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 18 May 2016 23:36:08 +0000 (16:36 -0700)
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
src/bootstrap/build/config.rs
src/bootstrap/config.toml.example

index f12b0dadeacc1ce9389a0de629436809211ef57d..154d9556fd7ba2331e248ab1e9c20c7ca72757f7 100644 (file)
@@ -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("");
index 533c1c93d5bc47772f2243ec6a9c5fb91bd44b08..3c35b9a95169a908478b0fcf9ce0d7a156f4e775 100644 (file)
@@ -59,6 +59,8 @@ pub struct Config {
     pub rust_rpath: bool,
     pub rustc_default_linker: Option<String>,
     pub rustc_default_ar: Option<String>,
+    pub rust_optimize_tests: bool,
+    pub rust_debuginfo_tests: bool,
 
     pub build: String,
     pub host: Vec<String>,
@@ -136,6 +138,8 @@ struct Rust {
     channel: Option<String>,
     musl_root: Option<String>,
     rpath: Option<bool>,
+    optimize_tests: Option<bool>,
+    debuginfo_tests: Option<bool>,
 }
 
 /// TOML representation of how each build target is configured.
@@ -154,6 +158,7 @@ pub fn parse(build: &str, file: Option<PathBuf>) -> 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 @@ pub fn parse(build: &str, file: Option<PathBuf>) -> 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 @@ macro_rules! check {
                 ("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 {
index a0e6ab1a2d2d01d8f873aef7d817a7dd117c28f6..6f0658423283be3c61f9377c0f04dcc8f0b24f49 100644 (file)
 # 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
 #