From 0daf89b8d275a6f54ab4ce2c69dcafa7bfbe1e76 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 10:20:08 -0700 Subject: [PATCH 01/11] llvmPackages_git: move lld to common --- pkgs/development/compilers/llvm/{git => common}/lld/default.nix | 0 .../compilers/llvm/{git => common}/lld/gnu-install-dirs.patch | 0 pkgs/development/compilers/llvm/git/default.nix | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename pkgs/development/compilers/llvm/{git => common}/lld/default.nix (100%) rename pkgs/development/compilers/llvm/{git => common}/lld/gnu-install-dirs.patch (100%) diff --git a/pkgs/development/compilers/llvm/git/lld/default.nix b/pkgs/development/compilers/llvm/common/lld/default.nix similarity index 100% rename from pkgs/development/compilers/llvm/git/lld/default.nix rename to pkgs/development/compilers/llvm/common/lld/default.nix diff --git a/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/common/lld/gnu-install-dirs.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch rename to pkgs/development/compilers/llvm/common/lld/gnu-install-dirs.patch diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 80cff85372d06..b920f6c0d562d 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -144,7 +144,7 @@ in let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { inherit llvm_meta; }; From 2a660eb2aa4dba586dae5b1d30f3f4fedb3f2da8 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 11:11:16 -0700 Subject: [PATCH 02/11] llvmPackages_git: move clang to common --- .../compilers/llvm/{git => common}/clang/default.nix | 4 ++-- .../llvm/{git => common}/clang/gnu-install-dirs.patch | 0 .../compilers/llvm/{git => common}/clang/purity.patch | 0 pkgs/development/compilers/llvm/git/default.nix | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename pkgs/development/compilers/llvm/{git => common}/clang/default.nix (97%) rename pkgs/development/compilers/llvm/{git => common}/clang/gnu-install-dirs.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/clang/purity.patch (100%) diff --git a/pkgs/development/compilers/llvm/git/clang/default.nix b/pkgs/development/compilers/llvm/common/clang/default.nix similarity index 97% rename from pkgs/development/compilers/llvm/git/clang/default.nix rename to pkgs/development/compilers/llvm/common/clang/default.nix index 1e777c6132e43..85af6cbc4aee9 100644 --- a/pkgs/development/compilers/llvm/git/clang/default.nix +++ b/pkgs/development/compilers/llvm/common/clang/default.nix @@ -52,9 +52,9 @@ let ./purity.patch # https://reviews.llvm.org/D51899 ./gnu-install-dirs.patch - ../../common/clang/add-nostdlibinc-flag.patch + ./add-nostdlibinc-flag.patch (substituteAll { - src = ../../common/clang/clang-at-least-16-LLVMgold-path.patch; + src = ./clang-at-least-16-LLVMgold-path.patch; libllvmLibdir = "${libllvm.lib}/lib"; }) ]; diff --git a/pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/common/clang/gnu-install-dirs.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/clang/gnu-install-dirs.patch rename to pkgs/development/compilers/llvm/common/clang/gnu-install-dirs.patch diff --git a/pkgs/development/compilers/llvm/git/clang/purity.patch b/pkgs/development/compilers/llvm/common/clang/purity.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/clang/purity.patch rename to pkgs/development/compilers/llvm/common/clang/purity.patch diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index b920f6c0d562d..62ad12666d123 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -98,7 +98,7 @@ in let # we need to reintroduce `outputSpecified` to get the expected behavior e.g. of lib.get* llvm = tools.libllvm; - libclang = callPackage ./clang { + libclang = callPackage ../common/clang { inherit llvm_meta; }; From 129557c7d694605e75dd8f4f8265ae074b39e392 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 11:18:31 -0700 Subject: [PATCH 03/11] llvmPackages_git: move compiler-rt to common --- .../{git => common}/compiler-rt/X86-support-extension.patch | 0 .../compiler-rt/darwin-targetconditionals.patch | 0 .../compilers/llvm/{git => common}/compiler-rt/default.nix | 4 ++-- .../llvm/{git => common}/compiler-rt/normalize-var.patch | 0 pkgs/development/compilers/llvm/git/default.nix | 4 ++-- 5 files changed, 4 insertions(+), 4 deletions(-) rename pkgs/development/compilers/llvm/{git => common}/compiler-rt/X86-support-extension.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/compiler-rt/darwin-targetconditionals.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/compiler-rt/default.nix (98%) rename pkgs/development/compilers/llvm/{git => common}/compiler-rt/normalize-var.patch (100%) diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/X86-support-extension.patch b/pkgs/development/compilers/llvm/common/compiler-rt/X86-support-extension.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/compiler-rt/X86-support-extension.patch rename to pkgs/development/compilers/llvm/common/compiler-rt/X86-support-extension.patch diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/darwin-targetconditionals.patch b/pkgs/development/compilers/llvm/common/compiler-rt/darwin-targetconditionals.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/compiler-rt/darwin-targetconditionals.patch rename to pkgs/development/compilers/llvm/common/compiler-rt/darwin-targetconditionals.patch diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix similarity index 98% rename from pkgs/development/compilers/llvm/git/compiler-rt/default.nix rename to pkgs/development/compilers/llvm/common/compiler-rt/default.nix index f51316beb5705..417a701c95e70 100644 --- a/pkgs/development/compilers/llvm/git/compiler-rt/default.nix +++ b/pkgs/development/compilers/llvm/common/compiler-rt/default.nix @@ -91,9 +91,9 @@ stdenv.mkDerivation { # extra `/`. ./normalize-var.patch # See: https://github.com/NixOS/nixpkgs/pull/186575 - ../../common/compiler-rt/darwin-plistbuddy-workaround.patch + ./darwin-plistbuddy-workaround.patch # See: https://github.com/NixOS/nixpkgs/pull/194634#discussion_r999829893 - # ../../common/compiler-rt/armv7l-15.patch + # ./armv7l-15.patch ]; # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks diff --git a/pkgs/development/compilers/llvm/git/compiler-rt/normalize-var.patch b/pkgs/development/compilers/llvm/common/compiler-rt/normalize-var.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/compiler-rt/normalize-var.patch rename to pkgs/development/compilers/llvm/common/compiler-rt/normalize-var.patch diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 62ad12666d123..f41be058d06f1 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -289,14 +289,14 @@ in let callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake ninja libxml2 python3 release_version version monorepoSrc; }); in { - compiler-rt-libc = callPackage ./compiler-rt { + compiler-rt-libc = callPackage ../common/compiler-rt { inherit llvm_meta; stdenv = if stdenv.hostPlatform.useLLVM or false || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isStatic) then overrideCC stdenv buildLlvmTools.clangNoCompilerRtWithLibc else stdenv; }; - compiler-rt-no-libc = callPackage ./compiler-rt { + compiler-rt-no-libc = callPackage ../common/compiler-rt { inherit llvm_meta; stdenv = if stdenv.hostPlatform.useLLVM or false then overrideCC stdenv buildLlvmTools.clangNoCompilerRt From 005d865c1e58979c24ad05cdafa89937373f989a Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 11:24:06 -0700 Subject: [PATCH 04/11] llvmPackages_git: move libcxx to common --- .../libcxx/0001-darwin-10.12-mbstate_t-fix.patch | 0 .../compilers/llvm/{git => common}/libcxx/default.nix | 0 pkgs/development/compilers/llvm/git/default.nix | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename pkgs/development/compilers/llvm/{git => common}/libcxx/0001-darwin-10.12-mbstate_t-fix.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/libcxx/default.nix (100%) diff --git a/pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch b/pkgs/development/compilers/llvm/common/libcxx/0001-darwin-10.12-mbstate_t-fix.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/libcxx/0001-darwin-10.12-mbstate_t-fix.patch rename to pkgs/development/compilers/llvm/common/libcxx/0001-darwin-10.12-mbstate_t-fix.patch diff --git a/pkgs/development/compilers/llvm/git/libcxx/default.nix b/pkgs/development/compilers/llvm/common/libcxx/default.nix similarity index 100% rename from pkgs/development/compilers/llvm/git/libcxx/default.nix rename to pkgs/development/compilers/llvm/common/libcxx/default.nix diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index f41be058d06f1..6ded03de31be4 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -315,7 +315,7 @@ in let # `libcxx` requires a fairly modern C++ compiler, # so: we use the clang from this LLVM package set instead of the regular # stdenv's compiler. - libcxx = callPackage ./libcxx { + libcxx = callPackage ../common/libcxx { inherit llvm_meta; stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; From edebaa9e49d04d1df655ef491ce334176ccc787b Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 11:25:39 -0700 Subject: [PATCH 05/11] llvmPackages_git: move libunwind to common --- .../compilers/llvm/{git => common}/libunwind/default.nix | 0 pkgs/development/compilers/llvm/git/default.nix | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename pkgs/development/compilers/llvm/{git => common}/libunwind/default.nix (100%) diff --git a/pkgs/development/compilers/llvm/git/libunwind/default.nix b/pkgs/development/compilers/llvm/common/libunwind/default.nix similarity index 100% rename from pkgs/development/compilers/llvm/git/libunwind/default.nix rename to pkgs/development/compilers/llvm/common/libunwind/default.nix diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 6ded03de31be4..7b7d7345dc520 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -320,7 +320,7 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - libunwind = callPackage ./libunwind { + libunwind = callPackage ../common/libunwind { inherit llvm_meta; stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; From 5c66a6cf8127f389d99de80e874e84788e744887 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 11:28:13 -0700 Subject: [PATCH 06/11] llvmPackages_git: move openmp to common --- .../compilers/llvm/{git => common}/openmp/default.nix | 0 .../compilers/llvm/{git => common}/openmp/fix-find-tool.patch | 0 .../llvm/{git => common}/openmp/run-lit-directly.patch | 0 pkgs/development/compilers/llvm/git/default.nix | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename pkgs/development/compilers/llvm/{git => common}/openmp/default.nix (100%) rename pkgs/development/compilers/llvm/{git => common}/openmp/fix-find-tool.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/openmp/run-lit-directly.patch (100%) diff --git a/pkgs/development/compilers/llvm/git/openmp/default.nix b/pkgs/development/compilers/llvm/common/openmp/default.nix similarity index 100% rename from pkgs/development/compilers/llvm/git/openmp/default.nix rename to pkgs/development/compilers/llvm/common/openmp/default.nix diff --git a/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch b/pkgs/development/compilers/llvm/common/openmp/fix-find-tool.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch rename to pkgs/development/compilers/llvm/common/openmp/fix-find-tool.patch diff --git a/pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch b/pkgs/development/compilers/llvm/common/openmp/run-lit-directly.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch rename to pkgs/development/compilers/llvm/common/openmp/run-lit-directly.patch diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 7b7d7345dc520..d73b9c3d68f54 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -325,7 +325,7 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { inherit llvm_meta targetLlvm; }; }); From a07e279f266d147655c8e26f029a34b088a42f34 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 11:31:07 -0700 Subject: [PATCH 07/11] llvmPackages_git: move llvm to common --- .../development/compilers/llvm/{git => common}/llvm/default.nix | 2 +- .../llvm/{git => common}/llvm/gnu-install-dirs-polly.patch | 0 .../compilers/llvm/{git => common}/llvm/gnu-install-dirs.patch | 0 .../llvm/lit-shell-script-runner-set-dyld-library-path.patch | 0 .../llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch | 0 .../llvm/polly-lit-cfg-add-libs-to-dylib-path.patch | 0 pkgs/development/compilers/llvm/git/default.nix | 2 +- 7 files changed, 2 insertions(+), 2 deletions(-) rename pkgs/development/compilers/llvm/{git => common}/llvm/default.nix (99%) rename pkgs/development/compilers/llvm/{git => common}/llvm/gnu-install-dirs-polly.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/llvm/gnu-install-dirs.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/llvm/lit-shell-script-runner-set-dyld-library-path.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch (100%) rename pkgs/development/compilers/llvm/{git => common}/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch (100%) diff --git a/pkgs/development/compilers/llvm/git/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix similarity index 99% rename from pkgs/development/compilers/llvm/git/llvm/default.nix rename to pkgs/development/compilers/llvm/common/llvm/default.nix index 670171a707f9c..004c5a5d5d6be 100644 --- a/pkgs/development/compilers/llvm/git/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -232,7 +232,7 @@ stdenv.mkDerivation (rec { # modifies the atime when run. See #284056. rm test/tools/llvm-objcopy/ELF/strip-preserve-atime.test '' + optionalString stdenv.hostPlatform.isMusl '' - patch -p1 -i ${../../common/llvm/TLI-musl.patch} + patch -p1 -i ${./TLI-musl.patch} substituteInPlace unittests/Support/CMakeLists.txt \ --replace "add_subdirectory(DynamicLibrary)" "" rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp diff --git a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch b/pkgs/development/compilers/llvm/common/llvm/gnu-install-dirs-polly.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs-polly.patch rename to pkgs/development/compilers/llvm/common/llvm/gnu-install-dirs-polly.patch diff --git a/pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/common/llvm/gnu-install-dirs.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/llvm/gnu-install-dirs.patch rename to pkgs/development/compilers/llvm/common/llvm/gnu-install-dirs.patch diff --git a/pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch b/pkgs/development/compilers/llvm/common/llvm/lit-shell-script-runner-set-dyld-library-path.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/llvm/lit-shell-script-runner-set-dyld-library-path.patch rename to pkgs/development/compilers/llvm/common/llvm/lit-shell-script-runner-set-dyld-library-path.patch diff --git a/pkgs/development/compilers/llvm/git/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch b/pkgs/development/compilers/llvm/common/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch rename to pkgs/development/compilers/llvm/common/llvm/llvm-lit-cfg-add-libs-to-dylib-path.patch diff --git a/pkgs/development/compilers/llvm/git/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch b/pkgs/development/compilers/llvm/common/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch similarity index 100% rename from pkgs/development/compilers/llvm/git/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch rename to pkgs/development/compilers/llvm/common/llvm/polly-lit-cfg-add-libs-to-dylib-path.patch diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index d73b9c3d68f54..bbc018978cb5c 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -90,7 +90,7 @@ in let in { - libllvm = callPackage ./llvm { + libllvm = callPackage ../common/llvm { inherit llvm_meta; }; From 55d5b4408804f2d5f45a670fc07817330b096fc7 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 4 Apr 2024 21:22:05 -0700 Subject: [PATCH 08/11] llvmPackages_{12,13,14,15,16,17,18}: use common lld --- .../development/compilers/llvm/12/default.nix | 6 +- .../compilers/llvm/12/lld/default.nix | 54 ---------------- .../development/compilers/llvm/13/default.nix | 5 +- .../compilers/llvm/13/lld/default.nix | 55 ---------------- .../development/compilers/llvm/14/default.nix | 6 +- .../compilers/llvm/14/lld/default.nix | 58 ----------------- .../development/compilers/llvm/15/default.nix | 5 +- .../compilers/llvm/15/lld/default.nix | 57 ----------------- .../development/compilers/llvm/16/default.nix | 6 +- .../compilers/llvm/16/lld/default.nix | 58 ----------------- .../development/compilers/llvm/17/default.nix | 6 +- .../compilers/llvm/17/lld/default.nix | 58 ----------------- .../development/compilers/llvm/18/default.nix | 5 +- .../compilers/llvm/18/lld/default.nix | 57 ----------------- .../compilers/llvm/common/lld/default.nix | 64 ++++++++++++------- .../compilers/llvm/git/default.nix | 3 + .../lld/gnu-install-dirs.patch | 0 17 files changed, 77 insertions(+), 426 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/12/lld/default.nix delete mode 100644 pkgs/development/compilers/llvm/13/lld/default.nix delete mode 100644 pkgs/development/compilers/llvm/14/lld/default.nix delete mode 100644 pkgs/development/compilers/llvm/15/lld/default.nix delete mode 100644 pkgs/development/compilers/llvm/16/lld/default.nix delete mode 100644 pkgs/development/compilers/llvm/17/lld/default.nix delete mode 100644 pkgs/development/compilers/llvm/18/lld/default.nix rename pkgs/development/compilers/llvm/{common => git}/lld/gnu-install-dirs.patch (100%) diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index bd87dc5f34f03..36d4d638fe581 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -114,7 +114,11 @@ let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { + src = fetch "lld" "0qg3fgc7wj34hdkqn21y03zcmsdd01szhhm1hfki63iifrm3y2v9"; + patches = [ + ./lld/gnu-install-dirs.patch + ]; inherit llvm_meta; inherit (libraries) libunwind; }; diff --git a/pkgs/development/compilers/llvm/12/lld/default.nix b/pkgs/development/compilers/llvm/12/lld/default.nix deleted file mode 100644 index 01b7e410aa073..0000000000000 --- a/pkgs/development/compilers/llvm/12/lld/default.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ lib, stdenv, llvm_meta -, buildLlvmTools -, fetch -, libunwind -, cmake -, libxml2 -, libllvm -, version -}: - -stdenv.mkDerivation rec { - pname = "lld"; - inherit version; - - src = fetch pname "0qg3fgc7wj34hdkqn21y03zcmsdd01szhhm1hfki63iifrm3y2v9"; - - patches = [ - ./gnu-install-dirs.patch - ]; - - postPatch = '' - substituteInPlace MachO/CMakeLists.txt --replace \ - '(''${LLVM_MAIN_SRC_DIR}/' '(' - mkdir -p libunwind/include - tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/" - ''; - - nativeBuildInputs = [ cmake ]; - buildInputs = [ libllvm libxml2 ]; - - cmakeFlags = [ - "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - ]; - - # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; - - outputs = [ "out" "lib" "dev" ]; - - meta = llvm_meta // { - homepage = "https://lld.llvm.org/"; - description = "The LLVM linker (unwrapped)"; - longDescription = '' - LLD is a linker from the LLVM project that is a drop-in replacement for - system linkers and runs much faster than them. It also provides features - that are useful for toolchain developers. - The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and - WebAssembly in descending order of completeness. Internally, LLD consists - of several different linkers. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index cd96231e62c35..0f4785c32d0a2 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -142,7 +142,10 @@ in let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { + patches = [ + ./lld/gnu-install-dirs.patch + ]; inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/13/lld/default.nix b/pkgs/development/compilers/llvm/13/lld/default.nix deleted file mode 100644 index d506f396f65cd..0000000000000 --- a/pkgs/development/compilers/llvm/13/lld/default.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ lib, stdenv, llvm_meta -, buildLlvmTools -, src -, cmake -, libxml2 -, libllvm -, version -}: - -stdenv.mkDerivation rec { - pname = "lld"; - inherit version; - - inherit src; - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./gnu-install-dirs.patch - ]; - - # On Darwin the llvm-config is perhaps not working fine as the - # LLVM_MAIN_SRC_DIR is not getting set correctly, and the build fails as the - # include path is not correct. - postPatch = lib.optionalString stdenv.isDarwin '' - substituteInPlace MachO/CMakeLists.txt --replace \ - '(''${LLVM_MAIN_SRC_DIR}/' '(../' - ''; - - nativeBuildInputs = [ cmake ]; - buildInputs = [ libllvm libxml2 ]; - - cmakeFlags = [ - "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - ]; - - # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; - - outputs = [ "out" "lib" "dev" ]; - - meta = llvm_meta // { - homepage = "https://lld.llvm.org/"; - description = "The LLVM linker (unwrapped)"; - longDescription = '' - LLD is a linker from the LLVM project that is a drop-in replacement for - system linkers and runs much faster than them. It also provides features - that are useful for toolchain developers. - The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and - WebAssembly in descending order of completeness. Internally, LLD consists - of several different linkers. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix index 66f5c7385a150..93b00d2733840 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -139,7 +139,11 @@ in let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { + patches = [ + ./lld/gnu-install-dirs.patch + ./lld/fix-root-src-dir.patch + ]; inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/14/lld/default.nix b/pkgs/development/compilers/llvm/14/lld/default.nix deleted file mode 100644 index 02ca4c8024873..0000000000000 --- a/pkgs/development/compilers/llvm/14/lld/default.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ lib, stdenv, llvm_meta -, buildLlvmTools -, monorepoSrc, runCommand -, cmake -, libxml2 -, libllvm -, version -}: - -stdenv.mkDerivation rec { - pname = "lld"; - inherit version; - - # Blank llvm dir just so relative path works - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - mkdir -p "$out/libunwind" - cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" - mkdir -p "$out/llvm" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./gnu-install-dirs.patch - # On Darwin the llvm-config is perhaps not working fine as the - # LLVM_MAIN_SRC_DIR is not getting set correctly, and the build fails as - # the include path is not correct. - ./fix-root-src-dir.patch - ]; - - nativeBuildInputs = [ cmake ]; - buildInputs = [ libllvm libxml2 ]; - - cmakeFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - ]; - - # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; - - outputs = [ "out" "lib" "dev" ]; - - meta = llvm_meta // { - homepage = "https://lld.llvm.org/"; - description = "The LLVM linker (unwrapped)"; - longDescription = '' - LLD is a linker from the LLVM project that is a drop-in replacement for - system linkers and runs much faster than them. It also provides features - that are useful for toolchain developers. - The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and - WebAssembly in descending order of completeness. Internally, LLD consists - of several different linkers. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix index 0ccb9c449a8da..3d16cb5ab5547 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -144,7 +144,10 @@ in let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { + patches = [ + ./lld/gnu-install-dirs.patch + ]; inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/15/lld/default.nix b/pkgs/development/compilers/llvm/15/lld/default.nix deleted file mode 100644 index cc18aee76a448..0000000000000 --- a/pkgs/development/compilers/llvm/15/lld/default.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ lib, stdenv, llvm_meta -, buildLlvmTools -, monorepoSrc, runCommand -, cmake -, ninja -, libxml2 -, libllvm -, version -}: - -stdenv.mkDerivation rec { - pname = "lld"; - inherit version; - - # Blank llvm dir just so relative path works - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - mkdir -p "$out/libunwind" - cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" - mkdir -p "$out/llvm" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./gnu-install-dirs.patch - ]; - - nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ libllvm libxml2 ]; - - cmakeFlags = [ - "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - ]; - - # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; - - outputs = [ "out" "lib" "dev" ]; - - meta = llvm_meta // { - homepage = "https://lld.llvm.org/"; - description = "The LLVM linker (unwrapped)"; - longDescription = '' - LLD is a linker from the LLVM project that is a drop-in replacement for - system linkers and runs much faster than them. It also provides features - that are useful for toolchain developers. - The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and - WebAssembly in descending order of completeness. Internally, LLD consists - of several different linkers. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index 66185071f22b7..859caff311695 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -144,7 +144,11 @@ in let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { + patches = [ + ./lld/gnu-install-dirs.patch + ./lld/add-table-base.patch + ]; inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/16/lld/default.nix b/pkgs/development/compilers/llvm/16/lld/default.nix deleted file mode 100644 index 84943e8effce1..0000000000000 --- a/pkgs/development/compilers/llvm/16/lld/default.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ lib, stdenv, llvm_meta -, buildLlvmTools -, monorepoSrc, runCommand -, cmake -, ninja -, libxml2 -, libllvm -, version -}: - -stdenv.mkDerivation rec { - pname = "lld"; - inherit version; - - # Blank llvm dir just so relative path works - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - mkdir -p "$out/libunwind" - cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" - mkdir -p "$out/llvm" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./gnu-install-dirs.patch - ./add-table-base.patch - ]; - - nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ libllvm libxml2 ]; - - cmakeFlags = [ - "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - ]; - - # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; - - outputs = [ "out" "lib" "dev" ]; - - meta = llvm_meta // { - homepage = "https://lld.llvm.org/"; - description = "The LLVM linker (unwrapped)"; - longDescription = '' - LLD is a linker from the LLVM project that is a drop-in replacement for - system linkers and runs much faster than them. It also provides features - that are useful for toolchain developers. - The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and - WebAssembly in descending order of completeness. Internally, LLD consists - of several different linkers. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/17/default.nix b/pkgs/development/compilers/llvm/17/default.nix index c8d9569253450..10f9773657839 100644 --- a/pkgs/development/compilers/llvm/17/default.nix +++ b/pkgs/development/compilers/llvm/17/default.nix @@ -139,7 +139,11 @@ in let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { + patches = [ + ./lld/gnu-install-dirs.patch + ./lld/add-table-base.patch + ]; inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/17/lld/default.nix b/pkgs/development/compilers/llvm/17/lld/default.nix deleted file mode 100644 index 84943e8effce1..0000000000000 --- a/pkgs/development/compilers/llvm/17/lld/default.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ lib, stdenv, llvm_meta -, buildLlvmTools -, monorepoSrc, runCommand -, cmake -, ninja -, libxml2 -, libllvm -, version -}: - -stdenv.mkDerivation rec { - pname = "lld"; - inherit version; - - # Blank llvm dir just so relative path works - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - mkdir -p "$out/libunwind" - cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" - mkdir -p "$out/llvm" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./gnu-install-dirs.patch - ./add-table-base.patch - ]; - - nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ libllvm libxml2 ]; - - cmakeFlags = [ - "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - ]; - - # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; - - outputs = [ "out" "lib" "dev" ]; - - meta = llvm_meta // { - homepage = "https://lld.llvm.org/"; - description = "The LLVM linker (unwrapped)"; - longDescription = '' - LLD is a linker from the LLVM project that is a drop-in replacement for - system linkers and runs much faster than them. It also provides features - that are useful for toolchain developers. - The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and - WebAssembly in descending order of completeness. Internally, LLD consists - of several different linkers. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/18/default.nix b/pkgs/development/compilers/llvm/18/default.nix index dd3000c042594..d58a98f06239a 100644 --- a/pkgs/development/compilers/llvm/18/default.nix +++ b/pkgs/development/compilers/llvm/18/default.nix @@ -139,7 +139,10 @@ in let extraBuildCommands = mkExtraBuildCommands cc; }; - lld = callPackage ./lld { + lld = callPackage ../common/lld { + patches = [ + ./lld/gnu-install-dirs.patch + ]; inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/18/lld/default.nix b/pkgs/development/compilers/llvm/18/lld/default.nix deleted file mode 100644 index 24ff0933dd1d8..0000000000000 --- a/pkgs/development/compilers/llvm/18/lld/default.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ lib, stdenv, llvm_meta -, buildLlvmTools -, monorepoSrc, runCommand -, cmake -, ninja -, libxml2 -, libllvm -, version -}: - -stdenv.mkDerivation rec { - pname = "lld"; - inherit version; - - # Blank llvm dir just so relative path works - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - mkdir -p "$out/libunwind" - cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" - mkdir -p "$out/llvm" - ''; - - sourceRoot = "${src.name}/${pname}"; - - nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ libllvm libxml2 ]; - - patches = [ - ./gnu-install-dirs.patch - ]; - - cmakeFlags = [ - "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" - ]; - - # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; - - outputs = [ "out" "lib" "dev" ]; - - meta = llvm_meta // { - homepage = "https://lld.llvm.org/"; - description = "The LLVM linker (unwrapped)"; - longDescription = '' - LLD is a linker from the LLVM project that is a drop-in replacement for - system linkers and runs much faster than them. It also provides features - that are useful for toolchain developers. - The linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS), and - WebAssembly in descending order of completeness. Internally, LLD consists - of several different linkers. - ''; - }; -} diff --git a/pkgs/development/compilers/llvm/common/lld/default.nix b/pkgs/development/compilers/llvm/common/lld/default.nix index 24ff0933dd1d8..be296be91e770 100644 --- a/pkgs/development/compilers/llvm/common/lld/default.nix +++ b/pkgs/development/compilers/llvm/common/lld/default.nix @@ -1,37 +1,57 @@ -{ lib, stdenv, llvm_meta +{ lib +, stdenv +, llvm_meta +, release_version +, patches ? [] , buildLlvmTools -, monorepoSrc, runCommand +, monorepoSrc ? null +, src ? null +, libunwind ? null +, runCommand , cmake , ninja , libxml2 , libllvm , version }: - -stdenv.mkDerivation rec { +let pname = "lld"; - inherit version; - - # Blank llvm dir just so relative path works - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - mkdir -p "$out/libunwind" - cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" - mkdir -p "$out/llvm" + src' = + if monorepoSrc != null then + runCommand "lld-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + mkdir -p "$out/libunwind" + cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" + mkdir -p "$out/llvm" + '' else src; + + postPatch = lib.optionalString (lib.versions.major release_version == "12") '' + substituteInPlace MachO/CMakeLists.txt --replace \ + '(''${LLVM_MAIN_SRC_DIR}/' '(' + mkdir -p libunwind/include + tar -xf "${libunwind.src}" --wildcards -C libunwind/include --strip-components=2 "libunwind-*/include/" + '' + lib.optionalString (lib.versions.major release_version == "13" && stdenv.isDarwin) '' + substituteInPlace MachO/CMakeLists.txt --replace \ + '(''${LLVM_MAIN_SRC_DIR}/' '(../' ''; +in +stdenv.mkDerivation (rec { + inherit pname version patches; - sourceRoot = "${src.name}/${pname}"; + src = src'; - nativeBuildInputs = [ cmake ninja ]; - buildInputs = [ libllvm libxml2 ]; + sourceRoot = + if lib.versionOlder release_version "13" then null + else "${src.name}/${pname}"; - patches = [ - ./gnu-install-dirs.patch - ]; + nativeBuildInputs = [ cmake ] ++ lib.optional (lib.versionAtLeast release_version "15") ninja; + buildInputs = [ libllvm libxml2 ]; - cmakeFlags = [ + cmakeFlags = lib.optionals (lib.versionOlder release_version "14") [ + "-DLLVM_CONFIG_PATH=${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}" + ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ "-DLLD_INSTALL_PACKAGE_DIR=${placeholder "dev"}/lib/cmake/lld" ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "-DLLVM_TABLEGEN_EXE=${buildLlvmTools.llvm}/bin/llvm-tblgen" @@ -54,4 +74,4 @@ stdenv.mkDerivation rec { of several different linkers. ''; }; -} +} // (if (postPatch == "" && lib.versions.major release_version != "13") then {} else { inherit postPatch; })) diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index bbc018978cb5c..94214365cc61d 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -145,6 +145,9 @@ in let }; lld = callPackage ../common/lld { + patches = [ + ./lld/gnu-install-dirs.patch + ]; inherit llvm_meta; }; diff --git a/pkgs/development/compilers/llvm/common/lld/gnu-install-dirs.patch b/pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch similarity index 100% rename from pkgs/development/compilers/llvm/common/lld/gnu-install-dirs.patch rename to pkgs/development/compilers/llvm/git/lld/gnu-install-dirs.patch From ec372cb0ad471d5d2178eceb518d58b898b6297f Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sat, 6 Apr 2024 22:39:35 -0700 Subject: [PATCH 09/11] llvmPackages_{12,13,14,15,16,17,18,git}: use common openmp --- .../development/compilers/llvm/12/default.nix | 11 ++- .../compilers/llvm/12/openmp/default.nix | 48 ------------ .../development/compilers/llvm/13/default.nix | 10 ++- .../compilers/llvm/13/openmp/default.nix | 53 ------------- .../development/compilers/llvm/14/default.nix | 6 +- .../compilers/llvm/14/openmp/default.nix | 69 ----------------- .../development/compilers/llvm/15/default.nix | 7 +- .../compilers/llvm/15/openmp/default.nix | 74 ------------------- .../development/compilers/llvm/16/default.nix | 7 +- .../compilers/llvm/16/openmp/default.nix | 74 ------------------- .../development/compilers/llvm/17/default.nix | 7 +- .../compilers/llvm/17/openmp/default.nix | 74 ------------------- .../development/compilers/llvm/18/default.nix | 6 +- .../compilers/llvm/18/openmp/default.nix | 73 ------------------ .../compilers/llvm/common/openmp/default.nix | 71 ++++++++++-------- .../compilers/llvm/git/default.nix | 4 + .../openmp/fix-find-tool.patch | 0 .../openmp/run-lit-directly.patch | 0 18 files changed, 93 insertions(+), 501 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/12/openmp/default.nix delete mode 100644 pkgs/development/compilers/llvm/13/openmp/default.nix delete mode 100644 pkgs/development/compilers/llvm/14/openmp/default.nix delete mode 100644 pkgs/development/compilers/llvm/15/openmp/default.nix delete mode 100644 pkgs/development/compilers/llvm/16/openmp/default.nix delete mode 100644 pkgs/development/compilers/llvm/17/openmp/default.nix delete mode 100644 pkgs/development/compilers/llvm/18/openmp/default.nix rename pkgs/development/compilers/llvm/{common => git}/openmp/fix-find-tool.patch (100%) rename pkgs/development/compilers/llvm/{common => git}/openmp/run-lit-directly.patch (100%) diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index 36d4d638fe581..4351eeef6719e 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -1,5 +1,6 @@ { lowPrio, newScope, pkgs, lib, stdenv, cmake , preLibcCrossHeaders +, fetchpatch , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross @@ -268,7 +269,15 @@ let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { + src = fetch "openmp" "14dh0r6h2xh747ffgnsl4z08h0ri04azi9vf79cbz7ma1r27kzk0"; + patches = [ + # Fix cross. + (fetchpatch { + url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch"; + hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A="; + }) + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/12/openmp/default.nix b/pkgs/development/compilers/llvm/12/openmp/default.nix deleted file mode 100644 index 6040f3d1621a9..0000000000000 --- a/pkgs/development/compilers/llvm/12/openmp/default.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ lib -, stdenv -, llvm_meta -, fetch -, fetchpatch -, cmake -, llvm -, targetLlvm -, perl -, version -}: - -stdenv.mkDerivation rec { - pname = "openmp"; - inherit version; - - src = fetch pname "14dh0r6h2xh747ffgnsl4z08h0ri04azi9vf79cbz7ma1r27kzk0"; - - patches = [ - # Fix cross. - (fetchpatch { - url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch"; - hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A="; - }) - ]; - - patchFlags = [ "-p2" ]; - - nativeBuildInputs = [ cmake perl ]; - buildInputs = [ - (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) - ]; - - meta = llvm_meta // { - homepage = "https://openmp.llvm.org/"; - description = "Support for the OpenMP language"; - longDescription = '' - The OpenMP subproject of LLVM contains the components required to build an - executable OpenMP program that are outside the compiler itself. - Contains the code for the runtime library against which code compiled by - "clang -fopenmp" must be linked before it can run and the library that - supports offload to target devices. - ''; - # "All of the code is dual licensed under the MIT license and the UIUC - # License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/13/default.nix b/pkgs/development/compilers/llvm/13/default.nix index 0f4785c32d0a2..d89a624b41521 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -1,5 +1,6 @@ { lowPrio, newScope, pkgs, lib, stdenv, cmake , preLibcCrossHeaders +, fetchpatch , libxml2, python3, isl, fetchFromGitHub, overrideCC, wrapCCWith, wrapBintoolsWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross @@ -307,7 +308,14 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { + patches = [ + # Fix cross. + (fetchpatch { + url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch"; + hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A="; + }) + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/13/openmp/default.nix b/pkgs/development/compilers/llvm/13/openmp/default.nix deleted file mode 100644 index 7b461df438f9a..0000000000000 --- a/pkgs/development/compilers/llvm/13/openmp/default.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ lib -, stdenv -, llvm_meta -, src -, fetchpatch -, cmake -, llvm -, targetLlvm -, perl -, version -}: - -stdenv.mkDerivation rec { - pname = "openmp"; - inherit version; - - inherit src; - sourceRoot = "${src.name}/${pname}"; - - patches = [ - # Fix cross. - (fetchpatch { - url = "https://github.com/llvm/llvm-project/commit/5e2358c781b85a18d1463fd924d2741d4ae5e42e.patch"; - hash = "sha256-UxIlAifXnexF/MaraPW0Ut6q+sf3e7y1fMdEv1q103A="; - }) - ]; - - patchFlags = [ "-p2" ]; - - nativeBuildInputs = [ cmake perl ]; - buildInputs = [ - (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) - ]; - - cmakeFlags = [ - "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL currently fails - ]; - - meta = llvm_meta // { - homepage = "https://openmp.llvm.org/"; - description = "Support for the OpenMP language"; - longDescription = '' - The OpenMP subproject of LLVM contains the components required to build an - executable OpenMP program that are outside the compiler itself. - Contains the code for the runtime library against which code compiled by - "clang -fopenmp" must be linked before it can run and the library that - supports offload to target devices. - ''; - # "All of the code is dual licensed under the MIT license and the UIUC - # License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/14/default.nix b/pkgs/development/compilers/llvm/14/default.nix index 93b00d2733840..d4ff09d0e00c4 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -306,7 +306,11 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { + patches = [ + ./openmp/gnu-install-dirs.patch + ./openmp/run-lit-directly.patch + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/14/openmp/default.nix b/pkgs/development/compilers/llvm/14/openmp/default.nix deleted file mode 100644 index d1c6a46b4d693..0000000000000 --- a/pkgs/development/compilers/llvm/14/openmp/default.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ lib -, stdenv -, llvm_meta -, monorepoSrc -, runCommand -, cmake -, llvm -, targetLlvm -, lit -, clang-unwrapped -, perl -, pkg-config -, version -}: - -stdenv.mkDerivation rec { - pname = "openmp"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./gnu-install-dirs.patch - ./run-lit-directly.patch - ]; - - outputs = [ "out" "dev" ]; - - nativeBuildInputs = [ cmake perl pkg-config lit ]; - buildInputs = [ - (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) - ]; - - # Unsup:Pass:XFail:Fail - # 26:267:16:8 - doCheck = false; - checkTarget = "check-openmp"; - - preCheck = '' - patchShebangs ../tools/archer/tests/deflake.bash - ''; - - cmakeFlags = [ - "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" - "-DOPT_TOOL=${llvm}/bin/opt" - "-DLINK_TOOL=${llvm}/bin/llvm-link" - ]; - - meta = llvm_meta // { - homepage = "https://openmp.llvm.org/"; - description = "Support for the OpenMP language"; - longDescription = '' - The OpenMP subproject of LLVM contains the components required to build an - executable OpenMP program that are outside the compiler itself. - Contains the code for the runtime library against which code compiled by - "clang -fopenmp" must be linked before it can run and the library that - supports offload to target devices. - ''; - # "All of the code is dual licensed under the MIT license and the UIUC - # License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix index 3d16cb5ab5547..4113976713613 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -323,7 +323,12 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { + patches = [ + ./openmp/fix-find-tool.patch + ./openmp/gnu-install-dirs.patch + ./openmp/run-lit-directly.patch + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/15/openmp/default.nix b/pkgs/development/compilers/llvm/15/openmp/default.nix deleted file mode 100644 index d51335436ad23..0000000000000 --- a/pkgs/development/compilers/llvm/15/openmp/default.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ lib -, stdenv -, llvm_meta -, monorepoSrc -, runCommand -, cmake -, ninja -, llvm -, targetLlvm -, lit -, clang-unwrapped -, perl -, pkg-config -, xcbuild -, version -}: - -stdenv.mkDerivation rec { - pname = "openmp"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./fix-find-tool.patch - ./gnu-install-dirs.patch - ./run-lit-directly.patch - ]; - - outputs = [ "out" "dev" ]; - - nativeBuildInputs = [ cmake ninja perl pkg-config lit ]; - buildInputs = [ - (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) - ]; - - nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun; - - # Unsup:Pass:XFail:Fail - # 26:267:16:8 - doCheck = false; - checkTarget = "check-openmp"; - - preCheck = '' - patchShebangs ../tools/archer/tests/deflake.bash - ''; - - cmakeFlags = [ - "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" - "-DOPT_TOOL=${llvm}/bin/opt" - "-DLINK_TOOL=${llvm}/bin/llvm-link" - ]; - - meta = llvm_meta // { - homepage = "https://openmp.llvm.org/"; - description = "Support for the OpenMP language"; - longDescription = '' - The OpenMP subproject of LLVM contains the components required to build an - executable OpenMP program that are outside the compiler itself. - Contains the code for the runtime library against which code compiled by - "clang -fopenmp" must be linked before it can run and the library that - supports offload to target devices. - ''; - # "All of the code is dual licensed under the MIT license and the UIUC - # License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/16/default.nix b/pkgs/development/compilers/llvm/16/default.nix index 859caff311695..a5e126f127785 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -339,7 +339,12 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { + patches = [ + ./openmp/fix-find-tool.patch + ./openmp/gnu-install-dirs.patch + ./openmp/run-lit-directly.patch + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/16/openmp/default.nix b/pkgs/development/compilers/llvm/16/openmp/default.nix deleted file mode 100644 index d51335436ad23..0000000000000 --- a/pkgs/development/compilers/llvm/16/openmp/default.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ lib -, stdenv -, llvm_meta -, monorepoSrc -, runCommand -, cmake -, ninja -, llvm -, targetLlvm -, lit -, clang-unwrapped -, perl -, pkg-config -, xcbuild -, version -}: - -stdenv.mkDerivation rec { - pname = "openmp"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./fix-find-tool.patch - ./gnu-install-dirs.patch - ./run-lit-directly.patch - ]; - - outputs = [ "out" "dev" ]; - - nativeBuildInputs = [ cmake ninja perl pkg-config lit ]; - buildInputs = [ - (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) - ]; - - nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun; - - # Unsup:Pass:XFail:Fail - # 26:267:16:8 - doCheck = false; - checkTarget = "check-openmp"; - - preCheck = '' - patchShebangs ../tools/archer/tests/deflake.bash - ''; - - cmakeFlags = [ - "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" - "-DOPT_TOOL=${llvm}/bin/opt" - "-DLINK_TOOL=${llvm}/bin/llvm-link" - ]; - - meta = llvm_meta // { - homepage = "https://openmp.llvm.org/"; - description = "Support for the OpenMP language"; - longDescription = '' - The OpenMP subproject of LLVM contains the components required to build an - executable OpenMP program that are outside the compiler itself. - Contains the code for the runtime library against which code compiled by - "clang -fopenmp" must be linked before it can run and the library that - supports offload to target devices. - ''; - # "All of the code is dual licensed under the MIT license and the UIUC - # License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/17/default.nix b/pkgs/development/compilers/llvm/17/default.nix index 10f9773657839..1ee9dd17ab125 100644 --- a/pkgs/development/compilers/llvm/17/default.nix +++ b/pkgs/development/compilers/llvm/17/default.nix @@ -324,7 +324,12 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { + patches = [ + ./openmp/fix-find-tool.patch + ./openmp/gnu-install-dirs.patch + ./openmp/run-lit-directly.patch + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/17/openmp/default.nix b/pkgs/development/compilers/llvm/17/openmp/default.nix deleted file mode 100644 index d51335436ad23..0000000000000 --- a/pkgs/development/compilers/llvm/17/openmp/default.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ lib -, stdenv -, llvm_meta -, monorepoSrc -, runCommand -, cmake -, ninja -, llvm -, targetLlvm -, lit -, clang-unwrapped -, perl -, pkg-config -, xcbuild -, version -}: - -stdenv.mkDerivation rec { - pname = "openmp"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./fix-find-tool.patch - ./gnu-install-dirs.patch - ./run-lit-directly.patch - ]; - - outputs = [ "out" "dev" ]; - - nativeBuildInputs = [ cmake ninja perl pkg-config lit ]; - buildInputs = [ - (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) - ]; - - nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun; - - # Unsup:Pass:XFail:Fail - # 26:267:16:8 - doCheck = false; - checkTarget = "check-openmp"; - - preCheck = '' - patchShebangs ../tools/archer/tests/deflake.bash - ''; - - cmakeFlags = [ - "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" - "-DOPT_TOOL=${llvm}/bin/opt" - "-DLINK_TOOL=${llvm}/bin/llvm-link" - ]; - - meta = llvm_meta // { - homepage = "https://openmp.llvm.org/"; - description = "Support for the OpenMP language"; - longDescription = '' - The OpenMP subproject of LLVM contains the components required to build an - executable OpenMP program that are outside the compiler itself. - Contains the code for the runtime library against which code compiled by - "clang -fopenmp" must be linked before it can run and the library that - supports offload to target devices. - ''; - # "All of the code is dual licensed under the MIT license and the UIUC - # License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/18/default.nix b/pkgs/development/compilers/llvm/18/default.nix index d58a98f06239a..ffb2a8075342f 100644 --- a/pkgs/development/compilers/llvm/18/default.nix +++ b/pkgs/development/compilers/llvm/18/default.nix @@ -323,7 +323,11 @@ in let stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; - openmp = callPackage ./openmp { + openmp = callPackage ../common/openmp { + patches = [ + ./openmp/fix-find-tool.patch + ./openmp/run-lit-directly.patch + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/18/openmp/default.nix b/pkgs/development/compilers/llvm/18/openmp/default.nix deleted file mode 100644 index e1c3c2379af2a..0000000000000 --- a/pkgs/development/compilers/llvm/18/openmp/default.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ lib -, stdenv -, llvm_meta -, monorepoSrc -, runCommand -, cmake -, ninja -, llvm -, targetLlvm -, lit -, clang-unwrapped -, perl -, pkg-config -, xcbuild -, version -}: - -stdenv.mkDerivation rec { - pname = "openmp"; - inherit version; - - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; - - sourceRoot = "${src.name}/${pname}"; - - patches = [ - ./fix-find-tool.patch - ./run-lit-directly.patch - ]; - - outputs = [ "out" "dev" ]; - - nativeBuildInputs = [ cmake ninja perl pkg-config lit ]; - buildInputs = [ - (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) - ]; - - nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun; - - # Unsup:Pass:XFail:Fail - # 26:267:16:8 - doCheck = false; - checkTarget = "check-openmp"; - - preCheck = '' - patchShebangs ../tools/archer/tests/deflake.bash - ''; - - cmakeFlags = [ - "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" - "-DOPT_TOOL=${llvm}/bin/opt" - "-DLINK_TOOL=${llvm}/bin/llvm-link" - ]; - - meta = llvm_meta // { - homepage = "https://openmp.llvm.org/"; - description = "Support for the OpenMP language"; - longDescription = '' - The OpenMP subproject of LLVM contains the components required to build an - executable OpenMP program that are outside the compiler itself. - Contains the code for the runtime library against which code compiled by - "clang -fopenmp" must be linked before it can run and the library that - supports offload to target devices. - ''; - # "All of the code is dual licensed under the MIT license and the UIUC - # License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/common/openmp/default.nix b/pkgs/development/compilers/llvm/common/openmp/default.nix index e1c3c2379af2a..f6664d2bee516 100644 --- a/pkgs/development/compilers/llvm/common/openmp/default.nix +++ b/pkgs/development/compilers/llvm/common/openmp/default.nix @@ -1,7 +1,10 @@ { lib , stdenv , llvm_meta -, monorepoSrc +, release_version +, patches ? [] +, monorepoSrc ? null +, src ? null , runCommand , cmake , ninja @@ -14,43 +17,47 @@ , xcbuild , version }: - -stdenv.mkDerivation rec { +let pname = "openmp"; - inherit version; + src' = + if monorepoSrc != null then + runCommand "${pname}-src-${version}" {} '' + mkdir -p "$out" + cp -r ${monorepoSrc}/cmake "$out" + cp -r ${monorepoSrc}/${pname} "$out" + '' else src; +in +stdenv.mkDerivation (rec { + inherit pname version patches; - src = runCommand "${pname}-src-${version}" {} '' - mkdir -p "$out" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/${pname} "$out" - ''; + src = src'; - sourceRoot = "${src.name}/${pname}"; + sourceRoot = + if lib.versionOlder release_version "13" then null + else "${src.name}/${pname}"; - patches = [ - ./fix-find-tool.patch - ./run-lit-directly.patch - ]; + outputs = [ "out" ] + ++ lib.optionals (lib.versionAtLeast release_version "14") [ "dev" ]; - outputs = [ "out" "dev" ]; + patchFlags = + if lib.versionOlder release_version "14" then [ "-p2" ] + else null; + + nativeBuildInputs = [ + cmake + ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ + ninja + ] ++ [ perl ] ++ lib.optionals (lib.versionAtLeast release_version "14") [ + pkg-config lit + ]; - nativeBuildInputs = [ cmake ninja perl pkg-config lit ]; buildInputs = [ (if stdenv.buildPlatform == stdenv.hostPlatform then llvm else targetLlvm) ]; - nativeCheckInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun; - - # Unsup:Pass:XFail:Fail - # 26:267:16:8 - doCheck = false; - checkTarget = "check-openmp"; - - preCheck = '' - patchShebangs ../tools/archer/tests/deflake.bash - ''; - - cmakeFlags = [ + cmakeFlags = lib.optionals (lib.versions.major release_version == "13") [ + "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF" # Building the AMDGCN device RTL fails + ] ++ lib.optionals (lib.versionAtLeast release_version "14") [ "-DCLANG_TOOL=${clang-unwrapped}/bin/clang" "-DOPT_TOOL=${llvm}/bin/opt" "-DLINK_TOOL=${llvm}/bin/llvm-link" @@ -70,4 +77,10 @@ stdenv.mkDerivation rec { # License (a BSD-like license)": license = with lib.licenses; [ mit ncsa ]; }; -} +} // (if lib.versionAtLeast release_version "14" then { + doCheck = false; + checkTarget = "check-openmp"; + preCheck = '' + patchShebangs ../tools/archer/tests/deflake.bash + ''; +} else {})) diff --git a/pkgs/development/compilers/llvm/git/default.nix b/pkgs/development/compilers/llvm/git/default.nix index 94214365cc61d..7e4bcf60fe57e 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -329,6 +329,10 @@ in let }; openmp = callPackage ../common/openmp { + patches = [ + ./openmp/fix-find-tool.patch + ./openmp/run-lit-directly.patch + ]; inherit llvm_meta targetLlvm; }; }); diff --git a/pkgs/development/compilers/llvm/common/openmp/fix-find-tool.patch b/pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch similarity index 100% rename from pkgs/development/compilers/llvm/common/openmp/fix-find-tool.patch rename to pkgs/development/compilers/llvm/git/openmp/fix-find-tool.patch diff --git a/pkgs/development/compilers/llvm/common/openmp/run-lit-directly.patch b/pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch similarity index 100% rename from pkgs/development/compilers/llvm/common/openmp/run-lit-directly.patch rename to pkgs/development/compilers/llvm/git/openmp/run-lit-directly.patch From 7ffb2c351d7792d9ea654fd37e6143e33ac3ea5e Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Tue, 9 Apr 2024 22:05:22 -0700 Subject: [PATCH 10/11] llvmPackages_{12,13,14,15,16,17,18}: 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 | 91 +++++++++++++------ 15 files changed, 88 insertions(+), 402 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 diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index 4351eeef6719e..d8b673c70f222 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -263,9 +263,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 95e0962b46891..0000000000000 --- 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 d89a624b41521..89304a951def2 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -303,7 +303,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 d837bc60de370..0000000000000 --- 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 d4ff09d0e00c4..25102a8b3462a 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -301,7 +301,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 c6d9eda5e4749..0000000000000 --- 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 4113976713613..96a1c34f3a0a0 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -318,7 +318,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 1b677a7a2c0d7..0000000000000 --- 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 a5e126f127785..b5a7ade5526c2 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -334,7 +334,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 1b677a7a2c0d7..0000000000000 --- 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 1ee9dd17ab125..e0a13a11a2add 100644 --- a/pkgs/development/compilers/llvm/17/default.nix +++ b/pkgs/development/compilers/llvm/17/default.nix @@ -319,7 +319,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 a3c8e2594f5a7..0000000000000 --- 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 ffb2a8075342f..43aaa34da596a 100644 --- a/pkgs/development/compilers/llvm/18/default.nix +++ b/pkgs/development/compilers/llvm/18/default.nix @@ -318,7 +318,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 e67823ffb85c2..0000000000000 --- 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 index e67823ffb85c2..a6f586773bd34 100644 --- a/pkgs/development/compilers/llvm/common/libunwind/default.nix +++ b/pkgs/development/compilers/llvm/common/libunwind/default.nix @@ -1,44 +1,80 @@ -{ lib, stdenv, llvm_meta, version -, monorepoSrc, runCommand +{ lib +, stdenv +, release_version +, patches ? [] +, src ? null +, llvm_meta +, version +, monorepoSrc ? null +, runCommand , cmake , ninja , python3 +, libcxx , enableShared ? !stdenv.hostPlatform.isStatic }: - -stdenv.mkDerivation rec { +let 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" + src' = if monorepoSrc != null then + runCommand "${pname}-src-${version}" {} (if lib.versionAtLeast release_version "15" then '' + 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" + '' else '' + 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" + '') else src; + + postUnpack = lib.optionalString (lib.versions.major release_version == "12") '' + ln -s ${libcxx.src}/libcxx . + ln -s ${libcxx.src}/llvm . ''; - sourceRoot = "${src.name}/runtimes"; + prePatch = lib.optionalString (lib.versionAtLeast release_version "15") '' + cd ../${pname} + chmod -R u+w . + ''; - postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) '' + postPatch = lib.optionalString (lib.versionAtLeast release_version "15") '' + cd ../runtimes + ''; + + postInstall = lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin && lib.versionAtLeast release_version "15") '' # 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.versions.major release_version == "14" then "${src.name}/${pname}" + else "${src.name}/runtimes"; outputs = [ "out" "dev" ]; - nativeBuildInputs = [ cmake ninja python3 ]; + nativeBuildInputs = [ cmake ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ + ninja python3 + ]; - cmakeFlags = [ - "-DLLVM_ENABLE_RUNTIMES=libunwind" - ] ++ lib.optional (!enableShared) "-DLIBUNWIND_ENABLE_SHARED=OFF"; + 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 @@ -51,4 +87,7 @@ stdenv.mkDerivation rec { dependency of other runtimes. ''; }; -} +} // (if postUnpack != "" then { inherit postUnpack; } else {}) + // (if postInstall != "" then { inherit postInstall; } else {}) + // (if prePatch != "" then { inherit prePatch; } else {}) + // (if postPatch != "" then { inherit postPatch; } else {})) From 7462e89f324fd8709019f0014494bd42eb7befe0 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Wed, 10 Apr 2024 23:45:40 -0700 Subject: [PATCH 11/11] llvmPackages_12: use common libcxx --- .../development/compilers/llvm/12/default.nix | 32 +++- .../compilers/llvm/12/libcxx/default.nix | 139 ------------------ .../compilers/llvm/common/libcxx/default.nix | 79 +++++----- 3 files changed, 72 insertions(+), 178 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/12/libcxx/default.nix diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index d8b673c70f222..1d32ea8eb0e0a 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -1,6 +1,6 @@ { lowPrio, newScope, pkgs, lib, stdenv, cmake , preLibcCrossHeaders -, fetchpatch +, substitute, fetchFromGitHub, fetchpatch , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith , buildLlvmTools # tools, but from the previous stage, for cross , targetLlvmLibraries # libraries, but from the next stage, for cross @@ -258,7 +258,35 @@ let libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; - libcxx = callPackage ./libcxx { + libcxx = callPackage ../common/libcxx { + src = fetchFromGitHub { + owner = "llvm"; + repo = "llvm-project"; + rev = "refs/tags/llvmorg-${version}"; + sparseCheckout = [ + "libcxx" + "libcxxabi" + "llvm/cmake" + "llvm/utils" + "runtimes" + ]; + hash = "sha256-etxgXIdWxMTmbZ83Hsc0w6Jt5OSQSUEPVEWqLkHsNBY="; + }; + patches = [ + (substitute { + src = ../common/libcxxabi/wasm.patch; + replacements = [ + "--replace-fail" "/cmake/" "/llvm/cmake/" + ]; + }) + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ + (substitute { + src = ../common/libcxx/libcxx-0001-musl-hacks.patch; + replacements = [ + "--replace-fail" "/include/" "/libcxx/include/" + ]; + }) + ]; inherit llvm_meta; stdenv = overrideCC stdenv buildLlvmTools.clangNoLibcxx; }; diff --git a/pkgs/development/compilers/llvm/12/libcxx/default.nix b/pkgs/development/compilers/llvm/12/libcxx/default.nix deleted file mode 100644 index 7c6174711456c..0000000000000 --- a/pkgs/development/compilers/llvm/12/libcxx/default.nix +++ /dev/null @@ -1,139 +0,0 @@ -{ lib, stdenv, llvm_meta -, fetchFromGitHub, runCommand, substitute -, cmake, lndir, ninja, python3, fixDarwinDylibNames, version -, cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null -, libcxxrt, libunwind -, enableShared ? !stdenv.hostPlatform.isStatic -}: - -# external cxxabi is not supported on Darwin as the build will not link libcxx -# properly and not re-export the cxxabi symbols into libcxx -# https://github.com/NixOS/nixpkgs/issues/166205 -# https://github.com/NixOS/nixpkgs/issues/269548 -assert cxxabi == null || !stdenv.hostPlatform.isDarwin; -let - basename = "libcxx"; - cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}"; - runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi"; - - # Note: useLLVM is likely false for Darwin but true under pkgsLLVM - useLLVM = stdenv.hostPlatform.useLLVM or false; - - cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ - "-DLIBCXXABI_USE_COMPILER_RT=ON" - "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" - ] ++ lib.optionals stdenv.hostPlatform.isWasm [ - "-DLIBCXXABI_ENABLE_THREADS=OFF" - "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optionals (!enableShared) [ - "-DLIBCXXABI_ENABLE_SHARED=OFF" - ]; - - cxxCMakeFlags = [ - "-DLIBCXX_CXX_ABI=${cxxabiName}" - ] ++ lib.optionals (cxxabi != null) [ - "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include" - ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [ - "-DLIBCXX_HAS_MUSL_LIBC=1" - ] ++ lib.optionals useLLVM [ - "-DLIBCXX_USE_COMPILER_RT=ON" - ] ++ lib.optionals stdenv.hostPlatform.isWasm [ - "-DLIBCXX_ENABLE_THREADS=OFF" - "-DLIBCXX_ENABLE_FILESYSTEM=OFF" - "-DLIBCXX_ENABLE_EXCEPTIONS=OFF" - ] ++ lib.optionals (!enableShared) [ - "-DLIBCXX_ENABLE_SHARED=OFF" - ]; - - cmakeFlags = [ - "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}" - ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ - # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib, - # but that does not appear to be the case for example when building - # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc). - "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib" - "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib" - ] ++ lib.optionals stdenv.hostPlatform.isWasm [ - "-DCMAKE_C_COMPILER_WORKS=ON" - "-DCMAKE_CXX_COMPILER_WORKS=ON" - "-DUNIX=ON" # Required otherwise libc++ fails to detect the correct linker - ] ++ cxxCMakeFlags - ++ lib.optionals (cxxabi == null) cxxabiCMakeFlags; - -in - -stdenv.mkDerivation rec { - pname = basename; - inherit version cmakeFlags; - - src = fetchFromGitHub { - owner = "llvm"; - repo = "llvm-project"; - rev = "refs/tags/llvmorg-${version}"; - sparseCheckout = [ - "libcxx" - "libcxxabi" - "llvm/cmake" - "llvm/utils" - "runtimes" - ]; - hash = "sha256-etxgXIdWxMTmbZ83Hsc0w6Jt5OSQSUEPVEWqLkHsNBY="; - }; - - outputs = [ "out" "dev" ]; - - patches = [ - (substitute { - src = ../../common/libcxxabi/wasm.patch; - replacements = [ - "--replace-fail" "/cmake/" "/llvm/cmake/" - ]; - }) - ] ++ lib.optionals stdenv.hostPlatform.isMusl [ - (substitute { - src = ../../common/libcxx/libcxx-0001-musl-hacks.patch; - replacements = [ - "--replace-fail" "/include/" "/libcxx/include/" - ]; - }) - ]; - - postPatch = '' - cd runtimes - ''; - - preConfigure = lib.optionalString stdenv.hostPlatform.isMusl '' - patchShebangs utils/cat_files.py - ''; - - nativeBuildInputs = [ cmake ninja python3 ] - ++ lib.optional stdenv.isDarwin fixDarwinDylibNames - ++ lib.optional (cxxabi != null) lndir; - - buildInputs = [ cxxabi ] - ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ libunwind ]; - - # libc++.so is a linker script which expands to multiple libraries, - # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't - # support linker scripts so the external cxxabi needs to be symlinked in - postInstall = lib.optionalString (cxxabi != null) '' - lndir ${lib.getDev cxxabi}/include $out/include/c++/v1 - lndir ${lib.getLib cxxabi}/lib $out/lib - ''; - - passthru = { - isLLVM = true; - }; - - meta = llvm_meta // { - homepage = "https://libcxx.llvm.org/"; - description = "C++ standard library"; - longDescription = '' - libc++ is an implementation of the C++ standard library, targeting C++11, - C++14 and above. - ''; - # "All of the code in libc++ is dual licensed under the MIT license and the - # UIUC License (a BSD-like license)": - license = with lib.licenses; [ mit ncsa ]; - }; -} diff --git a/pkgs/development/compilers/llvm/common/libcxx/default.nix b/pkgs/development/compilers/llvm/common/libcxx/default.nix index d6c304c0b476a..79f46402f4e01 100644 --- a/pkgs/development/compilers/llvm/common/libcxx/default.nix +++ b/pkgs/development/compilers/llvm/common/libcxx/default.nix @@ -1,8 +1,21 @@ -{ lib, stdenv, llvm_meta -, monorepoSrc, runCommand -, cmake, lndir, ninja, python3, fixDarwinDylibNames, version +{ lib +, stdenv +, llvm_meta +, release_version +, monorepoSrc ? null +, src ? null +, patches ? [] +, runCommand +, substitute +, cmake +, lndir +, ninja +, python3 +, fixDarwinDylibNames +, version , cxxabi ? if stdenv.hostPlatform.isFreeBSD then libcxxrt else null -, libcxxrt, libunwind +, libcxxrt +, libunwind , enableShared ? !stdenv.hostPlatform.isStatic }: @@ -13,17 +26,27 @@ assert cxxabi == null || !stdenv.hostPlatform.isDarwin; let basename = "libcxx"; + pname = basename; cxxabiName = "lib${if cxxabi == null then "cxxabi" else cxxabi.libName}"; runtimes = [ "libcxx" ] ++ lib.optional (cxxabi == null) "libcxxabi"; # Note: useLLVM is likely false for Darwin but true under pkgsLLVM useLLVM = stdenv.hostPlatform.useLLVM or false; - cxxabiCMakeFlags = [ - "-DLIBCXXABI_USE_LLVM_UNWINDER=OFF" - ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ - "-DLIBCXXABI_ADDITIONAL_LIBRARIES=unwind" + src' = if monorepoSrc != null then + runCommand "${pname}-src-${version}" {} ('' + mkdir -p "$out/llvm" + cp -r ${monorepoSrc}/libcxx "$out" + cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" + cp -r ${monorepoSrc}/llvm/utils "$out/llvm" + cp -r ${monorepoSrc}/runtimes "$out" + '' + lib.optionalString (cxxabi == null) '' + cp -r ${monorepoSrc}/libcxxabi "$out" + '') else src; + + cxxabiCMakeFlags = lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ "-DLIBCXXABI_USE_COMPILER_RT=ON" + "-DLIBCXXABI_USE_LLVM_UNWINDER=ON" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXXABI_ENABLE_THREADS=OFF" "-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF" @@ -37,16 +60,8 @@ let "-DLIBCXX_CXX_ABI_INCLUDE_PATHS=${lib.getDev cxxabi}/include" ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.isWasi) [ "-DLIBCXX_HAS_MUSL_LIBC=1" - ] ++ lib.optionals (lib.versionAtLeast version "18" && !useLLVM && stdenv.hostPlatform.libc == "glibc" && !stdenv.hostPlatform.isStatic) [ - "-DLIBCXX_ADDITIONAL_LIBRARIES=gcc_s" ] ++ lib.optionals useLLVM [ "-DLIBCXX_USE_COMPILER_RT=ON" - # There's precedent for this in llvm-project/libcxx/cmake/caches. - # In a monorepo build you might do the following in the libcxxabi build: - # -DLLVM_ENABLE_PROJECTS=libcxxabi;libunwinder - # -DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=On - # libcxx appears to require unwind and doesn't pull it in via other means. - "-DLIBCXX_ADDITIONAL_LIBRARIES=unwind" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DLIBCXX_ENABLE_THREADS=OFF" "-DLIBCXX_ENABLE_FILESYSTEM=OFF" @@ -57,6 +72,12 @@ let cmakeFlags = [ "-DLLVM_ENABLE_RUNTIMES=${lib.concatStringsSep ";" runtimes}" + ] ++ lib.optionals (useLLVM && !stdenv.hostPlatform.isWasm) [ + # libcxxabi's CMake looks as though it treats -nostdlib++ as implying -nostdlib, + # but that does not appear to be the case for example when building + # pkgsLLVM.libcxxabi (which uses clangNoCompilerRtWithLibc). + "-DCMAKE_EXE_LINKER_FLAGS=-nostdlib" + "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib" ] ++ lib.optionals stdenv.hostPlatform.isWasm [ "-DCMAKE_C_COMPILER_WORKS=ON" "-DCMAKE_CXX_COMPILER_WORKS=ON" @@ -67,27 +88,11 @@ let in stdenv.mkDerivation rec { - pname = basename; - inherit version cmakeFlags; - - src = runCommand "${pname}-src-${version}" {} ('' - mkdir -p "$out/llvm" - cp -r ${monorepoSrc}/cmake "$out" - cp -r ${monorepoSrc}/libcxx "$out" - cp -r ${monorepoSrc}/llvm/cmake "$out/llvm" - cp -r ${monorepoSrc}/llvm/utils "$out/llvm" - cp -r ${monorepoSrc}/third-party "$out" - cp -r ${monorepoSrc}/runtimes "$out" - '' + lib.optionalString (cxxabi == null) '' - cp -r ${monorepoSrc}/libcxxabi "$out" - ''); + inherit pname version cmakeFlags patches; - outputs = [ "out" "dev" ]; + src = src'; - patches = lib.optionals (stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [ - # https://github.com/llvm/llvm-project/issues/64226 - ./0001-darwin-10.12-mbstate_t-fix.patch - ]; + outputs = [ "out" "dev" ]; postPatch = '' cd runtimes @@ -108,8 +113,8 @@ stdenv.mkDerivation rec { # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't # support linker scripts so the external cxxabi needs to be symlinked in postInstall = lib.optionalString (cxxabi != null) '' - lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1 - lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib + lndir ${lib.getDev cxxabi}/include $out/include/c++/v1 + lndir ${lib.getLib cxxabi}/lib $out/lib ''; passthru = {