mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-03-08 01:24:09 +01:00
compiler-rt: enable build of libatomic (#488265)
This commit is contained in:
commit
b25485cb71
1 changed files with 27 additions and 0 deletions
|
|
@ -21,6 +21,23 @@
|
|||
# are, so long as it provides some builtins.
|
||||
doFakeLibgcc ? stdenv.hostPlatform.isFreeBSD,
|
||||
|
||||
# Whether to build the set of __atomic_* routines that would typically
|
||||
# be provided by libatomic in gcc environments.
|
||||
withAtomics ?
|
||||
stdenv.hostPlatform.useLLVM
|
||||
&& ((stdenv.cc.libc != null) || !stdenv.hostPlatform.hasSharedLibraries),
|
||||
# If withAtomics is enabled, setting this to true ships those routines
|
||||
# in a separate DSO (aliased as libatomic to match gcc's) rather than
|
||||
# making them part of builtins.a. Unless no dynamic linking is used at
|
||||
# all, this is the correct setup as it ensures the locks are unique in
|
||||
# memory.
|
||||
withAtomicsLib ? stdenv.hostPlatform.hasSharedLibraries,
|
||||
# If withAtomics is enabled, this selects the pthreads-based
|
||||
# implementation of the routines instead of the implementation
|
||||
# using ad-hoc mutexes (which doesn't depend on libc at all).
|
||||
# Use of pthreads helps code play better with sanitizers.
|
||||
withAtomicsPthread ? lib.versionAtLeast release_version "19" && stdenv.cc.libc != null,
|
||||
|
||||
# In recent releases, the compiler-rt build seems to produce
|
||||
# many `libclang_rt*` libraries, but not a single unified
|
||||
# `libcompiler_rt` library, at least under certain configurations. Some
|
||||
|
|
@ -190,6 +207,11 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
lib.optional (stdenv.hostPlatform.isAarch64 && !haveLibc)
|
||||
# Fixes https://github.com/NixOS/nixpkgs/issues/393603
|
||||
(lib.cmakeBool "COMPILER_RT_DISABLE_AARCH64_FMV" true)
|
||||
++ lib.optionals withAtomics [
|
||||
(lib.cmakeBool "COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN" (!withAtomicsLib))
|
||||
(lib.cmakeBool "COMPILER_RT_BUILD_STANDALONE_LIBATOMIC" withAtomicsLib)
|
||||
(lib.cmakeBool "COMPILER_RT_LIBATOMIC_USE_PTHREAD" withAtomicsPthread)
|
||||
]
|
||||
++ devExtraCmakeFlags;
|
||||
|
||||
outputs = [
|
||||
|
|
@ -262,6 +284,11 @@ stdenv.mkDerivation (finalAttrs: {
|
|||
''
|
||||
+ lib.optionalString forceLinkCompilerRt ''
|
||||
ln -s $out/lib/*/libclang_rt.builtins-*.a $out/lib/libcompiler_rt.a
|
||||
''
|
||||
+ lib.optionalString (withAtomics && withAtomicsLib) ''
|
||||
ln -s $out/lib/*/libclang_rt.atomic-*.so $out/lib/libatomic.so
|
||||
# create a link with the original soname as well, so it's found at runtime
|
||||
ln -s $out/lib/*/libclang_rt.atomic-*.so $out/lib/
|
||||
'';
|
||||
|
||||
meta = llvm_meta // {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue