Skip to content

Commit 91a6f0a

Browse files
Correctly handle "master" feature
1 parent e785093 commit 91a6f0a

File tree

3 files changed

+39
-30
lines changed

3 files changed

+39
-30
lines changed

build_system/src/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
111111
rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests");
112112
}
113113
rustflags.push_str(" -Z force-unstable-if-unmarked");
114+
if config.no_default_features {
115+
rustflags.push_str(" -Csymbol-mangling-version=v0");
116+
}
114117
let mut env = env.clone();
115118
let channel = if config.sysroot_release_channel {
116119
env.insert(

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)