From 7319edcda5bbd9de6b83b79b6484f4a848b9277b Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 29 Jan 2022 15:54:41 -0300 Subject: [PATCH] 7zz: compile optimized assembly code for x86_64 Use uasm to compile the optimized code instead of generic C code for faster operations. Before: ``` 7zz x 10.83s user 0.40s system 98% cpu 11.439 total ``` After: ``` 7zz x 6.87s user 0.40s system 98% cpu 7.395 total ``` --- pkgs/tools/archivers/7zz/default.nix | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/archivers/7zz/default.nix b/pkgs/tools/archivers/7zz/default.nix index f5344a63f494..c93a750e48f0 100644 --- a/pkgs/tools/archivers/7zz/default.nix +++ b/pkgs/tools/archivers/7zz/default.nix @@ -1,5 +1,14 @@ -{ stdenv, lib, fetchurl, p7zip }: +{ stdenv, lib, fetchurl, p7zip, uasm, useUasm ? stdenv.isx86_64 }: +let + inherit (stdenv.hostPlatform) system; + platformSuffix = + if useUasm then + { + x86_64-linux = "_x64"; + }.${system} or (throw "`useUasm` is not supported for system ${system}") + else ""; +in stdenv.mkDerivation rec { pname = "7zz"; version = "21.07"; @@ -11,19 +20,18 @@ stdenv.mkDerivation rec { sourceRoot = "CPP/7zip/Bundles/Alone2"; - # we need https://github.com/nidud/asmc/tree/master/source/asmc/linux in order - # to build with the optimized assembler but that doesn't support building with - # GCC: https://github.com/nidud/asmc/issues/8 - makefile = "../../cmpl_gcc.mak"; # "../../cmpl_gcc_x64.mak"; + makeFlags = lib.optionals useUasm [ "MY_ASM=uasm" ]; - nativeBuildInputs = [ p7zip ]; + makefile = "../../cmpl_gcc${platformSuffix}.mak"; + + nativeBuildInputs = [ p7zip ] ++ lib.optionals useUasm [ uasm ]; enableParallelBuilding = true; installPhase = '' runHook preInstall - install -Dm555 -t $out/bin b/g/7zz + install -Dm555 -t $out/bin b/g${platformSuffix}/7zz install -Dm444 -t $out/share/doc/${pname} ../../../../DOC/*.txt runHook postInstall @@ -37,7 +45,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Command line archiver utility"; - homepage = "https://7zip.org"; + homepage = "https://7-zip.org"; license = licenses.lgpl21Plus; maintainers = with maintainers; [ anna328p peterhoeg ]; platforms = platforms.linux;