From 80f5345be0e7ae7801593eb74fe9a3daffdc0a1e Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sun, 30 Mar 2025 21:17:37 -0700 Subject: [PATCH] llvmPackages_{12,13,14,15,16,17,18,19,20,git}.lld: nixfmt --- .../compilers/llvm/common/lld/default.nix | 96 +++++++++++-------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/pkgs/development/compilers/llvm/common/lld/default.nix b/pkgs/development/compilers/llvm/common/lld/default.nix index bae64b0dfc79..ea5fe0e4e9cf 100644 --- a/pkgs/development/compilers/llvm/common/lld/default.nix +++ b/pkgs/development/compilers/llvm/common/lld/default.nix @@ -1,19 +1,20 @@ -{ lib -, stdenv -, llvm_meta -, release_version -, buildLlvmTools -, monorepoSrc ? null -, src ? null -, runCommand -, cmake -, ninja -, libxml2 -, libllvm -, version -, devExtraCmakeFlags ? [] -, getVersionFile -, fetchpatch +{ + lib, + stdenv, + llvm_meta, + release_version, + buildLlvmTools, + monorepoSrc ? null, + src ? null, + runCommand, + cmake, + ninja, + libxml2, + libllvm, + version, + devExtraCmakeFlags ? [ ], + getVersionFile, + fetchpatch, }: stdenv.mkDerivation (finalAttrs: { pname = "lld"; @@ -21,16 +22,22 @@ stdenv.mkDerivation (finalAttrs: { src = if monorepoSrc != null then - runCommand "lld-src-${version}" { inherit (monorepoSrc) passthru; } ('' - mkdir -p "$out" - '' + lib.optionalString (lib.versionAtLeast release_version "14") '' - cp -r ${monorepoSrc}/cmake "$out" - '' + '' - cp -r ${monorepoSrc}/lld "$out" - mkdir -p "$out/libunwind" - cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" - mkdir -p "$out/llvm" - '') else src; + runCommand "lld-src-${version}" { inherit (monorepoSrc) passthru; } ( + '' + mkdir -p "$out" + '' + + lib.optionalString (lib.versionAtLeast release_version "14") '' + cp -r ${monorepoSrc}/cmake "$out" + '' + + '' + cp -r ${monorepoSrc}/lld "$out" + mkdir -p "$out/libunwind" + cp -r ${monorepoSrc}/libunwind/include "$out/libunwind" + mkdir -p "$out/llvm" + '' + ) + else + src; sourceRoot = "${finalAttrs.src.name}/lld"; @@ -39,9 +46,9 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional (lib.versions.major release_version == "14") ( getVersionFile "lld/fix-root-src-dir.patch" ) - ++ lib.optional ( - lib.versionAtLeast release_version "16" && lib.versionOlder release_version "18" - ) (getVersionFile "lld/add-table-base.patch") + ++ lib.optional (lib.versionAtLeast release_version "16" && lib.versionOlder release_version "18") ( + getVersionFile "lld/add-table-base.patch" + ) ++ lib.optional (lib.versions.major release_version == "18") ( # https://github.com/llvm/llvm-project/pull/97122 fetchpatch { @@ -53,15 +60,24 @@ stdenv.mkDerivation (finalAttrs: { ); nativeBuildInputs = [ cmake ] ++ lib.optional (lib.versionAtLeast release_version "15") ninja; - buildInputs = [ libllvm libxml2 ]; + buildInputs = [ + libllvm + libxml2 + ]; - cmakeFlags = lib.optionals (lib.versionOlder release_version "14") [ - (lib.cmakeFeature "LLVM_CONFIG_PATH" "${libllvm.dev}/bin/llvm-config${lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native"}") - ] ++ lib.optionals (lib.versionAtLeast release_version "15") [ - (lib.cmakeFeature "LLD_INSTALL_PACKAGE_DIR" "${placeholder "dev"}/lib/cmake/lld") - ] ++ [ - (lib.cmakeFeature "LLVM_TABLEGEN_EXE" "${buildLlvmTools.tblgen}/bin/llvm-tblgen") - ] ++ devExtraCmakeFlags; + cmakeFlags = + lib.optionals (lib.versionOlder release_version "14") [ + (lib.cmakeFeature "LLVM_CONFIG_PATH" "${libllvm.dev}/bin/llvm-config${ + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-native" + }") + ] + ++ lib.optionals (lib.versionAtLeast release_version "15") [ + (lib.cmakeFeature "LLD_INSTALL_PACKAGE_DIR" "${placeholder "dev"}/lib/cmake/lld") + ] + ++ [ + (lib.cmakeFeature "LLVM_TABLEGEN_EXE" "${buildLlvmTools.tblgen}/bin/llvm-tblgen") + ] + ++ devExtraCmakeFlags; postPatch = lib.optionalString (lib.versionOlder release_version "14") '' substituteInPlace MachO/CMakeLists.txt --replace-fail \ @@ -71,7 +87,11 @@ stdenv.mkDerivation (finalAttrs: { # 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" ]; + outputs = [ + "out" + "lib" + "dev" + ]; meta = llvm_meta // { homepage = "https://lld.llvm.org/";