From ae92b08fd4369c0017cfb0df1890804d6324e20f Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 11:25:39 -0700 Subject: [PATCH] llvmPackages_{12,13,14,15,16,17,18,git}: use common libunwind --- .../development/compilers/llvm/12/default.nix | 7 +- .../compilers/llvm/12/libunwind/default.nix | 37 -------- .../development/compilers/llvm/13/default.nix | 5 +- .../compilers/llvm/13/libunwind/default.nix | 33 ------- .../development/compilers/llvm/14/default.nix | 5 +- .../compilers/llvm/14/libunwind/default.nix | 47 ---------- .../development/compilers/llvm/15/default.nix | 5 +- .../compilers/llvm/15/libunwind/default.nix | 67 -------------- .../development/compilers/llvm/16/default.nix | 5 +- .../compilers/llvm/16/libunwind/default.nix | 67 -------------- .../development/compilers/llvm/17/default.nix | 2 +- .../compilers/llvm/17/libunwind/default.nix | 63 -------------- .../development/compilers/llvm/18/default.nix | 2 +- .../compilers/llvm/18/libunwind/default.nix | 54 ------------ .../llvm/common/libunwind/default.nix | 87 +++++++++++++++++++ .../compilers/llvm/git/default.nix | 2 +- .../compilers/llvm/git/libunwind/default.nix | 54 ------------ 17 files changed, 111 insertions(+), 431 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/12/libunwind/default.nix delete mode 100644 pkgs/development/compilers/llvm/13/libunwind/default.nix delete mode 100644 pkgs/development/compilers/llvm/14/libunwind/default.nix delete mode 100644 pkgs/development/compilers/llvm/15/libunwind/default.nix delete mode 100644 pkgs/development/compilers/llvm/16/libunwind/default.nix delete mode 100644 pkgs/development/compilers/llvm/17/libunwind/default.nix delete mode 100644 pkgs/development/compilers/llvm/18/libunwind/default.nix create mode 100644 pkgs/development/compilers/llvm/common/libunwind/default.nix delete mode 100644 pkgs/development/compilers/llvm/git/libunwind/default.nix diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index bd87dc5f34f0..8b07c6705e20 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/12/libunwind/default.nix b/pkgs/development/compilers/llvm/12/libunwind/default.nix deleted file mode 100644 index 95e0962b4689..000000000000 --- a/pkgs/development/compilers/llvm/12/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index 429dfe5f1f3e..d280a93d7e91 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/13/libunwind/default.nix b/pkgs/development/compilers/llvm/13/libunwind/default.nix deleted file mode 100644 index d837bc60de37..000000000000 --- a/pkgs/development/compilers/llvm/13/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix index 6dcdcfa92584..6c9067b65e15 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/14/libunwind/default.nix b/pkgs/development/compilers/llvm/14/libunwind/default.nix deleted file mode 100644 index c6d9eda5e474..000000000000 --- a/pkgs/development/compilers/llvm/14/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix index dcafd2970d00..0a7ad8f79220 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/15/libunwind/default.nix b/pkgs/development/compilers/llvm/15/libunwind/default.nix deleted file mode 100644 index 1b677a7a2c0d..000000000000 --- a/pkgs/development/compilers/llvm/15/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index 46d17c193fc9..bec24fb620ab 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/16/libunwind/default.nix b/pkgs/development/compilers/llvm/16/libunwind/default.nix deleted file mode 100644 index 1b677a7a2c0d..000000000000 --- a/pkgs/development/compilers/llvm/16/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/17/default.nix b/pkgs/development/compilers/llvm/17/default.nix index fb3e967cc39b..680821719980 100644 --- a/pkgs/development/compilers/llvm/17/default.nix +++ b/pkgs/development/compilers/llvm/17/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/17/libunwind/default.nix b/pkgs/development/compilers/llvm/17/libunwind/default.nix deleted file mode 100644 index a3c8e2594f5a..000000000000 --- a/pkgs/development/compilers/llvm/17/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/18/default.nix b/pkgs/development/compilers/llvm/18/default.nix index 5f7f67438f0f..19df1d461746 100644 --- a/pkgs/development/compilers/llvm/18/default.nix +++ b/pkgs/development/compilers/llvm/18/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/18/libunwind/default.nix b/pkgs/development/compilers/llvm/18/libunwind/default.nix deleted file mode 100644 index e67823ffb85c..000000000000 --- a/pkgs/development/compilers/llvm/18/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/common/libunwind/default.nix b/pkgs/development/compilers/llvm/common/libunwind/default.nix new file mode 100644 index 000000000000..515914e6acb6 --- /dev/null +++ b/pkgs/development/compilers/llvm/common/libunwind/default.nix @@ -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 {})) diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index bd21a75b8c2f..344025149d95 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -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; }; diff --git a/pkgs/development/compilers/llvm/git/libunwind/default.nix b/pkgs/development/compilers/llvm/git/libunwind/default.nix deleted file mode 100644 index e67823ffb85c..000000000000 --- a/pkgs/development/compilers/llvm/git/libunwind/default.nix +++ /dev/null @@ -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. - ''; - }; -}