diff options
author | Shea Levy <shea@shealevy.com> | 2022-05-18 06:30:21 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2022-05-18 06:30:21 -0400 |
commit | 0f68ed163cabcc1963e0b4b643dbe5e9d65de88d (patch) | |
tree | 168b01c8991d35b65010299405cf8fa2357f8b63 /pkgs/development/compilers/llvm | |
parent | 92f4c6ed823ce10c484daa6582a908c5ae9ad61b (diff) | |
parent | ece10a711f5a2c406d8907c66c99c61f776c2ac1 (diff) | |
download | nixpkgs-0f68ed163cabcc1963e0b4b643dbe5e9d65de88d.tar nixpkgs-0f68ed163cabcc1963e0b4b643dbe5e9d65de88d.tar.gz nixpkgs-0f68ed163cabcc1963e0b4b643dbe5e9d65de88d.tar.bz2 nixpkgs-0f68ed163cabcc1963e0b4b643dbe5e9d65de88d.tar.lz nixpkgs-0f68ed163cabcc1963e0b4b643dbe5e9d65de88d.tar.xz nixpkgs-0f68ed163cabcc1963e0b4b643dbe5e9d65de88d.tar.zst nixpkgs-0f68ed163cabcc1963e0b4b643dbe5e9d65de88d.zip |
Merge branch 'mingwW64-clang' into staging
Diffstat (limited to 'pkgs/development/compilers/llvm')
21 files changed, 151 insertions, 46 deletions
diff --git a/pkgs/development/compilers/llvm/10/bintools/default.nix b/pkgs/development/compilers/llvm/10/bintools/default.nix index 53f7941e336..5735bf5a685 100644 --- a/pkgs/development/compilers/llvm/10/bintools/default.nix +++ b/pkgs/development/compilers/llvm/10/bintools/default.nix @@ -5,7 +5,7 @@ let if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; passthru.isLld = true; } '' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) diff --git a/pkgs/development/compilers/llvm/11/bintools/default.nix b/pkgs/development/compilers/llvm/11/bintools/default.nix index 53f7941e336..5735bf5a685 100644 --- a/pkgs/development/compilers/llvm/11/bintools/default.nix +++ b/pkgs/development/compilers/llvm/11/bintools/default.nix @@ -5,7 +5,7 @@ let if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; passthru.isLld = true; } '' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) diff --git a/pkgs/development/compilers/llvm/12/bintools/default.nix b/pkgs/development/compilers/llvm/12/bintools/default.nix index 53f7941e336..5735bf5a685 100644 --- a/pkgs/development/compilers/llvm/12/bintools/default.nix +++ b/pkgs/development/compilers/llvm/12/bintools/default.nix @@ -5,7 +5,7 @@ let if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; passthru.isLld = true; } '' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) diff --git a/pkgs/development/compilers/llvm/13/bintools/default.nix b/pkgs/development/compilers/llvm/13/bintools/default.nix index 53f7941e336..dcdad1af46f 100644 --- a/pkgs/development/compilers/llvm/13/bintools/default.nix +++ b/pkgs/development/compilers/llvm/13/bintools/default.nix @@ -1,11 +1,17 @@ -{ runCommand, stdenv, llvm, lld, version }: +{ runCommand, stdenv, llvm, lld, version, lib }: let prefix = if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { + preferLocalBuild = true; + passthru = { + isLld = true; + targetPrefix = prefix; + }; +} ('' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) @@ -26,4 +32,7 @@ in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip ln -s ${lld}/bin/lld $out/bin/${prefix}ld -'' +'' + lib.optionalString stdenv.targetPlatform.isWindows '' + ln -s ${llvm}/bin/llvm-windres $out/bin/${prefix}windres + ln -s ${llvm}/bin/llvm-dlltool $out/bin/${prefix}dlltool +'') diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index 874be111ade..b72d4244285 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/libcxx/default.nix b/pkgs/development/compilers/llvm/13/libcxx/default.nix index 0ce73ed97af..c5b8293676a 100644 --- a/pkgs/development/compilers/llvm/13/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/13/libcxx/default.nix @@ -1,5 +1,5 @@ { lib, stdenv, llvm_meta, src, cmake, python3, fixDarwinDylibNames, version -, libcxxabi +, libcxxabi, libunwind , enableShared ? !stdenv.hostPlatform.isStatic # If headersOnly is true, the resulting package would only include the headers. @@ -32,7 +32,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake python3 ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; - buildInputs = lib.optionals (!headersOnly) [ libcxxabi ]; + buildInputs = lib.optionals (!headersOnly) ([ libcxxabi ] ++ lib.optional libcxxabi.useLLVMUnwinder libunwind); cmakeFlags = [ "-DLIBCXX_CXX_ABI=libcxxabi" ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" @@ -41,7 +41,13 @@ stdenv.mkDerivation rec { "-DLIBCXX_ENABLE_THREADS=OFF" "-DLIBCXX_ENABLE_FILESYSTEM=OFF" "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; + ] + ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" + ++ lib.optionals (!headersOnly && libcxxabi.semi-static) [ + "-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE" + "-DLIBCXX_CXX_ABI_LIBRARY_PATH=${libcxxabi}/lib" + ] ++ lib.optional (!headersOnly && libcxxabi.useLLVMUnwinder) + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"; buildFlags = lib.optional headersOnly "generate-cxx-headers"; installTargets = lib.optional headersOnly "install-cxx-headers"; diff --git a/pkgs/development/compilers/llvm/13/libcxxabi/default.nix b/pkgs/development/compilers/llvm/13/libcxxabi/default.nix index 0bdbee07b73..66ec96e3518 100644 --- a/pkgs/development/compilers/llvm/13/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/13/libcxxabi/default.nix @@ -2,9 +2,14 @@ , enableShared ? !stdenv.hostPlatform.isStatic , standalone ? stdenv.hostPlatform.useLLVM or false , withLibunwind ? !stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm -}: +}: let + # lld doesn't support unresolved references on Windows https://github.com/llvm/llvm-project/issues/55245 + semi-static = enableShared && stdenv.hostPlatform.isWindows && stdenv.cc.bintools.isLld; -stdenv.mkDerivation rec { + enableShared' = enableShared && !semi-static; + + useLLVMUnwinder = standalone && withLibunwind; +in stdenv.mkDerivation rec { pname = "libcxxabi"; inherit version; @@ -26,18 +31,24 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake python3 ]; buildInputs = lib.optional withLibunwind libunwind; + passthru = { inherit semi-static useLLVMUnwinder; }; + cmakeFlags = [ "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" ] ++ lib.optionals standalone [ "-DLLVM_ENABLE_LIBCXX=ON" - ] ++ lib.optionals (standalone && withLibunwind) [ + ] ++ lib.optionals useLLVMUnwinder [ "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXXABI_ENABLE_THREADS=OFF" "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optionals (!enableShared) [ + ] ++ lib.optionals (!enableShared') [ "-DLIBCXXABI_ENABLE_SHARED=OFF" - ]; + ] ++ lib.optionals semi-static [ + "-DLIBCXX_ENABLE_SHARED=ON" + "-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" + ] ++ lib.optional stdenv.cc.isCompilerRT + "-DLIBCXXABI_USE_COMPILER_RT=ON"; installPhase = if stdenv.isDarwin then '' @@ -56,7 +67,7 @@ stdenv.mkDerivation rec { install -d -m 755 $out/include $out/lib install -m 644 lib/libc++abi.a $out/lib install -m 644 ../include/cxxabi.h $out/include - '' + lib.optionalString enableShared '' + '' + lib.optionalString enableShared' '' install -m 644 lib/libc++abi.so.1.0 $out/lib ln -s libc++abi.so.1.0 $out/lib/libc++abi.so ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 diff --git a/pkgs/development/compilers/llvm/13/libunwind/default.nix b/pkgs/development/compilers/llvm/13/libunwind/default.nix index b6017e74172..c6cc148239e 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/bintools/default.nix b/pkgs/development/compilers/llvm/14/bintools/default.nix index 53f7941e336..dcdad1af46f 100644 --- a/pkgs/development/compilers/llvm/14/bintools/default.nix +++ b/pkgs/development/compilers/llvm/14/bintools/default.nix @@ -1,11 +1,17 @@ -{ runCommand, stdenv, llvm, lld, version }: +{ runCommand, stdenv, llvm, lld, version, lib }: let prefix = if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { + preferLocalBuild = true; + passthru = { + isLld = true; + targetPrefix = prefix; + }; +} ('' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) @@ -26,4 +32,7 @@ in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip ln -s ${lld}/bin/lld $out/bin/${prefix}ld -'' +'' + lib.optionalString stdenv.targetPlatform.isWindows '' + ln -s ${llvm}/bin/llvm-windres $out/bin/${prefix}windres + ln -s ${llvm}/bin/llvm-dlltool $out/bin/${prefix}dlltool +'') diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix index b18b558d5b8..5df6bcae47e 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -169,6 +169,7 @@ let (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; + isCompilerRT = true; }; clangNoLibcxx = wrapCCWith rec { @@ -184,6 +185,7 @@ let "-B${targetLlvmLibraries.compiler-rt}/lib" "-nostdlib++" ]; + isCompilerRT = true; }; clangNoLibc = wrapCCWith rec { @@ -198,6 +200,7 @@ let "-rtlib=compiler-rt" "-B${targetLlvmLibraries.compiler-rt}/lib" ]; + isCompilerRT = true; }; clangNoCompilerRt = wrapCCWith rec { diff --git a/pkgs/development/compilers/llvm/14/libcxx/default.nix b/pkgs/development/compilers/llvm/14/libcxx/default.nix index 8891a69937a..8bdc7aa7967 100644 --- a/pkgs/development/compilers/llvm/14/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/14/libcxx/default.nix @@ -1,7 +1,7 @@ { lib, stdenv, llvm_meta , monorepoSrc, runCommand , cmake, python3, fixDarwinDylibNames, version -, libcxxabi +, libcxxabi, libunwind , enableShared ? !stdenv.hostPlatform.isStatic # If headersOnly is true, the resulting package would only include the headers. @@ -48,7 +48,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake python3 ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; - buildInputs = lib.optionals (!headersOnly) [ libcxxabi ]; + buildInputs = lib.optionals (!headersOnly) ([ libcxxabi ] ++ lib.optional libcxxabi.useLLVMUnwinder libunwind); cmakeFlags = [ "-DLIBCXX_CXX_ABI=libcxxabi" ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" @@ -57,7 +57,13 @@ stdenv.mkDerivation rec { "-DLIBCXX_ENABLE_THREADS=OFF" "-DLIBCXX_ENABLE_FILESYSTEM=OFF" "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; + ] + ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" + ++ lib.optionals (!headersOnly && libcxxabi.semi-static) [ + "-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE" + "-DLIBCXX_CXX_ABI_LIBRARY_PATH=${libcxxabi}/lib" + ] ++ lib.optional (!headersOnly && libcxxabi.useLLVMUnwinder) + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"; buildFlags = lib.optional headersOnly "generate-cxx-headers"; installTargets = lib.optional headersOnly "install-cxx-headers"; diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix index 07aaa2737ce..c31c4c90ad2 100644 --- a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix @@ -2,9 +2,17 @@ , monorepoSrc, runCommand , cxx-headers, libunwind, version , enableShared ? !stdenv.hostPlatform.isStatic -}: +}: let + withLibunwind = !stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm; -stdenv.mkDerivation rec { + semi-static = enableShared && stdenv.hostPlatform.isWindows && stdenv.cc.bintools.isLld; + + enableShared' = enableShared && !semi-static; + + standalone = stdenv.hostPlatform.useLLVM or false; + + useLLVMUnwinder = standalone && withLibunwind; +in stdenv.mkDerivation rec { pname = "libcxxabi"; inherit version; @@ -35,19 +43,26 @@ stdenv.mkDerivation rec { ]; nativeBuildInputs = [ cmake python3 ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional withLibunwind libunwind; + + passthru = { inherit semi-static useLLVMUnwinder; }; cmakeFlags = [ "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" - ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ + ] ++ lib.optionals standalone [ "-DLLVM_ENABLE_LIBCXX=ON" + ] ++ lib.optionals useLLVMUnwinder [ "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXXABI_ENABLE_THREADS=OFF" "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optionals (!enableShared) [ + ] ++ lib.optionals (!enableShared') [ "-DLIBCXXABI_ENABLE_SHARED=OFF" - ]; + ] ++ lib.optionals semi-static [ + "-DLIBCXX_ENABLE_SHARED=ON" + "-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" + ] ++ lib.optional stdenv.cc.isCompilerRT + "-DLIBCXXABI_USE_COMPILER_RT=ON"; installPhase = if stdenv.isDarwin then '' @@ -66,7 +81,7 @@ stdenv.mkDerivation rec { install -d -m 755 $out/include $out/lib install -m 644 lib/libc++abi.a $out/lib install -m 644 ../include/cxxabi.h $out/include - '' + lib.optionalString enableShared '' + '' + lib.optionalString enableShared' '' install -m 644 lib/libc++abi.so.1.0 $out/lib ln -s libc++abi.so.1.0 $out/lib/libc++abi.so ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 diff --git a/pkgs/development/compilers/llvm/14/libunwind/default.nix b/pkgs/development/compilers/llvm/14/libunwind/default.nix index 109b92f1e02..7940fa4b3a1 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/7/bintools/default.nix b/pkgs/development/compilers/llvm/7/bintools/default.nix index 53f7941e336..5735bf5a685 100644 --- a/pkgs/development/compilers/llvm/7/bintools/default.nix +++ b/pkgs/development/compilers/llvm/7/bintools/default.nix @@ -5,7 +5,7 @@ let if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; passthru.isLld = true; } '' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) diff --git a/pkgs/development/compilers/llvm/8/bintools/default.nix b/pkgs/development/compilers/llvm/8/bintools/default.nix index 53f7941e336..5735bf5a685 100644 --- a/pkgs/development/compilers/llvm/8/bintools/default.nix +++ b/pkgs/development/compilers/llvm/8/bintools/default.nix @@ -5,7 +5,7 @@ let if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; passthru.isLld = true; } '' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) diff --git a/pkgs/development/compilers/llvm/9/bintools/default.nix b/pkgs/development/compilers/llvm/9/bintools/default.nix index 53f7941e336..5735bf5a685 100644 --- a/pkgs/development/compilers/llvm/9/bintools/default.nix +++ b/pkgs/development/compilers/llvm/9/bintools/default.nix @@ -5,7 +5,7 @@ let if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; passthru.isLld = true; } '' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) diff --git a/pkgs/development/compilers/llvm/git/bintools/default.nix b/pkgs/development/compilers/llvm/git/bintools/default.nix index 53f7941e336..dcdad1af46f 100644 --- a/pkgs/development/compilers/llvm/git/bintools/default.nix +++ b/pkgs/development/compilers/llvm/git/bintools/default.nix @@ -1,11 +1,17 @@ -{ runCommand, stdenv, llvm, lld, version }: +{ runCommand, stdenv, llvm, lld, version, lib }: let prefix = if stdenv.hostPlatform != stdenv.targetPlatform then "${stdenv.targetPlatform.config}-" else ""; -in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' +in runCommand "llvm-binutils-${version}" { + preferLocalBuild = true; + passthru = { + isLld = true; + targetPrefix = prefix; + }; +} ('' mkdir -p $out/bin for prog in ${lld}/bin/*; do ln -s $prog $out/bin/${prefix}$(basename $prog) @@ -26,4 +32,7 @@ in runCommand "llvm-binutils-${version}" { preferLocalBuild = true; } '' ln -s ${llvm}/bin/llvm-strip $out/bin/${prefix}strip ln -s ${lld}/bin/lld $out/bin/${prefix}ld -'' +'' + lib.optionalString stdenv.targetPlatform.isWindows '' + ln -s ${llvm}/bin/llvm-windres $out/bin/${prefix}windres + ln -s ${llvm}/bin/llvm-dlltool $out/bin/${prefix}dlltool +'') diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 0f45acffb27..6b96190c042 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/libcxx/default.nix b/pkgs/development/compilers/llvm/git/libcxx/default.nix index 8891a69937a..774bd8a9a9b 100644 --- a/pkgs/development/compilers/llvm/git/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxx/default.nix @@ -1,7 +1,7 @@ { lib, stdenv, llvm_meta , monorepoSrc, runCommand , cmake, python3, fixDarwinDylibNames, version -, libcxxabi +, libcxxabi, libunwind , enableShared ? !stdenv.hostPlatform.isStatic # If headersOnly is true, the resulting package would only include the headers. @@ -48,7 +48,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake python3 ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; - buildInputs = lib.optionals (!headersOnly) [ libcxxabi ]; + buildInputs = lib.optionals (!headersOnly) ([ libcxxabi ] ++ lib.optional libcxxabi.useLLVMUnwinder libunwind); cmakeFlags = [ "-DLIBCXX_CXX_ABI=libcxxabi" ] ++ lib.optional (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) "-DLIBCXX_HAS_MUSL_LIBC=1" @@ -57,7 +57,14 @@ stdenv.mkDerivation rec { "-DLIBCXX_ENABLE_THREADS=OFF" "-DLIBCXX_ENABLE_FILESYSTEM=OFF" "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF"; + ] + ++ lib.optional (!enableShared) "-DLIBCXX_ENABLE_SHARED=OFF" + ++ lib.optionals (!headersOnly && libcxxabi.semi-static) [ + "-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE" + "-DLIBCXX_CXX_ABI_LIBRARY_PATH=${libcxxabi}/lib" + ] ++ lib.optional (!headersOnly && libcxxabi.useLLVMUnwinder) + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON"; + buildFlags = lib.optional headersOnly "generate-cxx-headers"; installTargets = lib.optional headersOnly "install-cxx-headers"; diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix index d64708ab040..26388e42f22 100644 --- a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix @@ -2,7 +2,17 @@ , monorepoSrc, runCommand , cxx-headers, libunwind, version , enableShared ? !stdenv.hostPlatform.isStatic -}: +}: let + withLibunwind = !stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm; + + semi-static = enableShared && stdenv.hostPlatform.isWindows && stdenv.cc.bintools.isLld; + + enableShared' = enableShared && !semi-static; + + standalone = stdenv.hostPlatform.useLLVM or false; + + useLLVMUnwinder = standalone && withLibunwind; +in stdenv.mkDerivation rec { pname = "libcxxabi"; @@ -35,19 +45,27 @@ stdenv.mkDerivation rec { ]; nativeBuildInputs = [ cmake python3 ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional withLibunwind libunwind; + + passthru = { inherit semi-static useLLVMUnwinder; }; + cmakeFlags = [ "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" - ] ++ lib.optionals (stdenv.hostPlatform.useLLVM or false) [ + ] ++ lib.optionals standalone [ "-DLLVM_ENABLE_LIBCXX=ON" + ] ++ lib.optionals useLLVMUnwinder [ "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXXABI_ENABLE_THREADS=OFF" "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optionals (!enableShared) [ + ] ++ lib.optionals (!enableShared') [ "-DLIBCXXABI_ENABLE_SHARED=OFF" - ]; + ] ++ lib.optionals semi-static [ + "-DLIBCXX_ENABLE_SHARED=ON" + "-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON" + ] ++ lib.optional stdenv.cc.isCompilerRT + "-DLIBCXXABI_USE_COMPILER_RT=ON"; installPhase = if stdenv.isDarwin then '' @@ -66,7 +84,7 @@ stdenv.mkDerivation rec { install -d -m 755 $out/include $out/lib install -m 644 lib/libc++abi.a $out/lib install -m 644 ../include/cxxabi.h $out/include - '' + lib.optionalString enableShared '' + '' + lib.optionalString enableShared' '' install -m 644 lib/libc++abi.so.1.0 $out/lib ln -s libc++abi.so.1.0 $out/lib/libc++abi.so ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 diff --git a/pkgs/development/compilers/llvm/git/libunwind/default.nix b/pkgs/development/compilers/llvm/git/libunwind/default.nix index c6d9eda5e47..30874588d8d 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 |