[llvm] [CMake] Enable CMP0179 when enabling CMP0156 to avoid LLD static library link order bug (PR #116497)

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 16 09:36:42 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()
----------------
compnerd wrote:

I think that this isn't the ideal way to handle this. I think that we should simply limit CMP0156 to `if(APPLE OR WIN32)`. ELFish platforms have the expectation that the command line order and duplication is material and the de-duplication will change the behaviour of the symbolic resolution.

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


More information about the llvm-commits mailing list