llvm-project
538fcbc7 - [clang][CMake] Fix ODR violation with LLVM_LINK_LLVM_DYLIB (#186689)

Commit
2 days ago
[clang][CMake] Fix ODR violation with LLVM_LINK_LLVM_DYLIB (#186689) After 42b638c6b40d ("Propagate dependencies to OBJECT libraries in add_llvm_library"), obj.clangSupport now inherits clangSupport's LINK_LIBRARIES via target_link_libraries, which includes libLLVM.so when LLVM_LINK_LLVM_DYLIB is enabled. Previously the obj.clangSupport alias path was harmless because the OBJECT library carried no link dependencies. Now, aliasing clangSupport_tablegen to obj.clangSupport in DYLIB mode causes clang-tblgen to transitively link libLLVM.so, while also having LLVM symbols compiled in statically — triggering an ASan ODR violation on globals like llvm::vfs::FileSystem::ID. Fix by only propagating parts of the compile interface instead of the full link interface - INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_SYSTEM_INCLUDE_DIRECTORIES. Also add a TODO to consider replacing with target_link_libraries($<COMPILE_ONLY:tgt>) once minimum CMake version is 3.27 or higher.
Parents
Loading