<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63860>63860</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
CMake emits invalid linker arguments for LLD.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Gadal
</td>
</tr>
</table>
<pre>
This CMake block will generate `-Wl,--push-state,--as-needed,-latomic,--pop-state` if the linker is LD, Gold, LLD, or Mold:
https://github.com/llvm/llvm-project/blob/2ac99205ee1a232b8da5ec144662b29bb00ccd70/llvm/cmake/modules/CheckAtomic.cmake#L89-L90
This review appears to implement support for --push-state and --pop-state in LLD:
https://reviews.llvm.org/D47542
Nevertheless, it appears to not work (Windows, x64):
```
> clang++ -fuse-ld=lld test.cpp -Wl,--push-state,--as-needed,-lkernel32,--pop-state
lld: error: unknown argument: --push-state
lld: error: unknown argument: --pop-state
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```
I'm using LLD version 16.0.4:
```
> ld.lld.exe --version
LLD 16.0.4 (compatible with GNU linkers)
```
I've attached a repro case (it's a .7z file; .zip couldn't get under Github's 25MB size cap):
[repro_case.zip](https://github.com/llvm/llvm-project/files/12047862/repro_case.zip)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE-P46gT_TT4UrKF8b_44MOk80vrJ6XntKs5rjBUbDYYLMBJb3_6FU6ynYy0o20pIi6gql69egX3Xg0GsSPVllS7hC9htK575ZLrpLfyr-63UXl4eeMnhF5bcYKL0hoGNOh4QCA1TX9owl7SdF78mPrAA64m96lBlCijpXmwkxLXe3a-XaspqCOEEUErc0IHysNhR9gLvFod_eBwNa2Dt7hTfCN0R-htHUOYfdxje8L2gwrj0mfCToTttT7f_9LZ2T9RBML2vbY9YXvGRdsyWiHmnBWs30heocjLsq5Zz9q-p1QI2dDPOGLiJyRsP1m5aPSE7V9GFKdva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