Uh oh!
There was an error while loading. Please reload this page.
add rust.rustflags and per target rustflags options to bootstrap.toml - #148795
Conversation
rustbot
commented
Nov 10, 2025
This PR modifies If appropriate, please update This PR modifies If appropriate, please update |
Uh oh!
There was an error while loading. Please reload this page.
Kobzol
commented
Nov 10, 2025
Just to clarify, does this provide any additional benefit over just configuring |
karolzwolak
commented
Nov 10, 2025
Yes it does! |
Kobzol
commented
Nov 11, 2025
Right. It would be great if you could generalize this to multiple targets, so that it would be possible to set e.g. I would also suggest that |
karolzwolak
commented
Nov 11, 2025
It's only global ones — but I will add target specific ones (see the following reply).
Sure, will do. I wasn't sure it was needed so I only added global ones.
Yeah I know it's a bit weird. However all options from rust/src/bootstrap/src/core/builder/cargo.rs Lines 26 to 31 in c8f22ca rust/src/bootstrap/src/core/builder/cargo.rs Lines 603 to 615 in c8f22ca RUSTFLAGS are first, followed by more specific {RUST, CARGO}FLAGS_{NOT_, _}BOOTSTRAP flags. Relative order of the all the variables is okay here — but they all should be applied after all the bootstrap.toml options — not before.I think we should match behavior of cargo:
This could be a breaking change breaking peoples |
Urgau
commented
Nov 11, 2025
If the main goal is to allow the use of custom linkers, why not have a more targeted approch to it? Allowing anyone to set custom Some could set |
Kobzol
commented
Nov 11, 2025
Yeah, that's what I was proposing.
We already have a lot of custom configs, including linkers. But I don't doubt that there are a bunch of people that just want to pass whatever flags they need when building rustc, and it sounds reasonable to me to make this easier. Of course we should also document that using this flags is "at your own risk" and it can break pretty much anything. |
karolzwolak
commented
Nov 11, 2025
Yes exactly — I didn't want to add yet another option that will be limited.
Okay — then I'm putting this PR on hold till I change the precedence in another PR. |
Oh, sorry, I was unclear 🤦 I didn't mean to change the existing behavior w.r.t. the old rustflags handling. I just thought that we might specifically put the new rustflags from So to summarize the order:
Today, we have the order 2) -> 3), after this PR we'd have 1) -> 2) -> 3). There is no need to land a separate PR, I think. |
karolzwolak
commented
Nov 11, 2025
Sure. The new options are going to be a bit awkward to use because they might not have high enough precedence but I get that 'fixing' this would be a breaking change. |
Kobzol
commented
Nov 11, 2025
I mean, there are probably good reasons for that. If you override rustflags set by bootstrap, there's a high chance that the build itself will fail. But yeah, we could still allow it, in theory. But that would have to be a separate change - I can bring this to t-boostrap. |
karolzwolak
commented
Nov 11, 2025
That'd be nice if you could bring it up to t-bootstrap. These flags should behave as they do in cargo. If it turned out we wanted to change the precedence we can do it in the future after merging this — it's gonna be a breaking change anyway. |
Kobzol
commented
Nov 11, 2025
Please move this discussion to #148816, I will answer there. |
295a6a6 to
b99462aComparekarolzwolak
commented
Nov 11, 2025
Update:
|
This comment has been minimized.
This comment has been minimized.
b2a5120 to
c9c9773Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
karolzwolak
commented
Nov 17, 2025
rustbot
commented
Nov 17, 2025
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bors
commented
Nov 18, 2025
☔ The latest upstream changes (presumably #148803) made this pull request unmergeable. Please resolve the merge conflicts. |
1711db1 to
d4f7efdComparerustbot
commented
Nov 20, 2025
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…p.toml This makes easy to persistently pass any flag to the compiler when building rustc. For example you can use a different linker by putting the following in `bootstrap.toml`: ```toml [rust] rustflags = ["-Clinker=clang", "-Clink-arg=--ld-path=wild"] ```
d4f7efd to
6e63c39Comparekarolzwolak
commented
Nov 21, 2025
No worries! I addressed the comments. |
Kobzol
commented
Nov 21, 2025
Thanks! @bors r+ |
bors
commented
Nov 21, 2025
Rollup of 7 pull requests Successful merges: - #146978 (Emit error when using path-segment keyword as cfg pred) - #148719 (Allow unnormalized types in drop elaboration) - #148795 (add `rust.rustflags` and per target `rustflags` options to `bootstrap.toml`) - #149028 ([rustdoc] Remove `UrlFragment::render` method to unify `clean::types::links` and `anchor`) - #149043 ( rustdoc-json: add rlib path to ExternalCrate to enable robust crate resolution) - #149098 (Fix error message for calling a non-tuple struct) - #149151 (Add test for importing path-segment keyword) r? `@ghost` `@rustbot` modify labels: rollup
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #148795 - karolzwolak:rustflags-bootstrap-toml, r=Kobzol add `rust.rustflags` and per target `rustflags` options to `bootstrap.toml` Part of #148782; see also #148708 Add new options `rust.rustflags` for all targets and `rustflags` par target that will pass specified flags to rustc for all stages. Target specific flags override (are passed after) global `rust.rustflags` ones. This makes easy to persistently pass any flag to the compiler when building rustc. For example you can use a different linker by putting the following in `bootstrap.toml`: ```toml [rust] rustflags = ["-Clinker=clang", "-Clink-arg=--ld-path=wild"] ``` r? bootstrap
…nsistently (#1324) I've updated instructions on building rustc with wild linker because rust-lang/rust#148795 got merged. This makes you can now put rustflags in the `bootstrap.toml` just like in `.cargo/config.toml`. This should means building rustc with wild should finally be both easy & reliable.
Rollup of 7 pull requests Successful merges: - rust-lang/rust#146978 (Emit error when using path-segment keyword as cfg pred) - rust-lang/rust#148719 (Allow unnormalized types in drop elaboration) - rust-lang/rust#148795 (add `rust.rustflags` and per target `rustflags` options to `bootstrap.toml`) - rust-lang/rust#149028 ([rustdoc] Remove `UrlFragment::render` method to unify `clean::types::links` and `anchor`) - rust-lang/rust#149043 ( rustdoc-json: add rlib path to ExternalCrate to enable robust crate resolution) - rust-lang/rust#149098 (Fix error message for calling a non-tuple struct) - rust-lang/rust#149151 (Add test for importing path-segment keyword) r? `@ghost` `@rustbot` modify labels: rollup
Part of #148782; see also #148708
Add new options
rust.rustflagsfor all targets andrustflagspar target that will pass specified flags to rustc for all stages. Target specific flags override (are passed after) globalrust.rustflagsones.This makes easy to persistently pass any flag to the compiler when building rustc. For example you can use a different linker by putting the following in
bootstrap.toml:r? bootstrap