This is an archive of the discontinued LLVM Phabricator instance.

[clang] [CMake] Link libclangBasic against libatomic when necessary.
ClosedPublic

Authored by thesamesam on Oct 19 2022, 12:12 PM.

Details

Summary

This is necessary at least on PPC32.

Depends on D136280.

Bug: https://bugs.gentoo.org/874024
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tested-by: erhard_f@mailbox.org <erhard_f@mailbox.org>

Diff Detail

Event Timeline

thesamesam created this revision.Oct 19 2022, 12:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 19 2022, 12:12 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
thesamesam requested review of this revision.Oct 19 2022, 12:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 19 2022, 12:12 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
mgorny added inline comments.Oct 19 2022, 8:10 PM
clang/lib/Basic/CMakeLists.txt
114–117

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.

Arfrever added inline comments.
clang/lib/Basic/CMakeLists.txt
114–117

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.

mgorny accepted this revision.Oct 20 2022, 6:11 AM

I suppose it comes indirectly then. I'd prefer that you tested it with git main, though.

This revision is now accepted and ready to land.Oct 20 2022, 6:11 AM
This revision was automatically updated to reflect the committed changes.
aaronpuchert added inline comments.
clang/lib/Basic/CMakeLists.txt
114–117

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.