This is an archive of the discontinued LLVM Phabricator instance.

[clang] Don't default to a specifically shared libunwind on mingw with a g++ driver
ClosedPublic

Authored by mstorsjo on Mar 5 2021, 2:12 AM.

Details

Summary

For MinGW targets, we distinguish between an explicitly shared unwinder library (requested via -shared-libgcc), an explicitly static one (requested via -static-libgcc or -static) and the default case (which just passes -lunwind to the linker, which will pick either shared or static depending on what's available, with the normal linker logic).

This makes the implicit default case (as added in D79995) actually work as it was intended, when using the g++ driver (which is the main usecase for libunwind as far as I know).

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Mar 5 2021, 2:12 AM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2021, 2:12 AM

It's clear overlook from D79995, that part is perfectly reasonable to me.

I'm a bit worried about this code though:

bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc &&
                !TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing();

https://github.com/llvm/llvm-project/blob/0b274ed499603d30694c0b995252ab014609acf9/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1413
IIUC this change would flip it from false to true for Linux targets, which also sounds fine on it's own but goes beyond this diff description and seems to lack any test.

I'm a bit worried about this code though:

bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc &&
                !TC.getTriple().isAndroid() && !TC.getTriple().isOSCygMing();

https://github.com/llvm/llvm-project/blob/0b274ed499603d30694c0b995252ab014609acf9/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1413
IIUC this change would flip it from false to true for Linux targets, which also sounds fine on it's own but goes beyond this diff description and seems to lack any test.

Oh, you're right. Hmm, this is sure a bit entangled...

@MaskRay What do you think about this?

I have tested the following configurations on x86_64-linux-gnu and I don't find a difference.

CC=/tmp/RelA/bin/clang
CXX=/tmp/RelA/bin/clang++
$CC -c a.c
$CC a.o '-###' &> a/c.raw.txt
$CC a.o --rtlib=compiler-rt --unwindlib=none '-###' &> a/c.rt.none.txt
$CC a.o --rtlib=compiler-rt --unwindlib=libgcc '-###' &> a/c.rt.libgcc.txt
$CC a.o --rtlib=compiler-rt --unwindlib=libunwind '-###' &> a/c.rt.libunwind.txt
$CXX a.o '-###' &> a/cc.raw.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=none '-###' &> a/cc.rt.none.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=libgcc '-###' &> a/cc.rt.libgcc.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=libunwind '-###' &> a/cc.rt.libunwind.txt

I'd hope we reduce the usage of UnspecifiedLibGcc as it has the tricky --as-needed implication. I think the idea is that for C (no exceptions, so no _Unwind_Resume at the end of non-catch handlers), libgcc_s.so.1 is usually unneeded, so --as-needed can likely result in one fewer DT_NEEDED... This optimization probably does not have much value.

So if you want to add a condition, please test mingw triple instead of testing RLT == ToolChain::RLT_Libgcc

I have tested the following configurations on x86_64-linux-gnu and I don't find a difference.

CC=/tmp/RelA/bin/clang
CXX=/tmp/RelA/bin/clang++
$CC -c a.c
$CC a.o '-###' &> a/c.raw.txt
$CC a.o --rtlib=compiler-rt --unwindlib=none '-###' &> a/c.rt.none.txt
$CC a.o --rtlib=compiler-rt --unwindlib=libgcc '-###' &> a/c.rt.libgcc.txt
$CC a.o --rtlib=compiler-rt --unwindlib=libunwind '-###' &> a/c.rt.libunwind.txt
$CXX a.o '-###' &> a/cc.raw.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=none '-###' &> a/cc.rt.none.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=libgcc '-###' &> a/cc.rt.libgcc.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=libunwind '-###' &> a/cc.rt.libunwind.txt

That's strange; if I do clang++ a.o -### -rtlib=compiler-rt -unwindlib=libunwind I get --as-needed around the -l:libunwind.so with this patch, which wasn't there before.

I'd hope we reduce the usage of UnspecifiedLibGcc as it has the tricky --as-needed implication. I think the idea is that for C (no exceptions, so no _Unwind_Resume at the end of non-catch handlers), libgcc_s.so.1 is usually unneeded, so --as-needed can likely result in one fewer DT_NEEDED... This optimization probably does not have much value.

Tangentially related though, I'm running into a similar issue with linking C, when experimenting with taking -unwindlib into use - right now, my toolchain is complete to build C applications once I've built compiler-rt builtins. But if I'm adding -unwindlib=libunwind, linking of all C programs fail until I've built libunwind - and the fact that linking of C programs fails messes up the cmake setup for building libunwind. So that essentially forces adding an extra -unwindlib=none throughout the bootstrap process until libunwind has been built, which is a bit inelegant. (The alternative, creating a dummy empty libunwind.a until the real deal is built isn't very elegant either.)

So due to that, I'm pondering whether it'd make sense to propose a patch to only add the -lunwind into the link if actually linking with the g++ driver. I'm sure there's some C programs somewhere that wants to call the unwinder though (maybe for calling _Unwind_Backtrace?), which that'd break. (That would be broken in my current toolchains anyway, though.)

So if you want to add a condition, please test mingw triple instead of testing RLT == ToolChain::RLT_Libgcc

Ok, I guess that'd be more straightforward...

mstorsjo updated this revision to Diff 328657.Mar 5 2021, 2:46 PM
mstorsjo retitled this revision from [clang] Don't make the g++ driver imply an explicitly shared libunwind to [clang] Don't default to a specifically shared libunwind on mingw with a g++ driver.

Changed the condition to only apply for isOSCygMing().

mstorsjo edited the summary of this revision. (Show Details)Mar 5 2021, 2:47 PM
mati865 accepted this revision.Mar 5 2021, 2:48 PM
This revision is now accepted and ready to land.Mar 5 2021, 2:48 PM
MaskRay accepted this revision.Mar 5 2021, 3:14 PM

I have tested the following configurations on x86_64-linux-gnu and I don't find a difference.

CC=/tmp/RelA/bin/clang
CXX=/tmp/RelA/bin/clang++
$CC -c a.c
$CC a.o '-###' &> a/c.raw.txt
$CC a.o --rtlib=compiler-rt --unwindlib=none '-###' &> a/c.rt.none.txt
$CC a.o --rtlib=compiler-rt --unwindlib=libgcc '-###' &> a/c.rt.libgcc.txt
$CC a.o --rtlib=compiler-rt --unwindlib=libunwind '-###' &> a/c.rt.libunwind.txt
$CXX a.o '-###' &> a/cc.raw.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=none '-###' &> a/cc.rt.none.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=libgcc '-###' &> a/cc.rt.libgcc.txt
$CCX a.o --rtlib=compiler-rt --unwindlib=libunwind '-###' &> a/cc.rt.libunwind.txt

That's strange; if I do clang++ a.o -### -rtlib=compiler-rt -unwindlib=libunwind I get --as-needed around the -l:libunwind.so with this patch, which wasn't there before.

Perhaps my tests were faulty... I do not check it again.

I'd hope we reduce the usage of UnspecifiedLibGcc as it has the tricky --as-needed implication. I think the idea is that for C (no exceptions, so no _Unwind_Resume at the end of non-catch handlers), libgcc_s.so.1 is usually unneeded, so --as-needed can likely result in one fewer DT_NEEDED... This optimization probably does not have much value.

Tangentially related though, I'm running into a similar issue with linking C, when experimenting with taking -unwindlib into use - right now, my toolchain is complete to build C applications once I've built compiler-rt builtins. But if I'm adding -unwindlib=libunwind, linking of all C programs fail until I've built libunwind - and the fact that linking of C programs fails messes up the cmake setup for building libunwind. So that essentially forces adding an extra -unwindlib=none throughout the bootstrap process until libunwind has been built, which is a bit inelegant. (The alternative, creating a dummy empty libunwind.a until the real deal is built isn't very elegant either.)

So due to that, I'm pondering whether it'd make sense to propose a patch to only add the -lunwind into the link if actually linking with the g++ driver. I'm sure there's some C programs somewhere that wants to call the unwinder though (maybe for calling _Unwind_Backtrace?), which that'd break. (That would be broken in my current toolchains anyway, though.)

Omitting the unwind library can be problematic if the C program does use such symbols. It is also difficult to fix because -lstdc++ is placed before the unwind library.
So user -lunwind will have a wrong linking position.

So if you want to add a condition, please test mingw triple instead of testing RLT == ToolChain::RLT_Libgcc

Ok, I guess that'd be more straightforward...

This revision was landed with ongoing or failed builds.Mar 5 2021, 11:10 PM
This revision was automatically updated to reflect the committed changes.
phosek added a comment.Mar 6 2021, 1:29 PM

We see two test failures that appear to have been introduced by this change:

******************** TEST 'Clang :: Driver/compiler-rt-unwind.c' FAILED ********************

/b/s/w/ir/x/w/llvm-project/clang/test/Driver/compiler-rt-unwind.c:9:15: error: RTLIB-GCC: expected string not found in input
// RTLIB-GCC: "{{.*}}lgcc_s"
              ^
<stdin>:6:817: note: scanning from here
 "/b/s/w/ir/x/w/staging/llvm_build/bin/ld.lld" "--hash-style=both" "--build-id" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/compiler-rt-unwind.c.tmp.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crt1.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crti.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/crtbegin.o" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../.." "-L/b/s/w/ir/x/w/staging/llvm_build/bin/../lib" "-L/lib" "-L/usr/lib" "/b/s/w/ir/x/t/compiler-rt-unwind-1fb79b.o" "-lgcc" "-lc" "-lgcc" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/crtend.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crtn.o"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ^
<stdin>:6:822: note: possible intended match here
 "/b/s/w/ir/x/w/staging/llvm_build/bin/ld.lld" "--hash-style=both" "--build-id" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/compiler-rt-unwind.c.tmp.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crt1.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crti.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/crtbegin.o" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../.." "-L/b/s/w/ir/x/w/staging/llvm_build/bin/../lib" "-L/lib" "-L/usr/lib" "/b/s/w/ir/x/t/compiler-rt-unwind-1fb79b.o" "-lgcc" "-lc" "-lgcc" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/crtend.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crtn.o"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ^

Input file: <stdin>
Check file: /b/s/w/ir/x/w/llvm-project/clang/test/Driver/compiler-rt-unwind.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: Fuchsia clang version 13.0.0 (https://llvm.googlesource.com/a/llvm-project 714644a36c3095e1dffeb2fb42da3876a5919d21) 
           2: Target: x86_64-unknown-linux 
           3: Thread model: posix 
           4: InstalledDir: /b/s/w/ir/x/w/staging/llvm_build/bin 
           5:  "/b/s/w/ir/x/w/staging/llvm_build/bin/clang" "-cc1" "-triple" "x86_64-unknown-linux" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "compiler-rt-unwind.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver" "-resource-dir" "/b/s/w/ir/x/w/staging/llvm_build/lib/clang/13.0.0" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/b/s/w/ir/x/w/staging/llvm_build/lib/clang/13.0.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-faddrsig" "-o" "/b/s/w/ir/x/t/compiler-rt-unwind-1fb79b.o" "-x" "c" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/compiler-rt-unwind.c" 
           6:  "/b/s/w/ir/x/w/staging/llvm_build/bin/ld.lld" "--hash-style=both" "--build-id" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/compiler-rt-unwind.c.tmp.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crt1.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crti.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/crtbegin.o" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu" "-L/lib/x86_64-linux-gnu" "-L/lib/../lib64" "-L/usr/lib/x86_64-linux-gnu" "-L/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../.." "-L/b/s/w/ir/x/w/staging/llvm_build/bin/../lib" "-L/lib" "-L/usr/lib" "/b/s/w/ir/x/t/compiler-rt-unwind-1fb79b.o" "-lgcc" "-lc" "-lgcc" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/crtend.o" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../x86_64-linux-gnu/crtn.o" 
check:9'0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:9'1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ?                                                                                                                  possible intended match
>>>>>>

******************** TEST 'Clang :: Driver/linux-ld.c' FAILED ********************

/b/s/w/ir/x/w/llvm-project/clang/test/Driver/linux-ld.c:34:17: error: CHECK-LD-64: expected string not found in input
// CHECK-LD-64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
                ^
<stdin>:6:1011: note: scanning from here
 "/b/s/w/ir/x/w/staging/llvm_build/bin/ld.lld" "--sysroot=/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree" "--hash-style=both" "--build-id" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/linux-ld.c.tmp.o" "crt1.o" "crti.o" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/lib" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib" "/b/s/w/ir/x/t/linux-ld-731974.o" "-lgcc" "-lc" "-lgcc" "crtend.o" "crtn.o"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ^
<stdin>:6:1046: note: possible intended match here
 "/b/s/w/ir/x/w/staging/llvm_build/bin/ld.lld" "--sysroot=/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree" "--hash-style=both" "--build-id" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/linux-ld.c.tmp.o" "crt1.o" "crti.o" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/lib" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib" "/b/s/w/ir/x/t/linux-ld-731974.o" "-lgcc" "-lc" "-lgcc" "crtend.o" "crtn.o"
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ^

Input file: <stdin>
Check file: /b/s/w/ir/x/w/llvm-project/clang/test/Driver/linux-ld.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: Fuchsia clang version 13.0.0 (https://llvm.googlesource.com/a/llvm-project 714644a36c3095e1dffeb2fb42da3876a5919d21) 
            2: Target: x86_64-unknown-linux 
            3: Thread model: posix 
            4: InstalledDir: /b/s/w/ir/x/w/staging/llvm_build/bin 
            5:  "/b/s/w/ir/x/w/staging/llvm_build/bin/clang" "-cc1" "-triple" "x86_64-unknown-linux" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "linux-ld.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver" "-resource-dir" "/b/s/w/ir/x/w/staging/llvm_build/lib/clang/13.0.0" "-isysroot" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree" "-internal-isystem" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/local/include" "-internal-isystem" "/b/s/w/ir/x/w/staging/llvm_build/lib/clang/13.0.0/include" "-internal-externc-isystem" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/include" "-internal-externc-isystem" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/include" "-fdebug-compilation-dir=/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-faddrsig" "-o" "/b/s/w/ir/x/t/linux-ld-731974.o" "-x" "c" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/linux-ld.c" 
            6:  "/b/s/w/ir/x/w/staging/llvm_build/bin/ld.lld" "--sysroot=/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree" "--hash-style=both" "--build-id" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "/b/s/w/ir/x/w/staging/llvm_build/tools/clang/test/Driver/Output/linux-ld.c.tmp.o" "crt1.o" "crti.o" "/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/lib" "-L/b/s/w/ir/x/w/llvm-project/clang/test/Driver/Inputs/basic_linux_tree/usr/lib" "/b/s/w/ir/x/t/linux-ld-731974.o" "-lgcc" "-lc" "-lgcc" "crtend.o" "crtn.o" 
check:34'0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:34'1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ?                                          possible intended match
>>>>>>

We see two test failures that appear to have been introduced by this change:

Hmm - I'm pretty surprised about that, because the change literally added an && !TC.getTriple().isOSCygMing(), which should evaluate to && true when targeting anything else than mingw/cygwin - and the errors you quoted clearly show a linux triple.

I presume you're not actually running the build in a mingw environment, in case that would happen to surprisingly interfere somehow?

Feel free to revert - but I'd appreciate if you could try to figure out why it breaks things, as to me, it should be a clear no-op for linux targets.

phosek added a comment.Mar 6 2021, 2:17 PM

We see two test failures that appear to have been introduced by this change:

Hmm - I'm pretty surprised about that, because the change literally added an && !TC.getTriple().isOSCygMing(), which should evaluate to && true when targeting anything else than mingw/cygwin - and the errors you quoted clearly show a linux triple.

I presume you're not actually running the build in a mingw environment, in case that would happen to surprisingly interfere somehow?

Feel free to revert - but I'd appreciate if you could try to figure out why it breaks things, as to me, it should be a clear no-op for linux targets.

The only thing that might be somewhat unusual is that we use CLANG_DEFAULT_RTLIB=compiler-rt, see https://github.com/llvm/llvm-project/blob/fb2cf0dd609238931b0fc53ef0ea2172a99307ae/clang/cmake/caches/Fuchsia-stage2.cmake#L34

phosek added a comment.Mar 6 2021, 2:20 PM

We see two test failures that appear to have been introduced by this change:

Hmm - I'm pretty surprised about that, because the change literally added an && !TC.getTriple().isOSCygMing(), which should evaluate to && true when targeting anything else than mingw/cygwin - and the errors you quoted clearly show a linux triple.

I presume you're not actually running the build in a mingw environment, in case that would happen to surprisingly interfere somehow?

Feel free to revert - but I'd appreciate if you could try to figure out why it breaks things, as to me, it should be a clear no-op for linux targets.

The only thing that might be somewhat unusual is that we use CLANG_DEFAULT_RTLIB=compiler-rt, see https://github.com/llvm/llvm-project/blob/fb2cf0dd609238931b0fc53ef0ea2172a99307ae/clang/cmake/caches/Fuchsia-stage2.cmake#L34

Actually, I don't think it's this commit that broke those tests. It's probably D98022, both of these changes landed around the same time and our bots pick them up in the same batch and I implicitly assumed that this one is more likely since the other one is just fixing a typo, but looking at the failure, it's likely the other one that caused the issue, sorry about the confusion.