Skip to content

Commit 2e67633

Browse files
authored
Merge pull request #452 from GuillaumeGomez/master-cfg
Remove unused `feature = "master"` cfg in build_system
2 parents e785093 + 114c25f commit 2e67633

File tree

3 files changed

+59
-56
lines changed

3 files changed

+59
-56
lines changed

build_system/src/build.rs

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ impl BuildArg {
1919

2020
while let Some(arg) = args.next() {
2121
match arg.as_str() {
22-
"--no-default-features" => {
23-
build_arg.flags.push("--no-default-features".to_string());
24-
}
2522
"--features" => {
2623
if let Some(arg) = args.next() {
2724
build_arg.flags.push("--features".to_string());
@@ -51,7 +48,6 @@ impl BuildArg {
5148
r#"
5249
`build` command help:
5350
54-
--no-default-features : Add `--no-default-features` flag
5551
--features [arg] : Add a new feature [arg]"#
5652
);
5753
ConfigInfo::show_usage();
@@ -112,34 +108,25 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
112108
}
113109
rustflags.push_str(" -Z force-unstable-if-unmarked");
114110
let mut env = env.clone();
111+
112+
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];
113+
114+
if config.no_default_features {
115+
rustflags.push_str(" -Csymbol-mangling-version=v0");
116+
args.push(&"--no-default-features");
117+
}
118+
115119
let channel = if config.sysroot_release_channel {
116-
env.insert(
117-
"RUSTFLAGS".to_string(),
118-
format!("{} -Zmir-opt-level=3", rustflags),
119-
);
120-
run_command_with_output_and_env(
121-
&[
122-
&"cargo",
123-
&"build",
124-
&"--release",
125-
&"--target",
126-
&config.target,
127-
],
128-
Some(start_dir),
129-
Some(&env),
130-
)?;
120+
rustflags.push_str(" -Zmir-opt-level=3");
121+
args.push(&"--release");
131122
"release"
132123
} else {
133-
env.insert("RUSTFLAGS".to_string(), rustflags);
134-
135-
run_command_with_output_and_env(
136-
&[&"cargo", &"build", &"--target", &config.target],
137-
Some(start_dir),
138-
Some(&env),
139-
)?;
140124
"debug"
141125
};
142126

127+
env.insert("RUSTFLAGS".to_string(), rustflags);
128+
run_command_with_output_and_env(&args, Some(start_dir), Some(&env))?;
129+
143130
// Copy files to sysroot
144131
let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple));
145132
fs::create_dir_all(&sysroot_path).map_err(|error| {
@@ -193,6 +180,13 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
193180
args.config_info.gcc_path.clone(),
194181
);
195182

183+
if args.config_info.no_default_features {
184+
env.insert(
185+
"RUSTFLAGS".to_string(),
186+
"-Csymbol-mangling-version=v0".to_string(),
187+
);
188+
}
189+
196190
let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"];
197191
if args.config_info.channel == Channel::Release {
198192
command.push(&"--release");
@@ -201,6 +195,9 @@ fn build_codegen(args: &mut BuildArg) -> Result<(), String> {
201195
} else {
202196
env.insert("CHANNEL".to_string(), "debug".to_string());
203197
}
198+
if args.config_info.no_default_features {
199+
command.push(&"--no-default-features");
200+
}
204201
let flags = args.flags.iter().map(|s| s.as_str()).collect::<Vec<_>>();
205202
for flag in &flags {
206203
command.push(flag);

build_system/src/config.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ pub struct ConfigInfo {
127127
// Needed for the `info` command which doesn't want to actually download the lib if needed,
128128
// just to set the `gcc_path` field to display it.
129129
pub no_download: bool,
130+
pub no_default_features: bool,
130131
}
131132

132133
impl ConfigInfo {
@@ -177,6 +178,7 @@ impl ConfigInfo {
177178
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string())
178179
}
179180
},
181+
"--no-default-features" => self.no_default_features = true,
180182
_ => return Ok(false),
181183
}
182184
Ok(true)
@@ -416,8 +418,9 @@ impl ConfigInfo {
416418
rustflags.push(linker.to_string());
417419
}
418420

419-
#[cfg(not(feature="master"))]
420-
rustflags.push("-Csymbol-mangling-version=v0".to_string());
421+
if self.no_default_features {
422+
rustflags.push("-Csymbol-mangling-version=v0".to_string());
423+
}
421424

422425
rustflags.extend_from_slice(&[
423426
"-Cdebuginfo=2".to_string(),
@@ -495,7 +498,8 @@ impl ConfigInfo {
495498
--sysroot-panic-abort : Build the sysroot without unwinding support
496499
--config-file : Location of the config file to be used
497500
--cg_gcc-path : Location of the rustc_codegen_gcc root folder (used
498-
when ran from another directory)"
501+
when ran from another directory)
502+
--no-default-features : Add `--no-default-features` flag to cargo commands"
499503
);
500504
}
501505
}

build_system/src/test.rs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ fn show_usage() {
9090
9191
--release : Build codegen in release mode
9292
--sysroot-panic-abort : Build the sysroot without unwinding support.
93-
--no-default-features : Add `--no-default-features` flag
9493
--features [arg] : Add a new feature [arg]
9594
--use-system-gcc : Use system installed libgccjit
9695
--build-only : Only build rustc_codegen_gcc then exits
@@ -110,7 +109,6 @@ fn show_usage() {
110109

111110
#[derive(Default, Debug)]
112111
struct TestArg {
113-
no_default_features: bool,
114112
build_only: bool,
115113
use_system_gcc: bool,
116114
runners: BTreeSet<String>,
@@ -132,13 +130,6 @@ impl TestArg {
132130

133131
while let Some(arg) = args.next() {
134132
match arg.as_str() {
135-
"--no-default-features" => {
136-
// To prevent adding it more than once.
137-
if !test_arg.no_default_features {
138-
test_arg.flags.push("--no-default-features".into());
139-
}
140-
test_arg.no_default_features = true;
141-
}
142133
"--features" => match args.next() {
143134
Some(feature) if !feature.is_empty() => {
144135
test_arg
@@ -196,11 +187,14 @@ impl TestArg {
196187
);
197188
}
198189
}
190+
if test_arg.config_info.no_default_features {
191+
test_arg.flags.push("--no-default-features".into());
192+
}
199193
Ok(Some(test_arg))
200194
}
201195

202196
pub fn is_using_gcc_master_branch(&self) -> bool {
203-
!self.no_default_features
197+
!self.config_info.no_default_features
204198
}
205199
}
206200

@@ -612,20 +606,23 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
612606

613607
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
614608

615-
let rustc_args =
616-
&format!(
617-
r#"-Zpanic-abort-tests \
618-
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
619-
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort"#,
620-
pwd = std::env::current_dir()
621-
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
622-
.display(),
623-
channel = args.config_info.channel.as_str(),
624-
dylib_ext = args.config_info.dylib_ext,
625-
);
609+
let extra = if args.is_using_gcc_master_branch() {
610+
""
611+
} else {
612+
" -Csymbol-mangling-version=v0"
613+
};
626614

627-
#[cfg(not(feature="master"))]
628-
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
615+
let rustc_args = &format!(
616+
r#"-Zpanic-abort-tests \
617+
-Zcodegen-backend="{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}" \
618+
--sysroot "{pwd}/build_sysroot/sysroot" -Cpanic=abort{extra}"#,
619+
pwd = std::env::current_dir()
620+
.map_err(|error| format!("`current_dir` failed: {:?}", error))?
621+
.display(),
622+
channel = args.config_info.channel.as_str(),
623+
dylib_ext = args.config_info.dylib_ext,
624+
extra = extra,
625+
);
629626

630627
run_command_with_env(
631628
&[
@@ -1069,16 +1066,21 @@ where
10691066
// FIXME: create a function "display_if_not_quiet" or something along the line.
10701067
println!("[TEST] rustc test suite");
10711068
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
1069+
1070+
let extra = if args.is_using_gcc_master_branch() {
1071+
""
1072+
} else {
1073+
" -Csymbol-mangling-version=v0"
1074+
};
1075+
10721076
let rustc_args = format!(
1073-
"{} -Zcodegen-backend={} --sysroot {}",
1077+
"{} -Zcodegen-backend={} --sysroot {}{}",
10741078
env.get("TEST_FLAGS").unwrap_or(&String::new()),
10751079
args.config_info.cg_backend_path,
10761080
args.config_info.sysroot_path,
1081+
extra,
10771082
);
10781083

1079-
#[cfg(not(feature="master"))]
1080-
let rustc_args = format!("{} -Csymbol-mangling-version=v0", rustc_args);
1081-
10821084
env.get_mut("RUSTFLAGS").unwrap().clear();
10831085
run_command_with_output_and_env(
10841086
&[

0 commit comments

Comments
 (0)