Only obey optimize-tests flag on UI tests that are run-pass
``` optimize-tests = false, master 25.98s optimize-tests = true, master 34.69s optimize-tests = true, patched 28.79s ``` Effects: - faster UI tests - llvm asserts get exercised less on build-pass tests - the difference between opt and nopt builds shrinks a bit - aux libs don't get optimized since they don't have a pass mode and almost never have explicit compile flags
This commit is contained in:
parent
4118ad24d6
commit
125f33aa4c
@ -1365,11 +1365,14 @@ fn run(self, builder: &Builder<'_>) {
|
||||
}
|
||||
|
||||
let mut flags = if is_rustdoc { Vec::new() } else { vec!["-Crpath".to_string()] };
|
||||
if !is_rustdoc {
|
||||
if !is_rustdoc && mode != "ui" {
|
||||
if builder.config.rust_optimize_tests {
|
||||
flags.push("-O".to_string());
|
||||
}
|
||||
}
|
||||
if builder.config.rust_optimize_tests {
|
||||
cmd.arg("--optimize-tests");
|
||||
}
|
||||
flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests));
|
||||
flags.push(builder.config.cmd.rustc_args().join(" "));
|
||||
|
||||
|
@ -269,6 +269,11 @@ pub struct Config {
|
||||
/// Flags to pass to the compiler when building for the target
|
||||
pub target_rustcflags: Option<String>,
|
||||
|
||||
/// Whether tests should be optimized.
|
||||
/// Currently only provides a default for UI-tests that are run-pass.
|
||||
/// Other tests are controlled by rustcflags or the testfiles themselves.
|
||||
pub optimize_tests: bool,
|
||||
|
||||
/// What panic strategy the target is built with. Unwind supports Abort, but
|
||||
/// not vice versa.
|
||||
pub target_panic: PanicStrategy,
|
||||
|
@ -244,6 +244,7 @@ pub fn from_aux_file(&self, testfile: &Path, cfg: Option<&str>, config: &Config)
|
||||
|
||||
// copy over select properties to the aux build:
|
||||
props.incremental_dir = self.incremental_dir.clone();
|
||||
props.ignore_pass = true;
|
||||
props.load_from(testfile, cfg, config);
|
||||
|
||||
props
|
||||
|
@ -102,6 +102,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
||||
)
|
||||
.optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
|
||||
.optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
|
||||
.optflag("", "optimize-tests", "build UI tests with optimization enabled")
|
||||
.optopt("", "target-panic", "what panic strategy the target supports", "unwind | abort")
|
||||
.optflag("", "verbose", "run tests verbosely, showing all output")
|
||||
.optflag(
|
||||
@ -253,6 +254,7 @@ fn make_absolute(path: PathBuf) -> PathBuf {
|
||||
runtool: matches.opt_str("runtool"),
|
||||
host_rustcflags: Some(matches.opt_strs("host-rustcflags").join(" ")),
|
||||
target_rustcflags: Some(matches.opt_strs("target-rustcflags").join(" ")),
|
||||
optimize_tests: matches.opt_present("optimize-tests"),
|
||||
target_panic: match matches.opt_str("target-panic").as_deref() {
|
||||
Some("unwind") | None => PanicStrategy::Unwind,
|
||||
Some("abort") => PanicStrategy::Abort,
|
||||
|
@ -1875,6 +1875,18 @@ fn make_compile_args(
|
||||
rustc.arg("-Zdeduplicate-diagnostics=no");
|
||||
}
|
||||
Ui => {
|
||||
// If optimize-tests is true we still only want to optimize tests that actually get
|
||||
// executed and that don't specify their own optimization levels
|
||||
if self.config.optimize_tests
|
||||
&& self.props.pass_mode(&self.config) == Some(PassMode::Run)
|
||||
&& !self
|
||||
.props
|
||||
.compile_flags
|
||||
.iter()
|
||||
.any(|arg| arg == "-O" || arg.contains("opt-level"))
|
||||
{
|
||||
rustc.arg("-O");
|
||||
}
|
||||
if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) {
|
||||
rustc.args(&["--error-format", "json"]);
|
||||
rustc.args(&["--json", "future-incompat"]);
|
||||
|
Loading…
Reference in New Issue
Block a user