From d04e57ea6a39992cb90d59b212576b090328ae60 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Thu, 31 Dec 2015 04:36:54 +0100 Subject: [PATCH] zpaq{,d}: un-break compileFlags and stop using -march=native MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Running zpaq on an older but not ancient 64-bit Intel server aborts with an ‘Illegal instruction’ error. Turns out the build expression was using -march=native to generate distibution binaries... Change this to more conservative, portable settings which should cover ‘all’ CPUs. It may run slightly slower — but that at least implies running. As a nice side effect, all common compile flags are now back in `compileFlags` whence they came, and actually used consistently. --- pkgs/tools/archivers/zpaq/default.nix | 15 ++++++++------- pkgs/tools/archivers/zpaq/zpaqd.nix | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/pkgs/tools/archivers/zpaq/default.nix b/pkgs/tools/archivers/zpaq/default.nix index c8f3a890487f..fddb3cbfb154 100644 --- a/pkgs/tools/archivers/zpaq/default.nix +++ b/pkgs/tools/archivers/zpaq/default.nix @@ -14,11 +14,12 @@ let ]; isUnix = with stdenv; isLinux || isGNU || isDarwin || isFreeBSD || isOpenBSD; isx86 = stdenv.isi686 || stdenv.isx86_64; - compileFlags = "" - + (stdenv.lib.optionalString isUnix " -Dunix -pthread ") - + (stdenv.lib.optionalString (!isx86) " -DNOJIT ") - + " -DNDEBUG " - + " -fPIC " + compileFlags = with stdenv; "" + + (lib.optionalString (isUnix) " -Dunix -pthread") + + (lib.optionalString (isi686) " -march=i686") + + (lib.optionalString (isx86_64) " -march=nocona") + + (lib.optionalString (!isx86) " -DNOJIT") + + " -O3 -mtune=generic -DNDEBUG" ; in stdenv.mkDerivation { @@ -29,8 +30,8 @@ stdenv.mkDerivation { }; sourceRoot = "."; buildPhase = '' - g++ -O3 -march=native -Dunix libzpaq.cpp -pthread --shared -o libzpaq.so -fPIC - g++ -O3 -march=native -Dunix zpaq.cpp -lzpaq -L. -L"$out/lib" -pthread -o zpaq + g++ ${compileFlags} -fPIC --shared libzpaq.cpp -o libzpaq.so + g++ ${compileFlags} -L. -L"$out/lib" -lzpaq zpaq.cpp -o zpaq ''; installPhase = '' mkdir -p "$out"/{bin,include,lib,share/doc/zpaq} diff --git a/pkgs/tools/archivers/zpaq/zpaqd.nix b/pkgs/tools/archivers/zpaq/zpaqd.nix index 65f40f68f550..5518a94ba21f 100644 --- a/pkgs/tools/archivers/zpaq/zpaqd.nix +++ b/pkgs/tools/archivers/zpaq/zpaqd.nix @@ -14,11 +14,12 @@ let ]; isUnix = with stdenv; isLinux || isGNU || isDarwin || isFreeBSD || isOpenBSD; isx86 = stdenv.isi686 || stdenv.isx86_64; - compileFlags = "" - + (stdenv.lib.optionalString isUnix " -Dunix -pthread ") - + (stdenv.lib.optionalString (!isx86) " -DNOJIT ") - + " -DNDEBUG " - + " -fPIC " + compileFlags = with stdenv; "" + + (lib.optionalString (isUnix) " -Dunix -pthread") + + (lib.optionalString (isi686) " -march=i686") + + (lib.optionalString (isx86_64) " -march=nocona") + + (lib.optionalString (!isx86) " -DNOJIT") + + " -O3 -mtune=generic -DNDEBUG" ; in stdenv.mkDerivation { @@ -29,8 +30,8 @@ stdenv.mkDerivation { }; sourceRoot = "."; buildPhase = '' - g++ -shared -O3 libzpaq.cpp ${compileFlags} -o libzpaq.so - g++ -O3 -L. -L"$out/lib" -lzpaq zpaqd.cpp -o zpaqd + g++ ${compileFlags} -fPIC --shared libzpaq.cpp -o libzpaq.so + g++ ${compileFlags} -L. -L"$out/lib" -lzpaq zpaqd.cpp -o zpaqd ''; installPhase = '' mkdir -p "$out"/{bin,include,lib,share/doc/zpaq}