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.
This commit is contained in:
parent
bdadad85b5
commit
f4e4ec7e6d
@ -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("");
|
||||
|
@ -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 @@ 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 {
|
||||
|
@ -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
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user