-
Notifications
You must be signed in to change notification settings - Fork 14k
add rust.rustflags and per target rustflags options to bootstrap.toml
#148795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
This PR modifies If appropriate, please update This PR modifies If appropriate, please update |
|
Just to clarify, does this provide any additional benefit over just configuring |
|
Yes it does! |
|
Hey, does this PR allow for target specific rustflags? |
|
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 |
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 |
|
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 |
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. |
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. |
|
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. |
|
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. |
|
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. |
|
Hmm, I managed to add rustflags to the target and build rustc that way |
|
Builder literally calls cargo like this |
|
Please move this discussion to #148816, I will answer there. |
295a6a6 to
b99462a
Compare
|
Update:
|
This comment has been minimized.
This comment has been minimized.
b99462a to
b2a5120
Compare
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"] ```
b2a5120 to
c9c9773
Compare
|
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. |
This comment has been minimized.
This comment has been minimized.
c9c9773 to
c700e86
Compare
rust.rustflags option to bootstrap.tomlrust.rustflags and per target rustflags options to bootstrap.toml
|
There might be a way to make |
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