Skip to content

Commit 706c60b

Browse files
Add new --with-llvm-sysroot test option
1 parent 9bcf4c1 commit 706c60b

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
"--test-successful-rustc --nb-parts 2 --current-part 1",
3838
"--projects",
3939
"--gcc-asm-tests",
40+
# With the LLVM sysroot now.
41+
"--test-successful-rustc --nb-parts 2 --current-part 0 --with-llvm-sysroot",
42+
"--test-successful-rustc --nb-parts 2 --current-part 1 --with-llvm-sysroot",
43+
"--projects --with-llvm-sysroot",
4044
]
4145

4246
steps:

build_system/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub struct ConfigInfo {
122122
pub no_default_features: bool,
123123
pub backend: Option<String>,
124124
pub features: Vec<String>,
125+
pub use_llvm_sysroot: bool,
125126
}
126127

127128
impl ConfigInfo {
@@ -394,11 +395,10 @@ impl ConfigInfo {
394395
// by its build system directly so no need to set it ourselves.
395396
rustflags.push(format!("-Zcodegen-backend={backend}"));
396397
} else {
397-
rustflags.extend_from_slice(&[
398-
"--sysroot".to_string(),
399-
self.sysroot_path.clone(),
400-
format!("-Zcodegen-backend={}", self.cg_backend_path),
401-
]);
398+
if !self.use_llvm_sysroot {
399+
rustflags.extend_from_slice(&["--sysroot".to_string(), self.sysroot_path.clone()]);
400+
}
401+
rustflags.push(format!("-Zcodegen-backend={}", self.cg_backend_path));
402402
}
403403

404404
// This environment variable is useful in case we want to change options of rustc commands.

build_system/src/test.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fn show_usage() {
7070
7171
--features [arg] : Add a new feature [arg]
7272
--use-system-gcc : Use system installed libgccjit
73+
--use-llvm-sysroot : Use LLVM sysroot instead of the one compiled with `cg_gcc`
7374
--build-only : Only build rustc_codegen_gcc then exits
7475
--nb-parts : Used to split rustc_tests (for CI needs)
7576
--current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
@@ -132,6 +133,9 @@ impl TestArg {
132133
"--keep-lto-tests" => {
133134
test_arg.keep_lto_tests = true;
134135
}
136+
"--use-llvm-sysroot" => {
137+
test_arg.config_info.use_llvm_sysroot = true;
138+
}
135139
"--sysroot-features" => match args.next() {
136140
Some(feature) if !feature.is_empty() => {
137141
test_arg.sysroot_features.push(feature);
@@ -283,6 +287,9 @@ fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> {
283287
fn build_sysroot(env: &Env, args: &TestArg) -> Result<(), String> {
284288
// FIXME: create a function "display_if_not_quiet" or something along the line.
285289
println!("[BUILD] sysroot");
290+
if !args.config_info.use_llvm_sysroot {
291+
println!("`--use-llvm-sysroot` option was used, skipping sysroot build");
292+
}
286293
let mut config = args.config_info.clone();
287294
config.features.extend(args.sysroot_features.iter().cloned());
288295
build::build_sysroot(env, &config)?;
@@ -630,8 +637,12 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
630637
if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" };
631638

632639
let rustc_args = format!(
633-
"-Zpanic-abort-tests -Zcodegen-backend={codegen_backend_path} --sysroot {} -Cpanic=abort{extra}",
634-
args.config_info.sysroot_path
640+
"-Zpanic-abort-tests -Zcodegen-backend={codegen_backend_path}{} -Cpanic=abort{extra}",
641+
if args.config_info.use_llvm_sysroot {
642+
String::new()
643+
} else {
644+
format!(" --sysroot {}", args.config_info.sysroot_path)
645+
},
635646
);
636647

637648
run_command_with_env(
@@ -1124,10 +1135,14 @@ where
11241135
if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" };
11251136

11261137
let rustc_args = format!(
1127-
"{test_flags} -Zcodegen-backend={backend} --sysroot {sysroot}{extra}",
1138+
"{test_flags} -Zcodegen-backend={backend}{sysroot}{extra}",
11281139
test_flags = env.get("TEST_FLAGS").unwrap_or(&String::new()),
11291140
backend = args.config_info.cg_backend_path,
1130-
sysroot = args.config_info.sysroot_path,
1141+
sysroot = if args.config_info.use_llvm_sysroot {
1142+
String::new()
1143+
} else {
1144+
format!(" --sysroot {}", args.config_info.sysroot_path)
1145+
},
11311146
extra = extra,
11321147
);
11331148

0 commit comments

Comments
 (0)