[PATCH] D136280: [llvm] [CMake] Set LLVM_ATOMIC_LIB variable for convenient linking against libatomic
Arfrever Frehtes Taifersar Arahesis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 20 01:06:48 PDT 2022
Arfrever added a comment.
In D136280#3870090 <https://reviews.llvm.org/D136280#3870090>, @MaskRay wrote:
> Is -latomic only needed on some 32-bit architectures? Does this change link against -latomic for major 64-bit architectures?
Earlier unchanged code in `CheckAtomic.cmake` tries to detect if `libatomic` exists and if linking against `libatomic` is possibly needed (see variables `HAVE_LIBATOMIC`, `HAVE_CXX_LIBATOMICS64`).
In such case, `HAVE_CXX_ATOMICS_WITH_LIB` and/or `HAVE_CXX_ATOMICS64_WITH_LIB` would be set.
`LLVM_ATOMIC_LIB` is set to non-empty value when `HAVE_CXX_ATOMICS_WITH_LIB` or `HAVE_CXX_ATOMICS64_WITH_LIB` are set.
When there was no linking against `-latomic`, there should still be none.
When there was linking against `-latomic`, there will be now (with all modern linkers) `-Wl,--push-state,--as-needed,-latomic,--pop-state` or (with archaic linkers) `-latomic`.
Due to `--as-needed`, on some architectures, some particular libraries or executables will no longer be unnecessarily linked against `libatomic`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136280/new/
https://reviews.llvm.org/D136280
More information about the llvm-commits
mailing list