From 319626a859f142750875590ffe8ef35f410ca8d1 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Thu, 22 Dec 2022 13:16:29 -0600 Subject: [PATCH] llvmPackages: add overrideable withLibunwind This makes it possible to disable bundling libunwind with Clang for out-of-tree platforms. --- pkgs/development/compilers/llvm/10/default.nix | 7 ++++--- pkgs/development/compilers/llvm/10/libcxxabi/default.nix | 3 ++- pkgs/development/compilers/llvm/11/default.nix | 7 ++++--- pkgs/development/compilers/llvm/12/default.nix | 7 ++++--- pkgs/development/compilers/llvm/13/default.nix | 7 ++++--- pkgs/development/compilers/llvm/14/default.nix | 7 ++++--- pkgs/development/compilers/llvm/14/libcxxabi/default.nix | 3 ++- pkgs/development/compilers/llvm/7/default.nix | 7 ++++--- pkgs/development/compilers/llvm/8/default.nix | 7 ++++--- pkgs/development/compilers/llvm/8/libcxxabi/default.nix | 3 ++- pkgs/development/compilers/llvm/9/default.nix | 7 ++++--- pkgs/development/compilers/llvm/9/libcxxabi/default.nix | 3 ++- pkgs/development/compilers/llvm/git/default.nix | 7 ++++--- pkgs/development/compilers/llvm/git/libcxxabi/default.nix | 3 ++- 14 files changed, 46 insertions(+), 32 deletions(-) diff --git a/pkgs/development/compilers/llvm/10/default.nix b/pkgs/development/compilers/llvm/10/default.nix index 10db99e899a9a..b86b31e7d21bb 100644 --- a/pkgs/development/compilers/llvm/10/default.nix +++ b/pkgs/development/compilers/llvm/10/default.nix @@ -15,6 +15,7 @@ if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintools +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -149,15 +150,15 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + '' + lib.optionalString withLibunwind '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' + '' + lib.optionalString (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags diff --git a/pkgs/development/compilers/llvm/10/libcxxabi/default.nix b/pkgs/development/compilers/llvm/10/libcxxabi/default.nix index d62422fc9a12a..8a9350760bfcd 100644 --- a/pkgs/development/compilers/llvm/10/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/10/libcxxabi/default.nix @@ -1,5 +1,6 @@ { lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version , enableShared ? !stdenv.hostPlatform.isStatic +, withLibunwind ? !stdenv.hostPlatform.isWasm }: stdenv.mkDerivation { @@ -28,7 +29,7 @@ stdenv.mkDerivation { ]; nativeBuildInputs = [ cmake ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional (withLibunwind && !stdenv.isDarwin) libunwind; cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [ "-DLLVM_ENABLE_LIBCXX=ON" diff --git a/pkgs/development/compilers/llvm/11/default.nix b/pkgs/development/compilers/llvm/11/default.nix index ae9b81ac1a1b6..94ec40646953f 100644 --- a/pkgs/development/compilers/llvm/11/default.nix +++ b/pkgs/development/compilers/llvm/11/default.nix @@ -15,6 +15,7 @@ if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintools +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -164,15 +165,15 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + '' + lib.optionalString withLibunwind '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' + '' + lib.optionalString (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index 132a98b9d7694..2b55fa2ce17e2 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -16,6 +16,7 @@ then null else pkgs.bintools , darwin +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -156,15 +157,15 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + '' + lib.optionalString withLibunwind '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' + '' + lib.optionalString (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index e62db1bc2c1cd..dcf5958e88270 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -16,6 +16,7 @@ then null else pkgs.bintools , darwin +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -156,15 +157,15 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + '' + lib.optionalString withLibunwind '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' + '' + lib.optionalString (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix index 26c0e23942068..839740d01b904 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -16,6 +16,7 @@ then null else pkgs.bintools , darwin +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -156,7 +157,7 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = mkExtraBuildCommands cc; @@ -165,9 +166,9 @@ let "-Wno-unused-command-line-argument" "-B${targetLlvmLibraries.compiler-rt}/lib" ] - ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind" + ++ lib.optional withLibunwind "--unwindlib=libunwind" ++ lib.optional - (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) + (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; }; diff --git a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix index 3be2f964abcd2..5b279553d427a 100644 --- a/pkgs/development/compilers/llvm/14/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/14/libcxxabi/default.nix @@ -2,6 +2,7 @@ , monorepoSrc, runCommand , cxx-headers, libunwind, version , enableShared ? !stdenv.hostPlatform.isStatic +, withLibunwind ? !stdenv.hostPlatform.isWasm }: stdenv.mkDerivation rec { @@ -35,7 +36,7 @@ stdenv.mkDerivation rec { ]; nativeBuildInputs = [ cmake python3 ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional (withLibunwind && !stdenv.isDarwin) libunwind; cmakeFlags = [ "-DLIBCXXABI_LIBCXX_INCLUDES=${cxx-headers}/include/c++/v1" diff --git a/pkgs/development/compilers/llvm/7/default.nix b/pkgs/development/compilers/llvm/7/default.nix index f33efb439026c..72d7cfd3de5ea 100644 --- a/pkgs/development/compilers/llvm/7/default.nix +++ b/pkgs/development/compilers/llvm/7/default.nix @@ -15,6 +15,7 @@ if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintools +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -156,15 +157,15 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + '' + lib.optionalString withLibunwind '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' + '' + lib.optionalString (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags diff --git a/pkgs/development/compilers/llvm/8/default.nix b/pkgs/development/compilers/llvm/8/default.nix index 0d604189a19f2..bf0a1ecc689a1 100644 --- a/pkgs/development/compilers/llvm/8/default.nix +++ b/pkgs/development/compilers/llvm/8/default.nix @@ -15,6 +15,7 @@ if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintools +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -157,15 +158,15 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + '' + lib.optionalString withLibunwind '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' + '' + lib.optionalString (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags diff --git a/pkgs/development/compilers/llvm/8/libcxxabi/default.nix b/pkgs/development/compilers/llvm/8/libcxxabi/default.nix index ab2d46f40a479..64d8dc2643997 100644 --- a/pkgs/development/compilers/llvm/8/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/8/libcxxabi/default.nix @@ -1,5 +1,6 @@ { lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version , enableShared ? !stdenv.hostPlatform.isStatic +, withLibunwind ? !stdenv.hostPlatform.isWasm }: stdenv.mkDerivation { @@ -28,7 +29,7 @@ stdenv.mkDerivation { ]; nativeBuildInputs = [ cmake ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional (withLibunwind && !stdenv.isDarwin) libunwind; cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [ "-DLLVM_ENABLE_LIBCXX=ON" diff --git a/pkgs/development/compilers/llvm/9/default.nix b/pkgs/development/compilers/llvm/9/default.nix index 95e05c969cdf3..735ea7ff48dac 100644 --- a/pkgs/development/compilers/llvm/9/default.nix +++ b/pkgs/development/compilers/llvm/9/default.nix @@ -15,6 +15,7 @@ if stdenv.targetPlatform.linker == "lld" then null else pkgs.bintools +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -157,15 +158,15 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = '' echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' + '' + lib.optionalString withLibunwind '' echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags - '' + lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' + '' + lib.optionalString (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) '' echo "-lunwind" >> $out/nix-support/cc-ldflags '' + lib.optionalString stdenv.targetPlatform.isWasm '' echo "-fno-exceptions" >> $out/nix-support/cc-cflags diff --git a/pkgs/development/compilers/llvm/9/libcxxabi/default.nix b/pkgs/development/compilers/llvm/9/libcxxabi/default.nix index cfd1c32abd00e..a419913febf67 100644 --- a/pkgs/development/compilers/llvm/9/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/9/libcxxabi/default.nix @@ -1,5 +1,6 @@ { lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version , enableShared ? !stdenv.hostPlatform.isStatic +, withLibunwind ? !stdenv.hostPlatform.isWasm }: stdenv.mkDerivation { @@ -28,7 +29,7 @@ stdenv.mkDerivation { ]; nativeBuildInputs = [ cmake ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional (withLibunwind && !stdenv.isDarwin) libunwind; cmakeFlags = lib.optionals (stdenv.hostPlatform.useLLVM or false) [ "-DLLVM_ENABLE_LIBCXX=ON" diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index c5567d2f2e2ac..19164b7a1599c 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -15,6 +15,7 @@ then null else pkgs.bintools , darwin +, withLibunwind ? !stdenv.targetPlatform.isWasm }: let @@ -155,7 +156,7 @@ let extraPackages = [ targetLlvmLibraries.libcxxabi targetLlvmLibraries.compiler-rt - ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ + ] ++ lib.optionals withLibunwind [ targetLlvmLibraries.libunwind ]; extraBuildCommands = mkExtraBuildCommands cc; @@ -164,9 +165,9 @@ let "-Wno-unused-command-line-argument" "-B${targetLlvmLibraries.compiler-rt}/lib" ] - ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind" + ++ lib.optional withLibunwind "--unwindlib=libunwind" ++ lib.optional - (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) + (withLibunwind && !stdenv.targetPlatform.isFreeBSD && stdenv.targetPlatform.useLLVM or false) "-lunwind" ++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions"; }; diff --git a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix index 804acd6c7451c..c7d773717b756 100644 --- a/pkgs/development/compilers/llvm/git/libcxxabi/default.nix +++ b/pkgs/development/compilers/llvm/git/libcxxabi/default.nix @@ -2,6 +2,7 @@ , monorepoSrc, runCommand, fetchpatch , cxx-headers, libunwind, version , enableShared ? !stdenv.hostPlatform.isStatic +, withLibunwind ? !stdenv.hostPlatform.isWasm }: stdenv.mkDerivation rec { @@ -53,7 +54,7 @@ stdenv.mkDerivation rec { ''; nativeBuildInputs = [ cmake python3 ]; - buildInputs = lib.optional (!stdenv.isDarwin && !stdenv.hostPlatform.isWasm) libunwind; + buildInputs = lib.optional (withLibunwind && !stdenv.isDarwin) libunwind; cmakeFlags = [ "-DLLVM_ENABLE_RUNTIMES=libcxxabi"