summaryrefslogtreecommitdiff
path: root/env/nixpkgs-patches
diff options
context:
space:
mode:
Diffstat (limited to 'env/nixpkgs-patches')
-rw-r--r--env/nixpkgs-patches/539430.diff81
1 files changed, 81 insertions, 0 deletions
diff --git a/env/nixpkgs-patches/539430.diff b/env/nixpkgs-patches/539430.diff
new file mode 100644
index 0000000..9c4ec07
--- /dev/null
+++ b/env/nixpkgs-patches/539430.diff
@@ -0,0 +1,81 @@
+diff --git a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix
+index 567462e3eba68..da799c93d08e0 100644
+--- a/pkgs/development/compilers/llvm/common/compiler-rt/default.nix
++++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix
+@@ -36,7 +36,8 @@
+ # 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,
++ withAtomicsPthread ?
++ lib.versionAtLeast release_version "19" && stdenv.cc.libc != null && !stdenv.hostPlatform.isMinGW,
+
+ # In recent releases, the compiler-rt build seems to produce
+ # many `libclang_rt*` libraries, but not a single unified
+@@ -214,7 +215,7 @@ stdenv.mkDerivation (finalAttrs: {
+ # 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_EXCLUDE_ATOMIC_BUILTIN" withAtomicsLib)
+ (lib.cmakeBool "COMPILER_RT_BUILD_STANDALONE_LIBATOMIC" withAtomicsLib)
+ (lib.cmakeBool "COMPILER_RT_LIBATOMIC_USE_PTHREAD" withAtomicsPthread)
+ ]
+@@ -291,11 +292,21 @@ 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/
+- '';
++ + lib.optionalString (withAtomics && withAtomicsLib) (
++ let
++ isMinGW = stdenv.hostPlatform.isMinGW;
++ sharedLibrary = stdenv.hostPlatform.extensions.sharedLibrary;
++ linkLibrarySuffix = lib.optionalString isMinGW ".a";
++ runtimeDirectory = if isMinGW then "$out/bin" else "$out/lib";
++ atomicLibrary = "libclang_rt.atomic" + lib.optionalString isMinGW "_dynamic" + "-*${sharedLibrary}";
++ in
++ ''
++ mkdir -p ${runtimeDirectory}
++ ln -s $out/lib/*/${atomicLibrary}${linkLibrarySuffix} $out/lib/libatomic${sharedLibrary}${linkLibrarySuffix}
++ # Link the original runtime name where the loader searches for shared libraries.
++ ln -s $out/lib/*/${atomicLibrary} ${runtimeDirectory}/
++ ''
++ );
+
+ meta = llvm_meta // {
+ homepage = "https://compiler-rt.llvm.org/";
+diff --git a/pkgs/development/compilers/llvm/common/default.nix b/pkgs/development/compilers/llvm/common/default.nix
+index af2e39dced099..9afc972ce7c31 100644
+--- a/pkgs/development/compilers/llvm/common/default.nix
++++ b/pkgs/development/compilers/llvm/common/default.nix
+@@ -308,9 +308,11 @@ makeScopeWithSplicing' {
+ && stdenv.targetPlatform.useLLVM or false
+ ) "-lunwind"
+ ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
+- nixSupport.cc-ldflags = lib.optionals (
+- !stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD
+- ) [ "-L${targetLlvmPackages.libunwind}/lib" ];
++ nixSupport.cc-ldflags =
++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
++ "-L${targetLlvmPackages.libunwind}/lib"
++ ]
++ ++ lib.optional stdenv.targetPlatform.isMinGW "-L${targetLlvmPackages.compiler-rt}/lib";
+ };
+
+ clangWithLibcAndBasicRtAndLibcxx = wrapCCWith rec {
+@@ -424,6 +426,11 @@ makeScopeWithSplicing' {
+
+ compiler-rt-no-libc = callPackage ./compiler-rt {
+ doFakeLibgcc = stdenv.hostPlatform.useLLVM or false;
++ # This runtime is used to bootstrap the libc-capable toolchain. Keep
++ # atomics in builtins.a until that toolchain can link the shared atomic
++ # runtime against libc (and pthreads, when enabled).
++ withAtomicsLib = false;
++ withAtomicsPthread = false;
+ stdenv =
+ # Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling.
+ if stdenv.hostPlatform.isDarwin then