Skip to content

Commit 3ffa6da

Browse files
compiletest: Default to one CGU when compiling tests.
1 parent 5669050 commit 3ffa6da

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,19 @@ impl<'test> TestCx<'test> {
16061606
rustc.args(&["-Z", "human_readable_cgu_names"]);
16071607
}
16081608

1609+
let explicit_cgus = self.props
1610+
.compile_flags
1611+
.iter()
1612+
.any(|arg| arg.contains("codegen-units"));
1613+
1614+
// For performance reasons we want to compile tests with just one CGU if
1615+
// possible.
1616+
let adapt_cgu_count = |cmd: &mut Command| {
1617+
if !explicit_cgus {
1618+
cmd.arg("-Ccodegen-units=1");
1619+
}
1620+
};
1621+
16091622
match self.config.mode {
16101623
CompileFail | ParseFail | Incremental => {
16111624
// If we are extracting and matching errors in the new
@@ -1629,6 +1642,8 @@ impl<'test> TestCx<'test> {
16291642
"-Zdump-mir-exclude-pass-number",
16301643
]);
16311644

1645+
adapt_cgu_count(&mut rustc);
1646+
16321647
let mir_dump_dir = self.get_mir_dump_dir();
16331648
let _ = fs::remove_dir_all(&mir_dump_dir);
16341649
create_dir_all(mir_dump_dir.as_path()).unwrap();
@@ -1638,14 +1653,16 @@ impl<'test> TestCx<'test> {
16381653

16391654
rustc.arg(dir_opt);
16401655
}
1641-
RunPass |
1642-
RunFail |
1643-
RunPassValgrind |
1644-
Pretty |
16451656
DebugInfoGdb |
16461657
DebugInfoLldb |
16471658
Codegen |
16481659
Rustdoc |
1660+
RunPassValgrind |
1661+
RunFail |
1662+
RunPass => {
1663+
adapt_cgu_count(&mut rustc);
1664+
}
1665+
Pretty |
16491666
RunMake |
16501667
CodegenUnits => {
16511668
// do not use JSON output

0 commit comments

Comments
 (0)