llvmPackages_{12,13,14,15,16,17,18,git}: use common libunwind

This commit is contained in:
Tristan Ross 2024-03-28 11:25:39 -07:00
parent d9110b9705
commit ae92b08fd4
No known key found for this signature in database
GPG key ID: B09C422035669AF8
17 changed files with 111 additions and 431 deletions

View file

@ -258,9 +258,12 @@ let
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
src = fetch "libunwind" "192ww6n81lj2mb9pj4043z79jp3cf58a9c2qrxjwm5c3a64n1shb";
patches = [
./libunwind/gnu-install-dirs.patch
];
inherit llvm_meta;
inherit (buildLlvmTools) llvm;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,37 +0,0 @@
{ lib, stdenv, llvm_meta, version, fetch, libcxx, llvm, cmake
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
src = fetch pname "192ww6n81lj2mb9pj4043z79jp3cf58a9c2qrxjwm5c3a64n1shb";
postUnpack = ''
ln -s ${libcxx.src}/libcxx .
ln -s ${libcxx.src}/llvm .
'';
patches = [
./gnu-install-dirs.patch
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -296,7 +296,10 @@ in let
monorepoSrc = src;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
patches = [
./libunwind/gnu-install-dirs.patch
];
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,33 +0,0 @@
{ lib, stdenv, llvm_meta, version, src, cmake
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
inherit src;
sourceRoot = "${src.name}/${pname}";
patches = [
./gnu-install-dirs.patch
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -294,7 +294,10 @@ in let
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
patches = [
./libunwind/gnu-install-dirs.patch
];
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,47 +0,0 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
# I am not so comfortable giving libc++ and friends the whole monorepo as
# requested, so I filter it to what is needed.
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
'';
sourceRoot = "${src.name}/${pname}";
patches = [
./gnu-install-dirs.patch
];
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ];
cmakeFlags = lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -312,7 +312,10 @@ in let
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
patches = [
./libunwind/gnu-install-dirs.patch
];
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,67 +0,0 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake
, ninja
, python3
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
# I am not so comfortable giving libc++ and friends the whole monorepo as
# requested, so I filter it to what is needed.
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
prePatch = ''
cd ../${pname}
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
];
postPatch = ''
cd ../runtimes
'';
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
# libcxxabi wants to link to libunwind_shared.so (?).
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
'';
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ninja python3 ];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=libunwind"
] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -327,7 +327,10 @@ in let
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
patches = [
./libunwind/gnu-install-dirs.patch
];
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,67 +0,0 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake
, ninja
, python3
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
# I am not so comfortable giving libc++ and friends the whole monorepo as
# requested, so I filter it to what is needed.
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
prePatch = ''
cd ../${pname}
chmod -R u+w .
'';
patches = [
./gnu-install-dirs.patch
];
postPatch = ''
cd ../runtimes
'';
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
# libcxxabi wants to link to libunwind_shared.so (?).
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
'';
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ninja python3 ];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=libunwind"
] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -312,7 +312,7 @@ in let
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,63 +0,0 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake
, ninja
, python3
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
# I am not so comfortable giving libc++ and friends the whole monorepo as
# requested, so I filter it to what is needed.
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
prePatch = ''
cd ../${pname}
chmod -R u+w .
'';
postPatch = ''
cd ../runtimes
'';
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
# libcxxabi wants to link to libunwind_shared.so (?).
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
'';
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ninja python3 ];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=libunwind"
] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -312,7 +312,7 @@ in let
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,54 +0,0 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake
, ninja
, python3
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
# I am not so comfortable giving libc++ and friends the whole monorepo as
# requested, so I filter it to what is needed.
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
# libcxxabi wants to link to libunwind_shared.so (?).
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
'';
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ninja python3 ];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=libunwind"
] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}

View file

@ -0,0 +1,87 @@
{ lib
, stdenv
, release_version
, patches ? []
, src ? null
, llvm_meta
, version
, monorepoSrc ? null
, runCommand
, cmake
, ninja
, python3
, libcxx
, enableShared ? !stdenv.hostPlatform.isStatic
}:
let
pname = "libunwind";
src' = if monorepoSrc != null then
runCommand "${pname}-src-${version}" {} (''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
'' + lib.optionalString (lib.versionAtLeast release_version "15") ''
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'') else src;
hasPatches = builtins.length patches > 0;
postUnpack = lib.optionalString (lib.versions.major release_version == "12") ''
ln -s ${libcxx.src}/libcxx .
ln -s ${libcxx.src}/llvm .
'';
prePatch = lib.optionalString (lib.versionAtLeast release_version "15" && (hasPatches || lib.versionOlder release_version "18")) ''
cd ../${pname}
chmod -R u+w .
'';
postPatch = lib.optionalString (lib.versionAtLeast release_version "15" && (hasPatches || lib.versionOlder release_version "18")) ''
cd ../runtimes
'';
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
# libcxxabi wants to link to libunwind_shared.so (?).
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
'';
in
stdenv.mkDerivation (rec {
inherit pname version patches;
src = src';
sourceRoot =
if lib.versionOlder release_version "13" then null
else if lib.versionAtLeast release_version "15" then "${src.name}/runtimes"
else "${src.name}/${pname}";
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ] ++ lib.optionals (lib.versionAtLeast release_version "15") [
ninja python3
];
cmakeFlags = lib.optional (lib.versionAtLeast release_version "15") "-DLLVM_ENABLE_RUNTIMES=libunwind"
++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
} // (if postUnpack != "" then { inherit postUnpack; } else {})
// (if (lib.versionAtLeast release_version "15") then { inherit postInstall; } else {})
// (if prePatch != "" then { inherit prePatch; } else {})
// (if postPatch != "" then { inherit postPatch; } else {}))

View file

@ -317,7 +317,7 @@ in let
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};
libunwind = callPackage ./libunwind {
libunwind = callPackage ../common/libunwind {
inherit llvm_meta;
stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx;
};

View file

@ -1,54 +0,0 @@
{ lib, stdenv, llvm_meta, version
, monorepoSrc, runCommand
, cmake
, ninja
, python3
, enableShared ? !stdenv.hostPlatform.isStatic
}:
stdenv.mkDerivation rec {
pname = "libunwind";
inherit version;
# I am not so comfortable giving libc++ and friends the whole monorepo as
# requested, so I filter it to what is needed.
src = runCommand "${pname}-src-${version}" {} ''
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
mkdir -p "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/cmake "$out/libcxx"
cp -r ${monorepoSrc}/libcxx/utils "$out/libcxx"
mkdir -p "$out/llvm"
cp -r ${monorepoSrc}/llvm/cmake "$out/llvm"
cp -r ${monorepoSrc}/llvm/utils "$out/llvm"
cp -r ${monorepoSrc}/runtimes "$out"
'';
sourceRoot = "${src.name}/runtimes";
postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
# libcxxabi wants to link to libunwind_shared.so (?).
ln -s $out/lib/libunwind.so $out/lib/libunwind_shared.so
'';
outputs = [ "out" "dev" ];
nativeBuildInputs = [ cmake ninja python3 ];
cmakeFlags = [
"-DLLVM_ENABLE_RUNTIMES=libunwind"
] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF";
meta = llvm_meta // {
# Details: https://github.com/llvm/llvm-project/blob/main/libunwind/docs/index.rst
homepage = "https://clang.llvm.org/docs/Toolchain.html#unwind-library";
description = "LLVM's unwinder library";
longDescription = ''
The unwind library provides a family of _Unwind_* functions implementing
the language-neutral stack unwinding portion of the Itanium C++ ABI (Level
I). It is a dependency of the C++ ABI library, and sometimes is a
dependency of other runtimes.
'';
};
}