[PATCH] D136282: [clang] [CMake] Link libclangBasic against libatomic when necessary.

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 16 16:41:57 PST 2022


aaronpuchert added inline comments.


================
Comment at: clang/lib/Basic/CMakeLists.txt:114-117
+target_link_libraries(clangBasic
+  PRIVATE
+  ${LLVM_ATOMIC_LIB}
+)
----------------
Arfrever wrote:
> mgorny wrote:
> > Is this the right place? Grepping for `std::atomic`, I see lib/Frontend and a bunch of tools, plus a few places in clang-tools-extra.
> `clang-15.0.2:20221005-132622.log` (from https://bugs.gentoo.org/874024) says that this is the place where linking is needed:
> ```
> /usr/bin/powerpc-unknown-linux-gnu-ld: lib/libclangBasic.a(FileManager.cpp.o): undefined reference to symbol '__atomic_load_8@@LIBATOMIC_1.0'
> /usr/bin/powerpc-unknown-linux-gnu-ld: /usr/lib/gcc/powerpc-unknown-linux-gnu/11.3.1/libatomic.so.1: error adding symbols: DSO missing from command line
> ```
> 
> There were no reportedly no other errors with missing linking.
FileManager.cpp has some uses of `ALWAYS_ENABLED_STATISTIC`, which translates into a variable declaration using a `TrackingStatistic` from llvm/ADT/Statistic.h, which in turn has some usage of atomic operations inline. I stumbled across the same issue in D132799.

As we discussed there, this isn't quite right. This isn't a (private) dependency of `clangBasic`, but a public dependency of `LLVMSupport`. But currently we don't cleanly separate the two concepts and just declare everything as private dependency.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136282/new/

https://reviews.llvm.org/D136282



More information about the cfe-commits mailing list