1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 07:00:43 +00:00

zpaq{,d}: un-break compileFlags and stop using -march=native

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.
This commit is contained in:
Tobias Geerinckx-Rice 2015-12-31 04:36:54 +01:00
parent 624b3a34c0
commit d04e57ea6a
2 changed files with 16 additions and 14 deletions

View file

@ -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}

View file

@ -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}