Skip to content

compiletest: Default to one CGU when compiling tests. #47779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,19 @@ impl<'test> TestCx<'test> {
rustc.args(&["-Z", "human_readable_cgu_names"]);
}

let explicit_cgus = self.props
.compile_flags
.iter()
.any(|arg| arg.contains("codegen-units"));

// For performance reasons we want to compile tests with just one CGU if
// possible.
let adapt_cgu_count = |cmd: &mut Command| {
if !explicit_cgus {
cmd.arg("-Ccodegen-units=1");
}
};

match self.config.mode {
CompileFail | ParseFail | Incremental => {
// If we are extracting and matching errors in the new
Expand All @@ -1629,6 +1642,8 @@ impl<'test> TestCx<'test> {
"-Zdump-mir-exclude-pass-number",
]);

adapt_cgu_count(&mut rustc);

let mir_dump_dir = self.get_mir_dump_dir();
let _ = fs::remove_dir_all(&mir_dump_dir);
create_dir_all(mir_dump_dir.as_path()).unwrap();
Expand All @@ -1638,14 +1653,16 @@ impl<'test> TestCx<'test> {

rustc.arg(dir_opt);
}
RunPass |
RunFail |
RunPassValgrind |
Pretty |
DebugInfoGdb |
DebugInfoLldb |
Codegen |
Rustdoc |
RunPassValgrind |
RunFail |
RunPass => {
adapt_cgu_count(&mut rustc);
}
Pretty |
RunMake |
CodegenUnits => {
// do not use JSON output
Expand Down