diff --git a/pkgs/development/tools/mold/default.nix b/pkgs/development/tools/mold/default.nix index 63a2fd581269..1d4a64d4467e 100644 --- a/pkgs/development/tools/mold/default.nix +++ b/pkgs/development/tools/mold/default.nix @@ -1,48 +1,54 @@ -{ stdenv +{ lib +, stdenv , fetchFromGitHub -, lib -, autoPatchelfHook , cmake -, llvmPackages_latest -, xxHash -, zlib +, mimalloc +, ninja , openssl -, nix-update-script +, zlib +, testers +, mold }: stdenv.mkDerivation rec { pname = "mold"; - version = "1.4.0"; + version = "1.4.2"; src = fetchFromGitHub { owner = "rui314"; repo = pname; rev = "v${version}"; - sha256 = "sha256-d1rSmDPiVHpYbDPWQKkDhcJJklKlM1+vGdzvjICTT14="; + hash = "sha256-omi4vx8KDpgZ/y3MvE5c/9MxSLXIA4IHJAMue3XpfD8="; }; - buildInputs = [ zlib openssl ]; - nativeBuildInputs = [ autoPatchelfHook cmake xxHash ]; + nativeBuildInputs = [ cmake ninja ]; - enableParallelBuilding = true; - dontUseCmakeConfigure = true; - EXTRA_LDFLAGS = "-fuse-ld=${llvmPackages_latest.lld}/bin/ld.lld"; - LTO = 1; - makeFlags = [ "PREFIX=${placeholder "out"}" ]; + buildInputs = [ openssl zlib ] + ++ lib.optionals (!stdenv.isDarwin) [ mimalloc ]; - passthru = { - updateScript = nix-update-script { - attrPath = pname; - }; - }; + postPatch = '' + sed -i CMakeLists.txt -e '/.*set(DEST\ .*/d' + ''; + + cmakeFlags = [ "-DMOLD_USE_SYSTEM_MIMALLOC:BOOL=ON" ]; + + NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [ "-faligned-allocation" ]; + + passthru.tests.version = testers.testVersion { package = mold; }; meta = with lib; { - description = "A high performance drop-in replacement for existing unix linkers"; + description = "A faster drop-in replacement for existing Unix linkers"; + longDescription = '' + mold is a faster drop-in replacement for existing Unix linkers. It is + several times faster than the LLVM lld linker. mold is designed to + increase developer productivity by reducing build time, especially in + rapid debug-edit-rebuild cycles. + ''; homepage = "https://github.com/rui314/mold"; - license = lib.licenses.agpl3Plus; - maintainers = with maintainers; [ nitsky ]; + license = licenses.agpl3Plus; + maintainers = with maintainers; [ azahi nitsky ]; platforms = platforms.unix; - # error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on macOS 10.14 or newer - broken = stdenv.isAarch64 || stdenv.isDarwin; + # https://github.com/NixOS/nixpkgs/pull/189712#issuecomment-1237791234 + broken = (stdenv.isLinux && stdenv.isAarch64); }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 37c22405eb3e..f13d8e8bf115 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -16879,7 +16879,7 @@ with pkgs; modd = callPackage ../development/tools/modd { }; mold = callPackage ../development/tools/mold { - stdenv = llvmPackages_latest.stdenv; + inherit (llvmPackages) stdenv; }; msgpack-tools = callPackage ../development/tools/msgpack-tools { };