Skip to content

Commit 0ac09b1

Browse files
Remove unneeded special case for rust CI
1 parent ee8d8cd commit 0ac09b1

File tree

2 files changed

+30
-47
lines changed

2 files changed

+30
-47
lines changed

compiler/rustc_codegen_gcc/build_system/src/config.rs

+29-36
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub struct ConfigInfo {
128128
// just to set the `gcc_path` field to display it.
129129
pub no_download: bool,
130130
pub no_default_features: bool,
131+
pub backend: Option<String>,
131132
}
132133

133134
impl ConfigInfo {
@@ -178,6 +179,14 @@ impl ConfigInfo {
178179
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string())
179180
}
180181
},
182+
"--use-backend" => match args.next() {
183+
Some(backend) if !backend.is_empty() => self.backend = Some(backend),
184+
_ => {
185+
return Err(
186+
"Expected an argument after `--use-backend`, found nothing".into()
187+
)
188+
}
189+
},
181190
"--no-default-features" => self.no_default_features = true,
182191
_ => return Ok(false),
183192
}
@@ -377,39 +386,25 @@ impl ConfigInfo {
377386
"debug"
378387
};
379388

380-
let has_builtin_backend = env
381-
.get("BUILTIN_BACKEND")
382-
.map(|backend| !backend.is_empty())
383-
.unwrap_or(false);
384-
385389
let mut rustflags = Vec::new();
386-
if has_builtin_backend {
387-
// It means we're building inside the rustc testsuite, so some options need to be handled
388-
// a bit differently.
389-
self.cg_backend_path = "gcc".to_string();
390-
391-
match env.get("RUSTC_SYSROOT") {
392-
Some(rustc_sysroot) if !rustc_sysroot.is_empty() => {
393-
rustflags.extend_from_slice(&["--sysroot".to_string(), rustc_sysroot.clone()]);
394-
}
395-
_ => {}
396-
}
397-
// This should not be needed, but is necessary for the CI in the rust repository.
398-
// FIXME: Remove when the rust CI switches to the master version of libgccjit.
399-
rustflags.push("-Cpanic=abort".to_string());
390+
self.cg_backend_path = current_dir
391+
.join("target")
392+
.join(channel)
393+
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
394+
.display()
395+
.to_string();
396+
self.sysroot_path = current_dir
397+
.join("build_sysroot/sysroot")
398+
.display()
399+
.to_string();
400+
if let Some(backend) = &self.backend {
401+
rustflags.push(format!("-Zcodegen-backend={}", backend));
400402
} else {
401-
self.cg_backend_path = current_dir
402-
.join("target")
403-
.join(channel)
404-
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
405-
.display()
406-
.to_string();
407-
self.sysroot_path = current_dir
408-
.join("build_sysroot/sysroot")
409-
.display()
410-
.to_string();
411-
rustflags.extend_from_slice(&["--sysroot".to_string(), self.sysroot_path.clone()]);
412-
};
403+
rustflags.extend_from_slice(&[
404+
"--sysroot".to_string(), self.sysroot_path.clone(),
405+
format!("-Zcodegen-backend={}", self.cg_backend_path),
406+
]);
407+
}
413408

414409
// This environment variable is useful in case we want to change options of rustc commands.
415410
if let Some(cg_rustflags) = env.get("CG_RUSTFLAGS") {
@@ -427,10 +422,7 @@ impl ConfigInfo {
427422
rustflags.push("-Csymbol-mangling-version=v0".to_string());
428423
}
429424

430-
rustflags.extend_from_slice(&[
431-
"-Cdebuginfo=2".to_string(),
432-
format!("-Zcodegen-backend={}", self.cg_backend_path),
433-
]);
425+
rustflags.push("-Cdebuginfo=2".to_string());
434426

435427
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
436428
// TODO(antoyo): remove when we can handle ThinLTO.
@@ -504,7 +496,8 @@ impl ConfigInfo {
504496
--config-file : Location of the config file to be used
505497
--cg_gcc-path : Location of the rustc_codegen_gcc root folder (used
506498
when ran from another directory)
507-
--no-default-features : Add `--no-default-features` flag to cargo commands"
499+
--no-default-features : Add `--no-default-features` flag to cargo commands
500+
--use-backend : Useful only for rustc testsuite"
508501
);
509502
}
510503
}

compiler/rustc_codegen_gcc/build_system/src/test.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ fn show_usage() {
9393
--features [arg] : Add a new feature [arg]
9494
--use-system-gcc : Use system installed libgccjit
9595
--build-only : Only build rustc_codegen_gcc then exits
96-
--use-backend : Useful only for rustc testsuite
9796
--nb-parts : Used to split rustc_tests (for CI needs)
9897
--current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
9998
);
@@ -113,7 +112,6 @@ struct TestArg {
113112
use_system_gcc: bool,
114113
runners: BTreeSet<String>,
115114
flags: Vec<String>,
116-
backend: Option<String>,
117115
nb_parts: Option<usize>,
118116
current_part: Option<usize>,
119117
sysroot_panic_abort: bool,
@@ -145,14 +143,6 @@ impl TestArg {
145143
test_arg.use_system_gcc = true;
146144
}
147145
"--build-only" => test_arg.build_only = true,
148-
"--use-backend" => match args.next() {
149-
Some(backend) if !backend.is_empty() => test_arg.backend = Some(backend),
150-
_ => {
151-
return Err(
152-
"Expected an argument after `--use-backend`, found nothing".into()
153-
)
154-
}
155-
},
156146
"--nb-parts" => {
157147
test_arg.nb_parts = Some(get_number_after_arg(&mut args, "--nb-parts")?);
158148
}
@@ -199,7 +189,7 @@ impl TestArg {
199189
}
200190

201191
fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> {
202-
if args.backend.is_some() {
192+
if args.config_info.backend.is_some() {
203193
return Ok(());
204194
}
205195
let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"];

0 commit comments

Comments
 (0)