You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CMake] Enable CMP0179 when enabling CMP0156 to avoid LLD static library link order bug
This fixes the following linking failure for libclang-cpp.so with -DLLVM_LINK_LLVM_DYLIB=ON:
```
ld.lld: error: undefined symbol: llvm::omp::getOpenMPClauseName(llvm::omp::Clause)
>>> referenced by OpenMPKinds.cpp
>>> tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o:(clang::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int))
>>> referenced by SemaOpenMP.cpp
>>> tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaOpenMP.cpp.o:(clang::SemaOpenMP::CheckOMPRequiresDecl(clang::SourceLocation, llvm::ArrayRef<clang::OMPClause*>))
>>> referenced by SemaOpenMP.cpp
>>> tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaOpenMP.cpp.o:(clang::SemaOpenMP::CheckOMPRequiresDecl(clang::SourceLocation, llvm::ArrayRef<clang::OMPClause*>))
>>> referenced 166 more times
[tons more]
```
This is exhibited under the following conditions:
* LLVM LLD
* CMake 3.31.0
* CMP0156=NEW
* CMP0179=OLD
CMake 3.31's new linker architecture changes the library link order.
Per LLD's design documents it should be immune to such reodering like other popular linkers (gold, Apple's), but isn't.
A workaround for LLD is expected in CMake 3.31.1 but CMP0179=NEW changes the linking order such that the bug is avoided.
Deduplication is better in general so always enable it when possible.
See: https://gitlab.kitware.com/cmake/cmake/-/issues/26447
Fixes: cb90d5b
0 commit comments