From 1572ec6bb122d5f28e9f3af1c7fd8b24ce3a0dd3 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 28 Mar 2024 10:20:08 -0700 Subject: llvmPackages_{12,13,14,15,16,17,18,git}: use common lld --- pkgs/development/compilers/llvm/12/default.nix | 6 +- pkgs/development/compilers/llvm/12/lld/default.nix | 54 --------------- pkgs/development/compilers/llvm/13/default.nix | 5 +- pkgs/development/compilers/llvm/13/lld/default.nix | 55 ---------------- pkgs/development/compilers/llvm/14/default.nix | 6 +- pkgs/development/compilers/llvm/14/lld/default.nix | 58 ---------------- pkgs/development/compilers/llvm/15/default.nix | 5 +- pkgs/development/compilers/llvm/15/lld/default.nix | 57 ---------------- pkgs/development/compilers/llvm/16/default.nix | 6 +- pkgs/development/compilers/llvm/16/lld/default.nix | 58 ---------------- pkgs/development/compilers/llvm/17/default.nix | 6 +- pkgs/development/compilers/llvm/17/lld/default.nix | 58 ---------------- pkgs/development/compilers/llvm/18/default.nix | 5 +- pkgs/development/compilers/llvm/18/lld/default.nix | 57 ---------------- .../compilers/llvm/common/lld/default.nix | 77 ++++++++++++++++++++++ pkgs/development/compilers/llvm/git/default.nix | 5 +- .../development/compilers/llvm/git/lld/default.nix | 57 ---------------- 17 files changed, 113 insertions(+), 462 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 create mode 100644 pkgs/development/compilers/llvm/common/lld/default.nix delete mode 100644 pkgs/development/compilers/llvm/git/lld/default.nix (limited to 'pkgs/development/compilers') diff --git a/pkgs/development/compilers/llvm/12/default.nix b/pkgs/development/compilers/llvm/12/default.nix index d35d463f0bb65..d8b673c70f222 100644 --- a/pkgs/development/compilers/llvm/12/default.nix +++ b/pkgs/development/compilers/llvm/12/default.nix @@ -115,7 +115,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 2f314e67bf906..e93fb1bf29440 100644 --- a/pkgs/development/compilers/llvm/13/default.nix +++ b/pkgs/development/compilers/llvm/13/default.nix @@ -140,7 +140,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 158cd60c03d2e..687deb6ead89b 100644 --- a/pkgs/development/compilers/llvm/14/default.nix +++ b/pkgs/development/compilers/llvm/14/default.nix @@ -136,7 +136,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 3c4d656a8f322..52ab1783b876b 100644 --- a/pkgs/development/compilers/llvm/15/default.nix +++ b/pkgs/development/compilers/llvm/15/default.nix @@ -141,7 +141,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 2028b48bd0803..168c288d49a3c 100644 --- a/pkgs/development/compilers/llvm/16/default.nix +++ b/pkgs/development/compilers/llvm/16/default.nix @@ -141,7 +141,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 42888dcc951af..70571b30b3a6e 100644 --- a/pkgs/development/compilers/llvm/17/default.nix +++ b/pkgs/development/compilers/llvm/17/default.nix @@ -136,7 +136,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 f34d4f58a02a5..d5c2140e33e49 100644 --- a/pkgs/development/compilers/llvm/18/default.nix +++ b/pkgs/development/compilers/llvm/18/default.nix @@ -136,7 +136,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 new file mode 100644 index 0000000000000..be296be91e770 --- /dev/null +++ b/pkgs/development/compilers/llvm/common/lld/default.nix @@ -0,0 +1,77 @@ +{ lib +, stdenv +, llvm_meta +, release_version +, patches ? [] +, buildLlvmTools +, monorepoSrc ? null +, src ? null +, libunwind ? null +, runCommand +, cmake +, ninja +, libxml2 +, libllvm +, version +}: +let + pname = "lld"; + 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; + + src = src'; + + sourceRoot = + if lib.versionOlder release_version "13" then null + else "${src.name}/${pname}"; + + nativeBuildInputs = [ cmake ] ++ lib.optional (lib.versionAtLeast release_version "15") ninja; + buildInputs = [ libllvm libxml2 ]; + + 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" + ]; + + # 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. + ''; + }; +} // (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 cbb380260dee9..d578c2a290e23 100644 --- a/pkgs/development/compilers/llvm/git/default.nix +++ b/pkgs/development/compilers/llvm/git/default.nix @@ -141,7 +141,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/git/lld/default.nix b/pkgs/development/compilers/llvm/git/lld/default.nix deleted file mode 100644 index 24ff0933dd1d8..0000000000000 --- a/pkgs/development/compilers/llvm/git/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. - ''; - }; -} -- cgit 1.4.1