[llvm] [CMake] Enable CMP0179 when enabling CMP0156 to avoid LLD static library link order bug (PR #116497)
Raul Tambre via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 17 11:04:45 PST 2024
================
@@ -37,4 +37,13 @@ endif()
# building with the Apple linker.
if(POLICY CMP0156)
cmake_policy(SET CMP0156 NEW)
+
+ # CMP0179: De-duplication of static libraries on link lines keeps first occurrence.
+ # Dependent on CMP0156=NEW. Keeps the first occurrence of static libraries
+ # during deduplication to unify the behaviour on all platforms.
+ # Also works around LLD bug exhibited since CMake 3.31.0 with an expected
+ # workaround in 3.31.1 (https://gitlab.kitware.com/cmake/cmake/-/issues/26447).
+ if(POLICY CMP0179)
+ cmake_policy(SET CMP0179 NEW)
+ endif()
----------------
tambry wrote:
I don't see a reason to limit this platform-wise. It works fine on all up until CMake 3.31.0 started taking advantage of leeway granted by CMP0156=NEW specification, if I understand correctly. However LLVM is affected by this and requires the more sensible behaviour provided by CMP0179=NEW, which coincides with the above change.
> Agreed that this is not really the correct solution to the specific problem mentioned here though.
What would be the correct solution?
CMP0179 solves the problem, it'll eventually get set anyway across the board and it changes to behaviour to what LLVM requires to be properly linked.
https://github.com/llvm/llvm-project/pull/116497
More information about the llvm-commits
mailing list