Pass more host flags using RUSTC_HOST_FLAGS
This commit is contained in:
parent
4ea6e7fc13
commit
3f9ab7ad92
@ -14,6 +14,7 @@ fn parse_rustc_verbose() -> usize {
|
||||
/// Parses the value of the "RUSTC_STAGE" environment variable and returns it as a `String`.
|
||||
///
|
||||
/// If "RUSTC_STAGE" was not set, the program will be terminated with 101.
|
||||
#[allow(unused)]
|
||||
fn parse_rustc_stage() -> String {
|
||||
std::env::var("RUSTC_STAGE").unwrap_or_else(|_| {
|
||||
// Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead.
|
||||
|
@ -27,7 +27,6 @@ fn main() {
|
||||
let args = env::args_os().skip(1).collect::<Vec<_>>();
|
||||
let arg = |name| args.windows(2).find(|args| args[0] == name).and_then(|args| args[1].to_str());
|
||||
|
||||
let stage = parse_rustc_stage();
|
||||
let verbose = parse_rustc_verbose();
|
||||
|
||||
// Detect whether or not we're a build script depending on whether --target
|
||||
@ -108,9 +107,6 @@ fn main() {
|
||||
cmd.arg("-Ztls-model=initial-exec");
|
||||
}
|
||||
} else {
|
||||
// FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars
|
||||
// here, but rather Cargo should know what flags to pass rustc itself.
|
||||
|
||||
// Find any host flags that were passed by bootstrap.
|
||||
// The flags are stored in a RUSTC_HOST_FLAGS variable, separated by spaces.
|
||||
if let Ok(flags) = std::env::var("RUSTC_HOST_FLAGS") {
|
||||
@ -118,17 +114,6 @@ fn main() {
|
||||
cmd.arg(flag);
|
||||
}
|
||||
}
|
||||
|
||||
// Cargo doesn't pass RUSTFLAGS to proc_macros:
|
||||
// https://github.com/rust-lang/cargo/issues/4423
|
||||
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
|
||||
// We also declare that the flag is expected, which we need to do to not
|
||||
// get warnings about it being unexpected.
|
||||
if stage == "0" {
|
||||
cmd.arg("--cfg=bootstrap");
|
||||
}
|
||||
cmd.arg("-Zunstable-options");
|
||||
cmd.arg("--check-cfg=values(bootstrap)");
|
||||
}
|
||||
|
||||
if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {
|
||||
|
@ -1438,6 +1438,20 @@ pub fn cargo(
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(rust-lang/cargo#5754) we shouldn't be using special command arguments
|
||||
// to the host invocation here, but rather Cargo should know what flags to pass rustc
|
||||
// itself.
|
||||
if stage == 0 {
|
||||
hostflags.arg("--cfg=bootstrap");
|
||||
}
|
||||
// Cargo doesn't pass RUSTFLAGS to proc_macros:
|
||||
// https://github.com/rust-lang/cargo/issues/4423
|
||||
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
|
||||
// We also declare that the flag is expected, which we need to do to not
|
||||
// get warnings about it being unexpected.
|
||||
hostflags.arg("-Zunstable-options");
|
||||
hostflags.arg("--check-cfg=values(bootstrap)");
|
||||
|
||||
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
|
||||
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
|
||||
// #71458.
|
||||
|
Loading…
Reference in New Issue
Block a user