[PATCH] D47606: [compiler-rt] [builtins] Don't build __atomic_load etc. by default.

Louis Dionne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 10:48:49 PDT 2021


ldionne added a comment.

In D47606#2880596 <https://reviews.llvm.org/D47606#2880596>, @efriedma wrote:

> On Linux, the operating system ships with libatomic.  I think it should be getting linked in by default?  If it isn't, that a problem with the link command.

No, it's not linked by default, you need to add `-latomic` (but that's another issue, as you say). So does that mean the intent on Linux is for Clang to use the OS-shipped `/usr/lib/<triple>/libatomic.so` instead of its own `libclang_rt`?

> Not sure what the situation is like on other operating systems.

On Darwin, we don't ship `libatomic.so` anywhere. It seems like we also don't ship the atomic builtins as part of `<xcode-toolchain>/usr/lib/clang/<version>/lib/darwin/libclang_rt.osx.a`, which is where I would normally expect those (I think?).

So IIUC, there would be two bugs here:

1. Clang doesn't automatically add `-latomic` when linking on Linux. Note that GCC behaves the same, so it is possible that I'll find out there's a good reason for it.
2. We should ship the atomic builtins in some form on Darwin, and make sure those are picked up by the driver.

Do you agree?


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D47606



More information about the llvm-commits mailing list