fix(rustflags): Respect rustflags when probing rustc for the sysroot - #17393
fix(rustflags): Respect rustflags when probing rustc for the sysroot#17393adamgemmell wants to merge 7 commits into
Conversation
…o.rs to util/rustc.rs
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
We probably want to beta backport if this merges. |
|
FWIW in a proc-macro package, this fails: I am still trying to figure out what is the correct behavior, though just FYI after the refactor before this PR, this command works. |
|
Thanks very much for testing, it's a good spot. I think it's because host sysroot lookups didn't used to respect RUSTFLAGS, but with this PR they do.
I think the assumption in this PR that it's only useful to have one sysroot per Cargo invocation is broken, so we could do option 2. or 4.. |
That is my main "concern". I am not sure if |
|
I'm fine with reverting by the way, coming up with some plumbing sounds like it might be easier than working out the intended behaviour here. |
|
Sounds good. Let's revert to buy us more time to think about it. Thank you for taking care of it |
### What does this PR try to resolve? This PR fixes rust-lang#17351 by reverting the offending rust-lang#17276. It should be backported to beta. We tried to address the issues in rust-lang#17393 but found that the situation was more complex than we thought, and I'll go another route to make the changes I need. This PR did not revert cleanly, and there were merge conflicts in the 2nd commit in `trim_paths.rs`. ### How to test and review this PR? Compare with the reverted PR.
What does this PR try to resolve?
Fixes #17351 by restoring the ability for
RUSTFLAGS,CARGO_ENCODED_RUSTFLAGSandbuild.rustflagsto override the sysroot.As discussed in the issue, this PR does not restore the ability for
rustflagsin thetargetcfg to override the sysroot as it's very difficult for build-std to support this and it's not clear if anyone has a need for the functionality. Users surveyed includecargo carefulandcargo miriin the issue, and xargo.This PR also cleans up a leftover comment introduced in the PR that caused this issue.
How to test and review this PR?
The PR introduces unit tests and implements the new behaviour in a sequence of atomic commits. I'd recommend reading each one turn to understand the change. The behaviour can be tested by invoking cargo with
RUSTFLAGS="--sysroot=dir"or by settingbuild.rustflags.🤖 LLM disclosure: I asked an LLM whether my tests would pass on Windows as a sanity check, and used the information returned to rewrite them. All code was hand-written and wasn't generated.