[flang-commits] [flang] [flang][Driver] Fix compiler-rt linker test with a libgcc unwinder (PR #212419)
via flang-commits
flang-commits at lists.llvm.org
Wed Aug 5 23:33:01 PDT 2026
leovancekang wrote:
> 我不太确定这一点。flang 是否应该遵循 libgcc 展开器的选择?这只是 flang 使用 clang 驱动程序带来的意外副作用吗?
Thanks, that is a fair question.
I traced this through the shared driver implementation. Flang uses clang::driver::Driver, and AddRunTimeLibs() selects the compiler runtime and unwind library independently. With RLT_CompilerRT, it adds libclang_rt.builtins.a and then calls AddUnwindLibrary(). Therefore, when CLANG_DEFAULT_UNWINDLIB=libgcc, GetUnwindLibType() selects the libgcc unwinder and the linker adds -lgcc_s.
Clang's clang/test/Driver/compiler-rt-unwind.c explicitly tests -rtlib=compiler-rt --unwindlib=libgcc and expects both libclang_rt.builtins.a and -lgcc_s. #144582 also adjusted Clang Driver tests to allow -lgcc_s when the configured defaults combined compiler-rt with the libgcc unwinder.
For that reason, my reading is that this is intended shared toolchain behavior rather than an accidental Flang side effect. The original -lgcc_s negative check conflates the unwinder with libgcc builtins; retaining COMPILER-RT-NOT: "-lgcc" still verifies that compiler-rt builtins are selected.
https://github.com/llvm/llvm-project/pull/212419
More information about the flang-commits
mailing list