[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
Tue Jul 28 00:04:18 PDT 2026
https://github.com/leovancekang created https://github.com/llvm/llvm-project/pull/212419
`-rtlib=compiler-rt` selects compiler-rt builtins, while the unwind library is selected independently. When Clang is configured with `CLANG_DEFAULT_UNWINDLIB=libgcc`, the driver therefore emits `-lgcc_s` alongside `libclang_rt.builtins.a`.
The existing `COMPILER-RT-NOT` check for `-lgcc_s` in `flang/test/Driver/linker-flags.f90` causes the test to fail in this configuration. This change removes that negative check while retaining the `-lgcc` check to ensure that the driver does not select libgcc builtins. This is a test-only change; driver behavior is unchanged.
### Testing
Built with `-DCLANG_DEFAULT_RTLIB=compiler-rt` and `-DCLANG_DEFAULT_UNWINDLIB=libgcc`.
- `build-release/bin/llvm-lit -sv --filter='Driver/linker-flags\.f90$' build-release/tools/flang/test`: passed
- `cmake --build build-release --target check-flang --parallel 12`: passed with no unexpected failures (4636 passed, 173 unsupported, and 11 expected failures)
>From 1a5cd96f01dd051d97be1f2144fce1465bf17f66 Mon Sep 17 00:00:00 2001
From: leovancekang <leovancekang at outlook.com>
Date: Tue, 28 Jul 2026 14:15:39 +0800
Subject: [PATCH] [flang][Driver] Fix compiler-rt linker test with a libgcc
unwinder
`-rtlib=compiler-rt` selects compiler-rt builtins but does not override
`CLANG_DEFAULT_UNWINDLIB`. When that default is `libgcc`, the driver
legitimately emits `-lgcc_s` as the unwind library alongside
`libclang_rt.builtins.a`.
Stop rejecting `-lgcc_s` while retaining the check that `-lgcc` is not
selected in place of compiler-rt builtins.
---
flang/test/Driver/linker-flags.f90 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index 2b56fdfb8da05..ab7182c3064a2 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -85,5 +85,6 @@
! MSVC-SAME: /subsystem:console
! MSVC-SAME: "[[object_file]]"
+! The compiler runtime and unwind library are selected independently. A
+! configured libgcc unwinder may therefore add "-lgcc_s" with compiler-rt.
! COMPILER-RT-NOT: "-lgcc"
-! COMPILER-RT-NOT: "-lgcc_s"
More information about the flang-commits
mailing list