Skip to content

Commit 3f9ab7a

Browse files
committed
Pass more host flags using RUSTC_HOST_FLAGS
1 parent 4ea6e7f commit 3f9ab7a

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/bootstrap/bin/_helper.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fn parse_rustc_verbose() -> usize {
1414
/// Parses the value of the "RUSTC_STAGE" environment variable and returns it as a `String`.
1515
///
1616
/// If "RUSTC_STAGE" was not set, the program will be terminated with 101.
17+
#[allow(unused)]
1718
fn parse_rustc_stage() -> String {
1819
std::env::var("RUSTC_STAGE").unwrap_or_else(|_| {
1920
// Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead.

src/bootstrap/bin/rustc.rs

-15
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fn main() {
2727
let args = env::args_os().skip(1).collect::<Vec<_>>();
2828
let arg = |name| args.windows(2).find(|args| args[0] == name).and_then(|args| args[1].to_str());
2929

30-
let stage = parse_rustc_stage();
3130
let verbose = parse_rustc_verbose();
3231

3332
// Detect whether or not we're a build script depending on whether --target
@@ -108,27 +107,13 @@ fn main() {
108107
cmd.arg("-Ztls-model=initial-exec");
109108
}
110109
} else {
111-
// FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars
112-
// here, but rather Cargo should know what flags to pass rustc itself.
113-
114110
// Find any host flags that were passed by bootstrap.
115111
// The flags are stored in a RUSTC_HOST_FLAGS variable, separated by spaces.
116112
if let Ok(flags) = std::env::var("RUSTC_HOST_FLAGS") {
117113
for flag in flags.split(' ') {
118114
cmd.arg(flag);
119115
}
120116
}
121-
122-
// Cargo doesn't pass RUSTFLAGS to proc_macros:
123-
// https://github.com/rust-lang/cargo/issues/4423
124-
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
125-
// We also declare that the flag is expected, which we need to do to not
126-
// get warnings about it being unexpected.
127-
if stage == "0" {
128-
cmd.arg("--cfg=bootstrap");
129-
}
130-
cmd.arg("-Zunstable-options");
131-
cmd.arg("--check-cfg=values(bootstrap)");
132117
}
133118

134119
if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {

src/bootstrap/builder.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,20 @@ impl<'a> Builder<'a> {
14381438
}
14391439
}
14401440

1441+
// FIXME(rust-lang/cargo#5754) we shouldn't be using special command arguments
1442+
// to the host invocation here, but rather Cargo should know what flags to pass rustc
1443+
// itself.
1444+
if stage == 0 {
1445+
hostflags.arg("--cfg=bootstrap");
1446+
}
1447+
// Cargo doesn't pass RUSTFLAGS to proc_macros:
1448+
// https://github.com/rust-lang/cargo/issues/4423
1449+
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
1450+
// We also declare that the flag is expected, which we need to do to not
1451+
// get warnings about it being unexpected.
1452+
hostflags.arg("-Zunstable-options");
1453+
hostflags.arg("--check-cfg=values(bootstrap)");
1454+
14411455
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
14421456
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
14431457
// #71458.

0 commit comments

Comments
 (0)