Skip to content

Commit cd6d165

Browse files
authored
Rollup merge of rust-lang#109156 - taiki-e:linker-detection, r=petrochenkov
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````
2 parents 023154e + 86a5e36 commit cd6d165

File tree

1 file changed

+3
-1
lines changed
  • compiler/rustc_codegen_ssa/src/back

1 file changed

+3
-1
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1199,15 +1199,17 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
11991199
.and_then(|(lhs, rhs)| rhs.chars().all(char::is_numeric).then_some(lhs))
12001200
.unwrap_or(stem);
12011201

1202-
// GCC can have an optional target prefix.
1202+
// GCC/Clang can have an optional target prefix.
12031203
let flavor = if stem == "emcc" {
12041204
LinkerFlavor::EmCc
12051205
} else if stem == "gcc"
12061206
|| stem.ends_with("-gcc")
12071207
|| stem == "g++"
12081208
|| stem.ends_with("-g++")
12091209
|| stem == "clang"
1210+
|| stem.ends_with("-clang")
12101211
|| stem == "clang++"
1212+
|| stem.ends_with("-clang++")
12111213
{
12121214
LinkerFlavor::from_cli(LinkerFlavorCli::Gcc, &sess.target)
12131215
} else if stem == "wasm-ld" || stem.ends_with("-wasm-ld") {

0 commit comments

Comments
 (0)