Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Allow to use atomic builtins from compiler-rt instead of libat…
…omic compiler-rt, when it's built with the `COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN` option disabled, provides all atomic builtins and serves as a full replacement for libatomic. By default, that option is enabled[0], meaning that default builds of compiler-rt, followed by the most of Linux distributions (Fedora, openSUSE, Ubuntu), do **not** provide all necessary atomics. However, FreeBSD[1] and Gentoo (with LLVM-based profiles)[2] disable it, therefore providing compiler-rt with atomic builtins. That difference can be detected by checking the symbol table of compiler-rt: ``` nm $(clang -print-libgcc-file-name) | grep __atomic ``` No matching symbols indicate lack of atomic builtins and necessity of linking libatomic. Matching symbols indicate a possibility to not link libatomic. Given that difference, provide the `--use-compiler-rt-atomics` option in `configure.py`. When enabled, the configure script checks whether compiler-rt provides atomics and, if yes, does not link libatomic. By default, without that option enabled, a build with clang links libatomic. For more context, see the discussion on Gentoo bugzilla[3]. [0] https://github.com/llvm/llvm-project/blob/llvmorg-19.1.6/compiler-rt/lib/builtins/CMakeLists.txt#L227-L229 [1] https://cgit.freebsd.org/src/commit/?id=7b67d47c70cca47f65fbbc9d8607b7516c2a82ee [2] gentoo/gentoo@63b4ae7 [3] https://bugs.gentoo.org/911340
- Loading branch information