Make sure libLLVM users link with libatomic if needed
authorAaron Puchert <aaronpuchert@alice-dsl.net>
Sun, 11 Sep 2022 18:44:51 +0000 (20:44 +0200)
committerAaron Puchert <aaronpuchert@alice-dsl.net>
Sun, 11 Sep 2022 18:44:53 +0000 (20:44 +0200)
64-bit atomics are used in llvm/ADT/Statistic.h, which means that users
of libLLVM.so might also have to link with libatomic. To avoid having
to special-case the library here, we simply add all `LLVM_SYSTEM_LIBS`
as public link dependencies to libLLVM.

This fixes a build failure on PowerPC 32-bit.

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D132799

llvm/tools/llvm-shlib/CMakeLists.txt

index 8e2b78f..cc6713a 100644 (file)
@@ -63,6 +63,9 @@ if(LLVM_BUILD_LLVM_DYLIB)
 
   target_link_libraries(LLVM PRIVATE ${LIB_NAMES})
 
+  get_property(SYSTEM_LIBS TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
+  target_link_libraries(LLVM PUBLIC ${SYSTEM_LIBS})
+
   if (APPLE)
     set_property(TARGET LLVM APPEND_STRING PROPERTY
                 LINK_FLAGS