[llvm] [CMake] Enable CMP0179 alongside CMP0156 for deduplication on LLD (PR #116497)

Evan Wilde via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 09:21:11 PST 2024


etcwilde wrote:

> I understand that LLD has ignored the requirements for ELF semantics. Please test with BFD. I expect that we need to disable this policy for BFD and gold to successfully link. We can add an additional case for that if you want.
> 
> ```cmake
> if(APPLE OR WIN32 OR LLVM_ENABLE_LLD)
>   ...
> endif()
> ```
> 
> However, if BFD and gold are able to link properly ignoring the symbol resolution semantics (and the output is the same), then this seems reasonable.

CMake added linker detection in 3.29 specifically so that it could handle these cases.
The addition of [CMAKE_LINKER_TYPE](https://cmake.org/cmake/help/v3.29/variable/CMAKE_LINKER_TYPE.html) was part of this. The expectation from CMP0156 is that it only de-dupes the libraries on the link line for linkers that don't require it.
Something regressed in 3.31 for LLD. [CMP0156](https://cmake.org/cmake/help/latest/policy/CMP0156.html) and [CMP0179](https://cmake.org/cmake/help/latest/policy/CMP0179.html) should not affect BFD or gold, as they do require repetition of the libraries.

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


More information about the llvm-commits mailing list