[PATCH] D132799: Make sure libLLVM users link with libatomic if needed

Aaron Puchert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 27 14:39:25 PDT 2022


aaronpuchert created this revision.
aaronpuchert added a reviewer: beanz.
Herald added subscribers: steven.zhang, mgorny.
Herald added a project: All.
aaronpuchert requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

64-bit atomics are used in llvm/ADT/Statistic.h, which means that users
of libLLVM.so might also have to link with libatomic. Ideally we would
properly distinguish between public and private dependencies on the
component level, but that's of course difficult. Collecting all
dependencies from e.g. Support might also be too much.

This fixes a build failure on PowerPC 32-bit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132799

Files:
  llvm/tools/llvm-shlib/CMakeLists.txt


Index: llvm/tools/llvm-shlib/CMakeLists.txt
===================================================================
--- llvm/tools/llvm-shlib/CMakeLists.txt
+++ llvm/tools/llvm-shlib/CMakeLists.txt
@@ -63,6 +63,10 @@
 
   target_link_libraries(LLVM PRIVATE ${LIB_NAMES})
 
+  if(LLVM_ENABLE_THREADS AND NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+    target_link_libraries(LLVM PUBLIC atomic)
+  endif()
+
   if (APPLE)
     set_property(TARGET LLVM APPEND_STRING PROPERTY
                 LINK_FLAGS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132799.456153.patch
Type: text/x-patch
Size: 490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220827/cd0bc924/attachment.bin>


More information about the llvm-commits mailing list