-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Infer Lld::No
linker hint when the linker stem is a generic compiler driver
#114711
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These commits modify compiler targets. |
@bors r+ rollup |
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Aug 15, 2023
Infer `Lld::No` linker hint when the linker stem is a generic compiler driver This PR basically reverts the temporary solution in rust-lang#113631 to a more long-term solution. r? `@petrochenkov` In [this comment](rust-lang#113631 (comment)), you had ideas about a long-term solution: > I wonder what a good non-temporary solution for the inference would look like. > > * If the default is `(Cc::No, Lld::Yes)` (e.g. `rust-lld`) > > * and we switch to some specific platform compiler (e.g. `-C linker=arm-none-eabi-gcc`), should we change to `Lld::No`? Maybe yes? > * and we switch to some non-default but generic compiler `-C linker=clang`? Then maybe not? > > * If the default is `(Cc::Yes, Lld::Yes)` (e.g. future x86_64 linux with default LLD) > > * and we switch to some specific platform compiler (e.g. `-C linker=arm-none-eabi-gcc`), should we change to `Lld::No`? Maybe yes? > * and we switch to some non-default but generic compiler `-C linker=clang`? Then maybe not? > I believe that we should infer the `Lld::No` linker hint for any `-Clinker` override, and all the cases above: - the linker drivers have their own defaults, so in my mind `-Clinker` is a signal to use its default linker / flavor, rather than ours or the target's. In the case of generic compilers, it's more likely than not going to be `Lld::No`. I would expect this to be the case in general, even when including platform-specific compilers. - the guess will be wrong if the linker driver uses lld by default (and we also don't want to search for `-fuse-ld` link args), but will work in the more common cases. And the minority of other cases can fix the wrong guess by opting into the precise linker flavor. - this also ensures backwards-compatibility: today, even on targets with an lld default and overriding the linker, rustc will not use lld. That includes `thumbv6m-none-eabi` where issue rust-lang#113597 happened. It looks like the simplest option, and the one with least churn: we maintain the current behavior in ambiguous cases. I've tested that this works on rust-lang#113597, as expected from the failure. (I also have a no-std `run-make` test using a custom target json spec: basically simulating a future `x86_64-unknown-linux-gnu` using an lld flavor by default, to check that e.g. `-Clinker=clang` doesn't use lld. I could add that test to this PR, but IIUC such a custom target requires `cargo -Z build-std` and we have no tests depending on this cargo feature yet. Let me know if you want to add this test of the linker inference for such targets.) What do you think ?
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 15, 2023
…llaumeGomez Rollup of 10 pull requests Successful merges: - rust-lang#114711 (Infer `Lld::No` linker hint when the linker stem is a generic compiler driver) - rust-lang#114772 (Add `{Local}ModDefId` to more strongly type DefIds`) - rust-lang#114800 (std: add some missing repr(transparent)) - rust-lang#114820 (Add test for unknown_lints from another file.) - rust-lang#114825 (Upgrade std to gimli 0.28.0) - rust-lang#114827 (Only consider object candidates for object-safe dyn types in new solver) - rust-lang#114828 (Probe when assembling upcast candidates so they don't step on eachother's toes in new solver) - rust-lang#114829 (Separate `consider_unsize_to_dyn_candidate` from other unsize candidates) - rust-lang#114830 (Clean up some bad UI testing annotations) - rust-lang#114831 (Check projection args before substitution in new solver) r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR basically reverts the temporary solution in #113631 to a more long-term solution.
r? @petrochenkov
In this comment, you had ideas about a long-term solution:
I believe that we should infer the
Lld::No
linker hint for any-Clinker
override, and all the cases above:-Clinker
is a signal to use its default linker / flavor, rather than ours or the target's. In the case of generic compilers, it's more likely than not going to beLld::No
. I would expect this to be the case in general, even when including platform-specific compilers.-fuse-ld
link args), but will work in the more common cases. And the minority of other cases can fix the wrong guess by opting into the precise linker flavor.thumbv6m-none-eabi
where issue Regression when usinglinker=arm-none-eabi-gcc
#113597 happened.It looks like the simplest option, and the one with least churn: we maintain the current behavior in ambiguous cases.
I've tested that this works on #113597, as expected from the failure.
(I also have a no-std
run-make
test using a custom target json spec: basically simulating a futurex86_64-unknown-linux-gnu
using an lld flavor by default, to check that e.g.-Clinker=clang
doesn't use lld. I could add that test to this PR, but IIUC such a custom target requirescargo -Z build-std
and we have no tests depending on this cargo feature yet. Let me know if you want to add this test of the linker inference for such targets.)What do you think ?