Rollup merge of #82309 - jyn514:rustdocflags, r=Mark-Simulacrum
Propagate RUSTDOCFLAGS in the environment when documenting Previously, RUSTDOCFLAGS would get overriden when bootstrap set `RUSTDOCFLAGS` itself. Propagate the flag manually, using the same logic as `RUSTFLAGS`. Fixes https://github.com/rust-lang/rust/issues/75256.
This commit is contained in:
commit
3de9b41850
1 changed files with 23 additions and 11 deletions
|
@ -939,6 +939,12 @@ impl<'a> Builder<'a> {
|
||||||
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
|
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
|
||||||
// #71458.
|
// #71458.
|
||||||
let mut rustdocflags = rustflags.clone();
|
let mut rustdocflags = rustflags.clone();
|
||||||
|
rustdocflags.propagate_cargo_env("RUSTDOCFLAGS");
|
||||||
|
if stage == 0 {
|
||||||
|
rustdocflags.env("RUSTDOCFLAGS_BOOTSTRAP");
|
||||||
|
} else {
|
||||||
|
rustdocflags.env("RUSTDOCFLAGS_NOT_BOOTSTRAP");
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(s) = env::var("CARGOFLAGS") {
|
if let Ok(s) = env::var("CARGOFLAGS") {
|
||||||
cargo.args(s.split_whitespace());
|
cargo.args(s.split_whitespace());
|
||||||
|
@ -1544,23 +1550,29 @@ impl<'a> Builder<'a> {
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct Rustflags(String);
|
struct Rustflags(String, TargetSelection);
|
||||||
|
|
||||||
impl Rustflags {
|
impl Rustflags {
|
||||||
fn new(target: TargetSelection) -> Rustflags {
|
fn new(target: TargetSelection) -> Rustflags {
|
||||||
let mut ret = Rustflags(String::new());
|
let mut ret = Rustflags(String::new(), target);
|
||||||
|
ret.propagate_cargo_env("RUSTFLAGS");
|
||||||
// Inherit `RUSTFLAGS` by default ...
|
|
||||||
ret.env("RUSTFLAGS");
|
|
||||||
|
|
||||||
// ... and also handle target-specific env RUSTFLAGS if they're
|
|
||||||
// configured.
|
|
||||||
let target_specific = format!("CARGO_TARGET_{}_RUSTFLAGS", crate::envify(&target.triple));
|
|
||||||
ret.env(&target_specific);
|
|
||||||
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// By default, cargo will pick up on various variables in the environment. However, bootstrap
|
||||||
|
/// reuses those variables to pass additional flags to rustdoc, so by default they get overriden.
|
||||||
|
/// Explicitly add back any previous value in the environment.
|
||||||
|
///
|
||||||
|
/// `prefix` is usually `RUSTFLAGS` or `RUSTDOCFLAGS`.
|
||||||
|
fn propagate_cargo_env(&mut self, prefix: &str) {
|
||||||
|
// Inherit `RUSTFLAGS` by default ...
|
||||||
|
self.env(prefix);
|
||||||
|
|
||||||
|
// ... and also handle target-specific env RUSTFLAGS if they're configured.
|
||||||
|
let target_specific = format!("CARGO_TARGET_{}_{}", crate::envify(&self.1.triple), prefix);
|
||||||
|
self.env(&target_specific);
|
||||||
|
}
|
||||||
|
|
||||||
fn env(&mut self, env: &str) {
|
fn env(&mut self, env: &str) {
|
||||||
if let Ok(s) = env::var(env) {
|
if let Ok(s) = env::var(env) {
|
||||||
for part in s.split(' ') {
|
for part in s.split(' ') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue