Remove unneeded special case for rust CI

This commit is contained in:
Guillaume Gomez 2024-03-03 23:00:46 +01:00
parent faebf73983
commit 06d07f816a
2 changed files with 30 additions and 47 deletions

View File

@ -128,6 +128,7 @@ pub struct ConfigInfo {
// just to set the `gcc_path` field to display it. // just to set the `gcc_path` field to display it.
pub no_download: bool, pub no_download: bool,
pub no_default_features: bool, pub no_default_features: bool,
pub backend: Option<String>,
} }
impl ConfigInfo { impl ConfigInfo {
@ -178,6 +179,14 @@ pub fn parse_argument(
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string()) return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string())
} }
}, },
"--use-backend" => match args.next() {
Some(backend) if !backend.is_empty() => self.backend = Some(backend),
_ => {
return Err(
"Expected an argument after `--use-backend`, found nothing".into()
)
}
},
"--no-default-features" => self.no_default_features = true, "--no-default-features" => self.no_default_features = true,
_ => return Ok(false), _ => return Ok(false),
} }
@ -377,39 +386,25 @@ pub fn setup(
"debug" "debug"
}; };
let has_builtin_backend = env
.get("BUILTIN_BACKEND")
.map(|backend| !backend.is_empty())
.unwrap_or(false);
let mut rustflags = Vec::new(); let mut rustflags = Vec::new();
if has_builtin_backend { self.cg_backend_path = current_dir
// It means we're building inside the rustc testsuite, so some options need to be handled .join("target")
// a bit differently. .join(channel)
self.cg_backend_path = "gcc".to_string(); .join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
.display()
match env.get("RUSTC_SYSROOT") { .to_string();
Some(rustc_sysroot) if !rustc_sysroot.is_empty() => { self.sysroot_path = current_dir
rustflags.extend_from_slice(&["--sysroot".to_string(), rustc_sysroot.clone()]); .join("build_sysroot/sysroot")
} .display()
_ => {} .to_string();
} if let Some(backend) = &self.backend {
// This should not be needed, but is necessary for the CI in the rust repository. rustflags.push(format!("-Zcodegen-backend={}", backend));
// FIXME: Remove when the rust CI switches to the master version of libgccjit.
rustflags.push("-Cpanic=abort".to_string());
} else { } else {
self.cg_backend_path = current_dir rustflags.extend_from_slice(&[
.join("target") "--sysroot".to_string(), self.sysroot_path.clone(),
.join(channel) format!("-Zcodegen-backend={}", self.cg_backend_path),
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext)) ]);
.display() }
.to_string();
self.sysroot_path = current_dir
.join("build_sysroot/sysroot")
.display()
.to_string();
rustflags.extend_from_slice(&["--sysroot".to_string(), self.sysroot_path.clone()]);
};
// This environment variable is useful in case we want to change options of rustc commands. // This environment variable is useful in case we want to change options of rustc commands.
if let Some(cg_rustflags) = env.get("CG_RUSTFLAGS") { if let Some(cg_rustflags) = env.get("CG_RUSTFLAGS") {
@ -427,10 +422,7 @@ pub fn setup(
rustflags.push("-Csymbol-mangling-version=v0".to_string()); rustflags.push("-Csymbol-mangling-version=v0".to_string());
} }
rustflags.extend_from_slice(&[ rustflags.push("-Cdebuginfo=2".to_string());
"-Cdebuginfo=2".to_string(),
format!("-Zcodegen-backend={}", self.cg_backend_path),
]);
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO. // Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
// TODO(antoyo): remove when we can handle ThinLTO. // TODO(antoyo): remove when we can handle ThinLTO.
@ -504,7 +496,8 @@ pub fn show_usage() {
--config-file : Location of the config file to be used --config-file : Location of the config file to be used
--cg_gcc-path : Location of the rustc_codegen_gcc root folder (used --cg_gcc-path : Location of the rustc_codegen_gcc root folder (used
when ran from another directory) when ran from another directory)
--no-default-features : Add `--no-default-features` flag to cargo commands" --no-default-features : Add `--no-default-features` flag to cargo commands
--use-backend : Useful only for rustc testsuite"
); );
} }
} }

View File

@ -93,7 +93,6 @@ fn show_usage() {
--features [arg] : Add a new feature [arg] --features [arg] : Add a new feature [arg]
--use-system-gcc : Use system installed libgccjit --use-system-gcc : Use system installed libgccjit
--build-only : Only build rustc_codegen_gcc then exits --build-only : Only build rustc_codegen_gcc then exits
--use-backend : Useful only for rustc testsuite
--nb-parts : Used to split rustc_tests (for CI needs) --nb-parts : Used to split rustc_tests (for CI needs)
--current-part : Used with `--nb-parts`, allows you to specify which parts to test"# --current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
); );
@ -113,7 +112,6 @@ struct TestArg {
use_system_gcc: bool, use_system_gcc: bool,
runners: BTreeSet<String>, runners: BTreeSet<String>,
flags: Vec<String>, flags: Vec<String>,
backend: Option<String>,
nb_parts: Option<usize>, nb_parts: Option<usize>,
current_part: Option<usize>, current_part: Option<usize>,
sysroot_panic_abort: bool, sysroot_panic_abort: bool,
@ -145,14 +143,6 @@ fn new() -> Result<Option<Self>, String> {
test_arg.use_system_gcc = true; test_arg.use_system_gcc = true;
} }
"--build-only" => test_arg.build_only = true, "--build-only" => test_arg.build_only = true,
"--use-backend" => match args.next() {
Some(backend) if !backend.is_empty() => test_arg.backend = Some(backend),
_ => {
return Err(
"Expected an argument after `--use-backend`, found nothing".into()
)
}
},
"--nb-parts" => { "--nb-parts" => {
test_arg.nb_parts = Some(get_number_after_arg(&mut args, "--nb-parts")?); test_arg.nb_parts = Some(get_number_after_arg(&mut args, "--nb-parts")?);
} }
@ -199,7 +189,7 @@ pub fn is_using_gcc_master_branch(&self) -> bool {
} }
fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> { fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> {
if args.backend.is_some() { if args.config_info.backend.is_some() {
return Ok(()); return Ok(());
} }
let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"]; let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"];