Merge pull request #452 from GuillaumeGomez/master-cfg

Remove unused `feature = "master"` cfg in build_system
This commit is contained in:
antoyo 2024-02-21 09:28:12 -05:00 committed by GitHub
commit 2e67633d3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 59 additions and 56 deletions

View File

@ -19,9 +19,6 @@ fn new() -> Result<Option<Self>, String> {
while let Some(arg) = args.next() {
match arg.as_str() {
"--no-default-features" => {
build_arg.flags.push("--no-default-features".to_string());
}
"--features" => {
if let Some(arg) = args.next() {
build_arg.flags.push("--features".to_string());
@ -51,7 +48,6 @@ fn usage() {
r#"
`build` command help:
--no-default-features : Add `--no-default-features` flag
--features [arg] : Add a new feature [arg]"#
);
ConfigInfo::show_usage();
@ -112,34 +108,25 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
}
rustflags.push_str(" -Z force-unstable-if-unmarked");
let mut env = env.clone();
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];
if config.no_default_features {
rustflags.push_str(" -Csymbol-mangling-version=v0");
args.push(&"--no-default-features");
}
let channel = if config.sysroot_release_channel {
env.insert(
"RUSTFLAGS".to_string(),
format!("{} -Zmir-opt-level=3", rustflags),
);
run_command_with_output_and_env(
&[
&"cargo",
&"build",
&"--release",
&"--target",
&config.target,
],
Some(start_dir),
Some(&env),
)?;
rustflags.push_str(" -Zmir-opt-level=3");
args.push(&"--release");
"release"
} else {
env.insert("RUSTFLAGS".to_string(), rustflags);
run_command_with_output_and_env(
&[&"cargo", &"build", &"--target", &config.target],
Some(start_dir),
Some(&env),
)?;
"debug"
};
env.insert("RUSTFLAGS".to_string(), rustflags);
run_command_with_output_and_env(&args, Some(start_dir), Some(&env))?;
// Copy files to sysroot
let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple));
fs::create_dir_all(&sysroot_path).map_err(|error| {
@ -193,6 +180,13 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
args.config_info.gcc_path.clone(),
);
if args.config_info.no_default_features {
env.insert(
"RUSTFLAGS".to_string(),
"-Csymbol-mangling-version=v0".to_string(),
);
}
let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"];
if args.config_info.channel == Channel::Release {
command.push(&"--release");
@ -201,6 +195,9 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
} else {
env.insert("CHANNEL".to_string(), "debug".to_string());
}
if args.config_info.no_default_features {
command.push(&"--no-default-features");
}
let flags = args.flags.iter().map(|s| s.as_str()).collect::<Vec<_>>();
for flag in &flags {
command.push(flag);

View File

@ -127,6 +127,7 @@ pub struct ConfigInfo {
// Needed for the `info` command which doesn't want to actually download the lib if needed,
// just to set the `gcc_path` field to display it.
pub no_download: bool,
pub no_default_features: bool,
}
impl ConfigInfo {
@ -177,6 +178,7 @@ pub fn parse_argument(
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string())
}
},
"--no-default-features" => self.no_default_features = true,
_ => return Ok(false),
}
Ok(true)
@ -416,8 +418,9 @@ pub fn setup(
rustflags.push(linker.to_string());
}
#[cfg(not(feature="master"))]
rustflags.push("-Csymbol-mangling-version=v0".to_string());
if self.no_default_features {
rustflags.push("-Csymbol-mangling-version=v0".to_string());
}
rustflags.extend_from_slice(&[
"-Cdebuginfo=2".to_string(),
@ -495,7 +498,8 @@ pub fn show_usage() {
--sysroot-panic-abort : Build the sysroot without unwinding support
--config-file : Location of the config file to be 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"
);
}
}

View File

@ -90,7 +90,6 @@ fn show_usage() {
--release : Build codegen in release mode
--sysroot-panic-abort : Build the sysroot without unwinding support.
--no-default-features : Add `--no-default-features` flag
--features [arg] : Add a new feature [arg]
--use-system-gcc : Use system installed libgccjit
--build-only : Only build rustc_codegen_gcc then exits
@ -110,7 +109,6 @@ fn show_usage() {
#[derive(Default, Debug)]
struct TestArg {
no_default_features: bool,
build_only: bool,
use_system_gcc: bool,
runners: BTreeSet<String>,
@ -132,13 +130,6 @@ fn new() -> Result<Option<Self>, String> {
while let Some(arg) = args.next() {
match arg.as_str() {
"--no-default-features" => {
// To prevent adding it more than once.
if !test_arg.no_default_features {
test_arg.flags.push("--no-default-features".into());
}
test_arg.no_default_features = true;
}
"--features" => match args.next() {
Some(feature) if !feature.is_empty() => {
test_arg
@ -196,11 +187,14 @@ fn new() -> Result<Option<Self>, String> {
);
}
}
if test_arg.config_info.no_default_features {
test_arg.flags.push("--no-default-features".into());
}
Ok(Some(test_arg))
}
pub fn is_using_gcc_master_branch(&self) -> bool {
!self.no_default_features
!self.config_info.no_default_features
}
}
@ -612,20 +606,23 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
let rustc_args =
&format!(
r#"-Zpanic-abort-tests \
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort"#,
pwd = std::env::current_dir()
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
.display(),
channel = args.config_info.channel.as_str(),
dylib_ext = args.config_info.dylib_ext,
);
let extra = if args.is_using_gcc_master_branch() {
""
} else {
" -Csymbol-mangling-version=v0"
};
#[cfg(not(feature="master"))]
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
let rustc_args = &format!(
r#"-Zpanic-abort-tests \
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort{extra}"#,
pwd = std::env::current_dir()
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
.display(),
channel = args.config_info.channel.as_str(),
dylib_ext = args.config_info.dylib_ext,
extra = extra,
);
run_command_with_env(
&[
@ -1069,16 +1066,21 @@ fn file_handling(file_path: &Path) -> Result<(), String> {
// FIXME: create a function "display_if_not_quiet" or something along the line.
println!("[TEST] rustc test suite");
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
let extra = if args.is_using_gcc_master_branch() {
""
} else {
" -Csymbol-mangling-version=v0"
};
let rustc_args = format!(
"{} -Zcodegen-backend={} --sysroot {}",
"{} -Zcodegen-backend={} --sysroot {}{}",
env.get("TEST_FLAGS").unwrap_or(&String::new()),
args.config_info.cg_backend_path,
args.config_info.sysroot_path,
extra,
);
#[cfg(not(feature="master"))]
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
env.get_mut("RUSTFLAGS").unwrap().clear();
run_command_with_output_and_env(
&[