Skip to content

Commit b82d86e

Browse files
committed
bootstrap: Handle target-specific cargo env vars
This commit ensure that we handle target-specific env vars for RUSTFLAGS through Cargo as well.
1 parent ac29809 commit b82d86e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/bootstrap/builder.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ impl<'a> Builder<'a> {
804804
stage = compiler.stage;
805805
}
806806

807-
let mut rustflags = Rustflags::new();
807+
let mut rustflags = Rustflags::new(&target, &mut cargo);
808808
if stage != 0 {
809809
rustflags.env("RUSTFLAGS_NOT_BOOTSTRAP");
810810
} else {
@@ -1258,9 +1258,19 @@ mod tests;
12581258
struct Rustflags(String);
12591259

12601260
impl Rustflags {
1261-
fn new() -> Rustflags {
1261+
fn new(target: &str, cmd: &mut Command) -> Rustflags {
12621262
let mut ret = Rustflags(String::new());
1263+
1264+
// Inherit `RUSTFLAGS` by default
12631265
ret.env("RUSTFLAGS");
1266+
1267+
// ... and also handle target-specific env RUSTFLAGS if they're
1268+
// configured. If this is configured we also remove it from the
1269+
// environment because Cargo will prefer it over RUSTFLAGS.
1270+
let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(target));
1271+
ret.env(&target_specific);
1272+
cmd.env_remove(&target_specific);
1273+
12641274
return ret;
12651275
}
12661276

0 commit comments

Comments
 (0)