Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvmPackages: add overrideable withLibunwind #207325

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/10/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
if stdenv.targetPlatform.linker == "lld"
then null
else pkgs.bintools
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/compilers/llvm/10/libcxxabi/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic
, withLibunwind ? !stdenv.hostPlatform.isWasm
}:

stdenv.mkDerivation {
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
if stdenv.targetPlatform.linker == "lld"
then null
else pkgs.bintools
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/12/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
then null
else pkgs.bintools
, darwin
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/13/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
then null
else pkgs.bintools
, darwin
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/14/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
then null
else pkgs.bintools
, darwin
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -156,7 +157,7 @@ let
extraPackages = [
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
] ++ lib.optionals withLibunwind [
targetLlvmLibraries.libunwind
];
extraBuildCommands = mkExtraBuildCommands cc;
Expand All @@ -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";
};
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/compilers/llvm/14/libcxxabi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, monorepoSrc, runCommand
, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
, withLibunwind ? !stdenv.hostPlatform.isWasm
}:

stdenv.mkDerivation rec {
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
if stdenv.targetPlatform.linker == "lld"
then null
else pkgs.bintools
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/8/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
if stdenv.targetPlatform.linker == "lld"
then null
else pkgs.bintools
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/compilers/llvm/8/libcxxabi/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic
, withLibunwind ? !stdenv.hostPlatform.isWasm
}:

stdenv.mkDerivation {
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/9/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
if stdenv.targetPlatform.linker == "lld"
then null
else pkgs.bintools
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/compilers/llvm/9/libcxxabi/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ lib, stdenv, llvm_meta, cmake, fetch, libcxx, libunwind, llvm, version
, enableShared ? !stdenv.hostPlatform.isStatic
, withLibunwind ? !stdenv.hostPlatform.isWasm
}:

stdenv.mkDerivation {
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions pkgs/development/compilers/llvm/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
then null
else pkgs.bintools
, darwin
, withLibunwind ? !stdenv.targetPlatform.isWasm
}:

let
Expand Down Expand Up @@ -155,7 +156,7 @@ let
extraPackages = [
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
] ++ lib.optionals withLibunwind [
targetLlvmLibraries.libunwind
];
extraBuildCommands = mkExtraBuildCommands cc;
Expand All @@ -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";
};
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/compilers/llvm/git/libcxxabi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, monorepoSrc, runCommand, fetchpatch
, cxx-headers, libunwind, version
, enableShared ? !stdenv.hostPlatform.isStatic
, withLibunwind ? !stdenv.hostPlatform.isWasm
}:

stdenv.mkDerivation rec {
Expand Down Expand Up @@ -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"
Expand Down