[clang] [Clang][Driver] Preserve user --as-needed state around libgcc_s (PR #233236)

Wesley Lewis via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 18 07:32:14 PDT 2026


wesley-lewis wrote:

## Tests:

I added a test which checks for the the presence of `--push-state` and `--pop-state`

```
// CHECK-USER-AS-NEEDED-SAME: "--as-needed" "-lgcc" "--push-state" "--as-needed" "-lgcc_s" "--pop-state" "-lc"
// CHECK-USER-AS-NEEDED-NOT: "--no-as-needed
```

Solaris LD doesn't have a push pop support. So I added a check for that as well in the driver. After these changes:

There were 7 tests which were failing as they were expecting the old pattern.
<img width="940" height="222" alt="image" src="https://github.com/user-attachments/assets/379bcadd-e3cb-4b00-ac6d-9c5f6d7610f3" />

I fixed them by replacing `--as-needed -lgcc|lgcc_s --not-as-needed` with `--push-state --as-needed ... --pop-state`

https://github.com/llvm/llvm-project/pull/233236


More information about the cfe-commits mailing list