diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 76f218de4d24..202a5cc577bf 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -17,6 +17,7 @@ , isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null , buildPackages ? {} , libcxx ? null +, isCompilerRT ? false }: with lib; @@ -145,7 +146,7 @@ stdenv.mkDerivation { # Binutils, and Apple's "cctools"; "bintools" as an attempt to find an # unused middle-ground name that evokes both. inherit bintools; - inherit libc nativeTools nativeLibc nativePrefix isGNU isClang; + inherit libc nativeTools nativeLibc nativePrefix isGNU isClang isCompilerRT; emacsBufferSetup = pkgs: '' ; We should handle propagation here too diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index 874be111ade0..b72d42442853 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -168,6 +168,7 @@ let '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoLibcxx = wrapCCWith rec { @@ -182,6 +183,7 @@ let echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags echo "-nostdlib++" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoLibc = wrapCCWith rec { @@ -195,6 +197,7 @@ let echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoCompilerRt = wrapCCWith rec { diff --git a/pkgs/development/compilers/llvm/13/libunwind/default.nix b/pkgs/development/compilers/llvm/13/libunwind/default.nix index b6017e741728..c6cc148239e1 100644 --- a/pkgs/development/compilers/llvm/13/libunwind/default.nix +++ b/pkgs/development/compilers/llvm/13/libunwind/default.nix @@ -17,7 +17,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; - cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; + cmakeFlags = + lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF" + ++ lib.optional (stdenv.cc.isCompilerRT) "-DLIBUNWIND_USE_COMPILER_RT=TRUE"; meta = llvm_meta // { # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix index 4e5e85684a2a..4de667d894e7 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -168,6 +168,7 @@ let '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoLibcxx = wrapCCWith rec { @@ -182,6 +183,7 @@ let echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags echo "-nostdlib++" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoLibc = wrapCCWith rec { @@ -195,6 +197,7 @@ let echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoCompilerRt = wrapCCWith rec { diff --git a/pkgs/development/compilers/llvm/14/libunwind/default.nix b/pkgs/development/compilers/llvm/14/libunwind/default.nix index 109b92f1e027..7940fa4b3a13 100644 --- a/pkgs/development/compilers/llvm/14/libunwind/default.nix +++ b/pkgs/development/compilers/llvm/14/libunwind/default.nix @@ -31,7 +31,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; - cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; + cmakeFlags = + lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF" + ++ lib.optional (stdenv.cc.isCompilerRT) "-DLIBUNWIND_USE_COMPILER_RT=TRUE"; meta = llvm_meta // { # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 0f45acffb279..6b96190c042d 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -168,6 +168,7 @@ let '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoLibcxx = wrapCCWith rec { @@ -182,6 +183,7 @@ let echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags echo "-nostdlib++" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoLibc = wrapCCWith rec { @@ -195,6 +197,7 @@ let echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags '' + mkExtraBuildCommands cc; + isCompilerRT = true; }; clangNoCompilerRt = wrapCCWith rec { diff --git a/pkgs/development/compilers/llvm/git/libunwind/default.nix b/pkgs/development/compilers/llvm/git/libunwind/default.nix index c6d9eda5e474..30874588d8d4 100644 --- a/pkgs/development/compilers/llvm/git/libunwind/default.nix +++ b/pkgs/development/compilers/llvm/git/libunwind/default.nix @@ -31,7 +31,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; - cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; + cmakeFlags = + lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF" + ++ lib.optional stdenv.cc.isCompilerRT "-DLIBUNWIND_USE_COMPILER_RT=TRUE"; meta = llvm_meta // { # Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst