bootstrap: Handle target-specific cargo env vars

This commit ensure that we handle target-specific env vars for RUSTFLAGS
through Cargo as well.
This commit is contained in:
Alex Crichton 2019-09-09 09:20:29 -07:00
parent ac29809940
commit b82d86ed60

View File

@ -804,7 +804,7 @@ impl<'a> Builder<'a> {
stage = compiler.stage;
}
let mut rustflags = Rustflags::new();
let mut rustflags = Rustflags::new(&target, &mut cargo);
if stage != 0 {
rustflags.env("RUSTFLAGS_NOT_BOOTSTRAP");
} else {
@ -1258,9 +1258,19 @@ mod tests;
struct Rustflags(String);
impl Rustflags {
fn new() -> Rustflags {
fn new(target: &str, cmd: &mut Command) -> Rustflags {
let mut ret = Rustflags(String::new());
// Inherit `RUSTFLAGS` by default
ret.env("RUSTFLAGS");
// ... and also handle target-specific env RUSTFLAGS if they're
// configured. If this is configured we also remove it from the
// environment because Cargo will prefer it over RUSTFLAGS.
let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(target));
ret.env(&target_specific);
cmd.env_remove(&target_specific);
return ret;
}