Skip to content

Conversation

@karolzwolak
Copy link
Member

@karolzwolak karolzwolak commented Nov 13, 2025

Before this PR extra flags from env variables like RUSTFLAGS had lower precedence than bootstrap flags. This PR changes that, and tus makes overriding flags passed to the compiler easier and more reliable.
This is technically a breaking change — but it only affects people using these env variables.

This change was discussed on zulip by members of bootstrap team.

To be exact these the following flags have their precedence increased:

  • RUSTFLAGS
  • RUSTFLAGS_NOT_BOOTSTRAP
  • RUSTFLAGS_BOOTSTRAP
  • CARGOFLAGS_NOT_BOOTSTRAP
  • CARGOFLAGS_BOOTSTRAP
  • CARGO_TARGET_{target}_RUSTFLAGS

r? @Kobzol

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Nov 13, 2025
@karolzwolak karolzwolak force-pushed the bootstrap-rustflags-precedence branch 2 times, most recently from ce939ab to 456ce9a Compare November 13, 2025 15:59
@karolzwolak
Copy link
Member Author

See also #148795 and #148782 for more context.

@rust-log-analyzer

This comment has been minimized.

…otstrap own flags and not the other way around.
@karolzwolak karolzwolak force-pushed the bootstrap-rustflags-precedence branch from 456ce9a to e0750a1 Compare November 13, 2025 16:35
// #71458.
let mut rustdocflags = rustflags.clone();
rustdocflags.propagate_rustflag_envs(build_compiler_stage);
rustdocflags.propagate_cargo_env("RUSTDOCFLAGS");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To uphold the rule that RUSTDOCFLAGS have preference, the env. vars. for rustdocflags should be only propagated after bootstrap sets its flags, right? Near line 1360.

Actually, now that I think about it, the changes from this PR are not enough. Because after being created, the Cargo struct has a rustflag method, which is used in other places in bootstrap to configure additional flags.

So if we really want the external env. var. to override everything, we should only do the actual propagation in impl From<Cargo> for BootstrapCommand, where the rustflags are "materialized".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants