-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix linker detection for linker (drivers) with a version postfix (e.g. clang-12 instead of clang) #106489
Conversation
r? @jackh726 (rustbot has picked a reviewer for you, use r? to override) |
r? compiler |
@bors r+ rollup |
📌 Commit 41672bf5e5e2946e684ec5b0639863b0f789621f has been approved by It is now in the queue for this repository. |
@bors r- |
5d8b2e9
to
3dc41f1
Compare
This comment was marked as resolved.
This comment was marked as resolved.
3dc41f1
to
08f5108
Compare
Would it make sense to add detection for |
Yeah, these can also be added. |
This requires using either |
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. |
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.
3a8d527
to
3bc2970
Compare
Rebased, squashed and adjusted the commit message. @rustbot label -S-waiting-on-author +S-waiting-on-review |
@bors r+ rollup |
…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
…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
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' ```
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' ```
…henkov Fix linker detection for clang with prefix rust-lang#106489 removed check for clang with prefix. It says: > Also remove the check for -clang, since there are no architecture specific variants of clang (to my knowledge). However, when doing cross-compilation, a wrapper script for clang with the target name as a prefix is sometimes used. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L62 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/scripts/freebsd-toolchain.sh#L76-L80 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L40 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs#L7 It seems the regression did not occur on the targets mentioned above because the default linker flavor is gcc, but it did occur on targets where the default linker flavor is not gcc (taiki-e/setup-cross-toolchain-action@fd352f3). r? `@petrochenkov`
…henkov Fix linker detection for clang with prefix rust-lang#106489 removed check for clang with prefix. It says: > Also remove the check for -clang, since there are no architecture specific variants of clang (to my knowledge). However, when doing cross-compilation, a wrapper script for clang with the target name as a prefix is sometimes used. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L62 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/scripts/freebsd-toolchain.sh#L76-L80 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L40 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs#L7 It seems the regression did not occur on the targets mentioned above because the default linker flavor is gcc, but it did occur on targets where the default linker flavor is not gcc (taiki-e/setup-cross-toolchain-action@fd352f3). r? ``@petrochenkov``
…henkov Fix linker detection for clang with prefix rust-lang#106489 removed check for clang with prefix. It says: > Also remove the check for -clang, since there are no architecture specific variants of clang (to my knowledge). However, when doing cross-compilation, a wrapper script for clang with the target name as a prefix is sometimes used. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L62 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/scripts/freebsd-toolchain.sh#L76-L80 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L40 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs#L7 It seems the regression did not occur on the targets mentioned above because the default linker flavor is gcc, but it did occur on targets where the default linker flavor is not gcc (taiki-e/setup-cross-toolchain-action@fd352f3). r? ```@petrochenkov```
…henkov Fix linker detection for clang with prefix rust-lang#106489 removed check for clang with prefix. It says: > Also remove the check for -clang, since there are no architecture specific variants of clang (to my knowledge). However, when doing cross-compilation, a wrapper script for clang with the target name as a prefix is sometimes used. https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L62 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/scripts/freebsd-toolchain.sh#L76-L80 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/src/ci/docker/host-x86_64/dist-various-2/Dockerfile#L40 https://github.com/rust-lang/rust/blob/1716932743a7b3705cbf0c34db0c4e070ed1930d/compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs#L7 It seems the regression did not occur on the targets mentioned above because the default linker flavor is gcc, but it did occur on targets where the default linker flavor is not gcc (taiki-e/setup-cross-toolchain-action@fd352f3). r? ````@petrochenkov````
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