Fix linker detection for linker (drivers) with a version postfix (e.g. clang-12 instead of clang) by jschwe · Pull Request #106489 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation30 Commits1 Checks0 Files changed
Conversation
This file contains hidden or 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
[ Show hidden characters]({{ revealButtonHref }})
Linker (drivers) such as clang / gcc or lld often have a version postfix matching the regex "-\d+$".
Previously, linker detection did not account for the possible version postfix and the fallback value was used, which can cause linker errors due to wrong arguments.
Also remove the check for -clang
, since there are no architecture specific variants of clang (to my knowledge).
Fixes #106454
r? @jackh726
(rustbot has picked a reviewer for you, use r? to override)
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
📌 Commit 41672bf5e5e2946e684ec5b0639863b0f789621f has been approved by oli-obk
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
bors added S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
labels
This comment was marked as resolved.
Would it make sense to add detection for g++
and clang++
(which should be treated the same as gcc/clang) in this PR, or should that be a seperate PR?
Would it make sense to add detection for
g++
andclang++
(which should be treated the same as gcc/clang) in this PR, or should that be a seperate PR?
Yeah, these can also be added.
This stuff is not strictly necessary because -C linker-flavor
can be added explicitly if it's not inferred correctly, so not everything is added, but adding obvious cases like g++
or clang++
should be fine.
This stuff is not strictly necessary because -C linker-flavor can be added explicitly if it's not inferred correctly
This requires using either RUSTFLAGS
(or one of the other ways to modify the rustflags for the crate and ALL dependencies) or cargo rustc
right? I.e. there is no way to set -C linker-flavor
for cargo test
without also setting the flag for all dependencies (where it might not be wanted).
I pushed a commit which strips the possible version postfix, but without using a regex this time. This makes the matching a bit nicer.
Ok, let's just land this as is.
r=me after squashing commits.
@rustbot author
rustbot added S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Linker drivers such as gcc, clang or lld often have a version postfix, e.g clang-12. The previous logic would not account for this and would fall back to guessing the linker flavor to be the default linker flavor for the target, which causes linker errors when this is not the case. By accounting for the possible version postfix and also considering g++ and clang++, we considerably reduce the amount of times the fallback guess has to be used.
To simplify matching check for a version postfix and match against the
linker stem without any version postfix.
In contrast to gcc, clang supports all architectures in one binary.
This means there are no variants like aarch64-linux-gnu-clang
and
there is no need to check for -clang
variants.
Rebased, squashed and adjusted the commit message.
@rustbot label -S-waiting-on-author +S-waiting-on-review
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
and removed S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
labels
📌 Commit 3bc2970 has been approved by petrochenkov
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…rochenkov
Fix linker detection for linker (drivers) with a version postfix (e.g. clang-12 instead of clang)
Linker (drivers) such as clang / gcc or lld often have a version postfix matching the regex "-\d+$".
Previously, linker detection did not account for the possible version postfix and the fallback value was used, which can cause linker errors due to wrong arguments.
Also remove the check for -clang
, since there are no architecture specific variants of clang (to my knowledge).
Fixes rust-lang#106454
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 10 pull requests
Successful merges:
- rust-lang#104645 (Add log-backtrace option to show backtraces along with logging)
- rust-lang#106465 (Bump
IMPLIED_BOUNDS_ENTAILMENT
to Deny + ReportNow) - rust-lang#106489 (Fix linker detection for linker (drivers) with a version postfix (e.g. clang-12 instead of clang))
- rust-lang#106585 (When suggesting writing a fully qualified path probe for appropriate types)
- rust-lang#106641 (Provide help on closures capturing self causing borrow checker errors)
- rust-lang#106678 (Warn when using panic-strategy abort for proc-macro crates)
- rust-lang#106701 (Fix
mpsc::SyncSender
spinning behavior) - rust-lang#106793 (Normalize test output more thoroughly)
- rust-lang#106797 (riscv: Fix ELF header flags)
- rust-lang#106813 (Remove redundant session field)
Failed merges:
r? @ghost
@rustbot
modify labels: rollup
jschwe deleted the fix_linker_detection branch
taiki-e added a commit to taiki-e/setup-cross-toolchain-action that referenced this pull request
Rust 1.68 (rust-lang/rust#106489) broke this:
= note: clang-15: error: unsupported option '--export'
clang-15: error: unsupported option '--stack-first'
clang-15: error: unsupported option '--allow-undefined'
clang-15: error: unsupported option '--fatal-warnings'
clang-15: error: unsupported option '--no-demangle'
clang-15: error: unsupported option '--gc-sections'
clang-15: error: unknown argument: '-flavor'
clang-15: error: no such file or directory: 'wasm'
clang-15: error: no such file or directory: '__main_void'
taiki-e added a commit to taiki-e/rust-cross-toolchain that referenced this pull request
Rust 1.68 (rust-lang/rust#106489) broke this:
= note: clang-15: error: unsupported option '--export'
clang-15: error: unsupported option '--stack-first'
clang-15: error: unsupported option '--allow-undefined'
clang-15: error: unsupported option '--fatal-warnings'
clang-15: error: unsupported option '--no-demangle'
clang-15: error: unsupported option '--gc-sections'
clang-15: error: unknown argument: '-flavor'
clang-15: error: no such file or directory: 'wasm'
clang-15: error: no such file or directory: '__main_void'
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
Labels
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the compiler team, which will review and decide on the PR/issue.