3
0
Fork 0
forked from mirrors/nixpkgs

compilation for particular x86_64 architecture

This commit is contained in:
volth 2019-04-21 17:06:50 +00:00
parent f454785bb4
commit 5ad79dc4bb
16 changed files with 92 additions and 76 deletions

View file

@ -60,6 +60,7 @@ let
${optionalString (isNix20 && !cfg.distributedBuilds) '' ${optionalString (isNix20 && !cfg.distributedBuilds) ''
builders = builders =
''} ''}
system-features = ${toString cfg.systemFeatures}
$extraOptions $extraOptions
END END
'' + optionalString cfg.checkConfig ( '' + optionalString cfg.checkConfig (
@ -360,6 +361,15 @@ in
''; '';
}; };
systemFeatures = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "kvm" "big-parallel" "gccarch-skylake" ];
description = ''
The supported features of a machine
'';
};
checkConfig = mkOption { checkConfig = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
@ -478,6 +488,21 @@ in
/nix/var/nix/gcroots/tmp /nix/var/nix/gcroots/tmp
''; '';
nix.systemFeatures = mkIf (pkgs.stdenv.isx86_64 && pkgs.hostPlatform.platform ? gcc.arch) (
# can build for arch
mkDefault (
[ "nixos-test" "benchmark" "big-parallel" "kvm" "gccarch-${pkgs.hostPlatform.platform.gcc.arch}" ] ++
{ # can also run code for the following achritectures:
"sandybridge" = [ "gccarch-westmere" ];
"ivybridge" = [ "gccarch-westmere" "gccarch-sandybridge" ];
"haswell" = [ "gccarch-westmere" "gccarch-sandybridge" "gccarch-ivybridge" ];
"broadwell" = [ "gccarch-westmere" "gccarch-sandybridge" "gccarch-ivybridge" "gccarch-haswell" ];
"skylake" = [ "gccarch-westmere" "gccarch-sandybridge" "gccarch-ivybridge" "gccarch-haswell" "gccarch-broadwell" ];
"skylake-avx512" = [ "gccarch-westmere" "gccarch-sandybridge" "gccarch-ivybridge" "gccarch-haswell" "gccarch-broadwell" "gccarch-skylake" ];
}.${pkgs.hostPlatform.platform.gcc.arch}
)
);
}; };
} }

View file

@ -66,7 +66,7 @@ in stdenv.mkDerivation rec {
# For some reason librdf_redland sometimes refers to rasqal.h instead # For some reason librdf_redland sometimes refers to rasqal.h instead
# of rasqal/rasqal.h # of rasqal/rasqal.h
NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" ]; NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" "-mno-fma" ];
patches = [ patches = [
./xdg-open-brief.patch ./xdg-open-brief.patch

View file

@ -66,7 +66,7 @@ in stdenv.mkDerivation rec {
# For some reason librdf_redland sometimes refers to rasqal.h instead # For some reason librdf_redland sometimes refers to rasqal.h instead
# of rasqal/rasqal.h # of rasqal/rasqal.h
NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" ]; NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" "-mno-fma" ];
patches = [ patches = [
./xdg-open-brief.patch ./xdg-open-brief.patch

View file

@ -1,7 +1,6 @@
{ stdenv { stdenv
, lib , lib
, fetchurl , fetchurl
, optimize ? false # impure
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "nauty-${version}"; name = "nauty-${version}";
@ -11,13 +10,15 @@ stdenv.mkDerivation rec {
sha256 = "05z6mk7c31j70md83396cdjmvzzip1hqb88pfszzc6k4gy8h3m2y"; sha256 = "05z6mk7c31j70md83396cdjmvzzip1hqb88pfszzc6k4gy8h3m2y";
}; };
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" ];
configureFlags = lib.optionals (!optimize) [ configureFlags = {
# Prevent nauty from sniffing some cpu features. While those are very # Prevent nauty from sniffing some cpu features. While those are very
# widely available, it can lead to nasty bugs when they are not available: # widely available, it can lead to nasty bugs when they are not available:
# https://groups.google.com/forum/#!topic/sage-packaging/Pe4SRDNYlhA # https://groups.google.com/forum/#!topic/sage-packaging/Pe4SRDNYlhA
"--disable-popcnt" "default" = [ "--disable-clz" "--disable-popcnt" ];
"--disable-clz" "westmere" = [ "--disable-clz" ];
]; "sandybridge" = [ "--disable-clz" ];
"ivybridge" = [ "--disable-clz" ];
}.${stdenv.hostPlatform.platform.gcc.arch or "default"} or [];
buildInputs = []; buildInputs = [];
installPhase = '' installPhase = ''
mkdir -p "$out"/{bin,share/doc/nauty} "$dev"/{lib,include/nauty} mkdir -p "$out"/{bin,share/doc/nauty} "$dev"/{lib,include/nauty}

View file

@ -130,7 +130,7 @@ stdenv.mkDerivation rec {
makeFlags = makeFlags =
let let
arch = head (splitString "-" stdenv.system); arch = head (splitString "-" stdenv.system);
march = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}" march = { "x86_64" = stdenv.hostPlatform.platform.gcc.arch or "x86-64"; "i686" = "pentium4"; }."${arch}"
or (throw "unsupported architecture: ${arch}"); or (throw "unsupported architecture: ${arch}");
# Julia requires Pentium 4 (SSE2) or better # Julia requires Pentium 4 (SSE2) or better
cpuTarget = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}" cpuTarget = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}"

View file

@ -18,17 +18,11 @@ stdenv.mkDerivation rec {
]; ];
configurePhase = let configurePhase = ''
marchflags =
if stdenv.isi686 then "-march=i686" else
if stdenv.isx86_64 then "-march=nocona -mtune=generic" else
"";
in
''
sed -i GNUmakefile \ sed -i GNUmakefile \
-e 's|-march=native|${marchflags} -fPIC|g' \ -e 's|-march=native|-fPIC|g' \
-e '/^CXXFLAGS =/s|-g ||' -e '/^CXXFLAGS =/s|-g ||'
''; '';
enableParallelBuilding = true; enableParallelBuilding = true;

View file

@ -1,7 +1,6 @@
{ stdenv, fetchFromGitHub, autoreconfHook, givaro, pkgconfig, blas { stdenv, fetchFromGitHub, autoreconfHook, givaro, pkgconfig, blas
, fetchpatch , fetchpatch
, gmpxx , gmpxx
, optimize ? false # impure
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "${pname}-${version}"; name = "${pname}-${version}";
@ -40,19 +39,17 @@ stdenv.mkDerivation rec {
configureFlags = [ configureFlags = [
"--with-blas-libs=-l${blas.linkName}" "--with-blas-libs=-l${blas.linkName}"
"--with-lapack-libs=-l${blas.linkName}" "--with-lapack-libs=-l${blas.linkName}"
] ++ stdenv.lib.optionals (!optimize) [ ] ++ stdenv.lib.optionals stdenv.isx86_64 {
# disable SIMD instructions (which are enabled *when available* by default) # disable SIMD instructions (which are enabled *when available* by default)
"--disable-sse" "default" = [ "--disable-sse3" "--disable-ssse3" "--disable-sse41" "--disable-sse42" "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse2" "westmere" = [ "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse3" "sandybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-ssse3" "ivybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse41" "haswell" = [ "--disable-fma4" ];
"--disable-sse42" "broadwell" = [ "--disable-fma4" ];
"--disable-avx" "skylake" = [ "--disable-fma4" ];
"--disable-avx2" "skylake-avx512" = [ "--disable-fma4" ];
"--disable-fma" }.${stdenv.hostPlatform.platform.gcc.arch or "default"};
"--disable-fma4"
];
doCheck = true; doCheck = true;

View file

@ -1,6 +1,4 @@
{ stdenv, fetchFromGitHub, automake, autoconf, libtool, autoreconfHook, gmpxx { stdenv, fetchFromGitHub, automake, autoconf, libtool, autoreconfHook, gmpxx }:
, optimize ? false # impure
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "${pname}-${version}"; name = "${pname}-${version}";
pname = "givaro"; pname = "givaro";
@ -19,19 +17,17 @@ stdenv.mkDerivation rec {
configureFlags = [ configureFlags = [
"--disable-optimization" "--disable-optimization"
] ++ stdenv.lib.optionals (!optimize) [ ] ++ stdenv.lib.optionals stdenv.isx86_64 {
# disable SIMD instructions (which are enabled *when available* by default) # disable SIMD instructions (which are enabled *when available* by default)
"--disable-sse" "default" = [ "--disable-sse3" "--disable-ssse3" "--disable-sse41" "--disable-sse42" "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse2" "westmere" = [ "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse3" "sandybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-ssse3" "ivybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse41" "haswell" = [ "--disable-fma4" ];
"--disable-sse42" "broadwell" = [ "--disable-fma4" ];
"--disable-avx" "skylake" = [ "--disable-fma4" ];
"--disable-avx2" "skylake-avx512" = [ "--disable-fma4" ];
"--disable-fma" }.${stdenv.hostPlatform.platform.gcc.arch or "default"};
"--disable-fma4"
];
# On darwin, tests are linked to dylib in the nix store, so we need to make # On darwin, tests are linked to dylib in the nix store, so we need to make
# sure tests run after installPhase. # sure tests run after installPhase.

View file

@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
sha256 = "1395y9hlhqadn5g9j8q22224fds5sd92jxi9czfavjj24myasq04"; sha256 = "1395y9hlhqadn5g9j8q22224fds5sd92jxi9czfavjj24myasq04";
}; };
NIX_CFLAGS_COMPILE = [ "-mno-fma" ]; # do not let -march=skylake to enable FMA (https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html)
patches = [ patches = [
# ToDo: there might be more impurities than FMA support check # ToDo: there might be more impurities than FMA support check
./disable-fma.patch # https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html ./disable-fma.patch # https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html

View file

@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
sha256 = "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k"; sha256 = "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k";
}; };
NIX_CFLAGS_COMPILE = [ "-mno-fma" ]; # do not let -march=skylake to enable FMA (https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html)
patches = [ patches = [
# ToDo: there might be more impurities than FMA support check # ToDo: there might be more impurities than FMA support check
./disable-fma.patch # https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html ./disable-fma.patch # https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html

View file

@ -7,7 +7,6 @@
, blas , blas
, fflas-ffpack , fflas-ffpack
, gmpxx , gmpxx
, optimize ? false # impure
, withSage ? false # sage support , withSage ? false # sage support
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -37,19 +36,18 @@ stdenv.mkDerivation rec {
configureFlags = [ configureFlags = [
"--with-blas-libs=-l${blas.linkName}" "--with-blas-libs=-l${blas.linkName}"
"--disable-optimization" "--disable-optimization"
] ++ stdenv.lib.optionals (!optimize) [ ] ++ stdenv.lib.optionals stdenv.isx86_64 {
# disable SIMD instructions (which are enabled *when available* by default) # disable SIMD instructions (which are enabled *when available* by default)
"--disable-sse" "default" = [ "--disable-sse3" "--disable-ssse3" "--disable-sse41" "--disable-sse42" "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse2" "westmere" = [ "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse3" "sandybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-ssse3" "ivybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ];
"--disable-sse41" "haswell" = [ "--disable-fma4" ];
"--disable-sse42" "broadwell" = [ "--disable-fma4" ];
"--disable-avx" "skylake" = [ "--disable-fma4" ];
"--disable-avx2" "skylake-avx512" = [ "--disable-fma4" ];
"--disable-fma" }.${stdenv.hostPlatform.platform.gcc.arch or "default"}
"--disable-fma4" ++ stdenv.lib.optionals withSage [
] ++ stdenv.lib.optionals withSage [
"--enable-sage" "--enable-sage"
]; ];

View file

@ -266,15 +266,18 @@ stdenv.mkDerivation {
++ ( ++ (
if (!stdenv.hostPlatform.isx86_64) if (!stdenv.hostPlatform.isx86_64)
then [ "-no-sse2" ] then [ "-no-sse2" ]
else lib.optional (compareVersion "5.9.0" >= 0) [ "-sse2" ] else lib.optionals (compareVersion "5.9.0" >= 0) {
"default" = [ "-sse2" "-no-sse3" "-no-ssse3" "-no-sse4.1" "-no-sse4.2" "-no-avx" "-no-avx2" ];
"westmere" = [ "-sse2" "-sse3" "-ssse3" "-sse4.1" "-sse4.2" "-no-avx" "-no-avx2" ];
"sandybridge" = [ "-sse2" "-sse3" "-ssse3" "-sse4.1" "-sse4.2" "-avx" "-no-avx2" ];
"ivybridge" = [ "-sse2" "-sse3" "-ssse3" "-sse4.1" "-sse4.2" "-avx" "-no-avx2" ];
"haswell" = [ "-sse2" "-sse3" "-ssse3" "-sse4.1" "-sse4.2" "-avx" "-avx2" ];
"broadwell" = [ "-sse2" "-sse3" "-ssse3" "-sse4.1" "-sse4.2" "-avx" "-avx2" ];
"skylake" = [ "-sse2" "-sse3" "-ssse3" "-sse4.1" "-sse4.2" "-avx" "-avx2" ];
"skylake-avx512" = [ "-sse2" "-sse3" "-ssse3" "-sse4.1" "-sse4.2" "-avx" "-avx2" ];
}.${stdenv.hostPlatform.platform.gcc.arch or "default"}
) )
++ [ ++ [
"-no-sse3"
"-no-ssse3"
"-no-sse4.1"
"-no-sse4.2"
"-no-avx"
"-no-avx2"
"-no-mips_dsp" "-no-mips_dsp"
"-no-mips_dspr2" "-no-mips_dspr2"
] ]

View file

@ -103,7 +103,10 @@ EOF
''); '');
NIX_CFLAGS_COMPILE = NIX_CFLAGS_COMPILE =
lib.optionalString stdenv.isDarwin [ # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940
# TODO: investigate and fix properly
lib.optionals (stdenv.hostPlatform.platform.gcc.arch or "" == "sandybridge") [ "-march=westmere" ] ++
lib.optionals stdenv.isDarwin [
"-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10" "-DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_10"
"-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_10" "-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_10"

View file

@ -8,9 +8,9 @@
, xlaSupport ? cudaSupport , xlaSupport ? cudaSupport
# Default from ./configure script # Default from ./configure script
, cudaCapabilities ? [ "3.5" "5.2" ] , cudaCapabilities ? [ "3.5" "5.2" ]
, sse42Support ? false , sse42Support ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") ["westmere" "sandybridge" "ivybridge" "haswell" "broadwell" "skylake" "skylake-avx512"]
, avx2Support ? false , avx2Support ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") [ "haswell" "broadwell" "skylake" "skylake-avx512"]
, fmaSupport ? false , fmaSupport ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") [ "haswell" "broadwell" "skylake" "skylake-avx512"]
}: }:
assert cudaSupport -> nvidia_x11 != null assert cudaSupport -> nvidia_x11 != null

View file

@ -19,10 +19,7 @@ stdenv.mkDerivation rec {
CPPFLAGS = with stdenv; "" CPPFLAGS = with stdenv; ""
+ (lib.optionalString (!isi686 && !isx86_64) "-DNOJIT ") + (lib.optionalString (!isi686 && !isx86_64) "-DNOJIT ")
+ "-Dunix"; + "-Dunix";
CXXFLAGS = with stdenv; "" CXXFLAGS = "-O3 -DNDEBUG";
+ (lib.optionalString isi686 "-march=i686 -mtune=generic ")
+ (lib.optionalString isx86_64 "-march=nocona -mtune=generic ")
+ "-O3 -DNDEBUG";
in '' in ''
buildFlagsArray=( "CPPFLAGS=${CPPFLAGS}" "CXXFLAGS=${CXXFLAGS}" ) buildFlagsArray=( "CPPFLAGS=${CPPFLAGS}" "CXXFLAGS=${CXXFLAGS}" )
''; '';

View file

@ -11,10 +11,8 @@ let
sha256="0868lynb45lm79yvx5f10lj5h6bfv0yck8whcls2j080vmk3n7rk"; sha256="0868lynb45lm79yvx5f10lj5h6bfv0yck8whcls2j080vmk3n7rk";
}; };
compileFlags = stdenv.lib.concatStringsSep " " ([ "-O3" "-mtune=generic" "-DNDEBUG" ] compileFlags = stdenv.lib.concatStringsSep " " ([ "-O3" "-DNDEBUG" ]
++ stdenv.lib.optional (stdenv.hostPlatform.isUnix) "-Dunix -pthread" ++ stdenv.lib.optional (stdenv.hostPlatform.isUnix) "-Dunix -pthread"
++ stdenv.lib.optional (stdenv.hostPlatform.isi686) "-march=i686"
++ stdenv.lib.optional (stdenv.hostPlatform.isx86_64) "-march=nocona"
++ stdenv.lib.optional (!stdenv.hostPlatform.isx86) "-DNOJIT"); ++ stdenv.lib.optional (!stdenv.hostPlatform.isx86) "-DNOJIT");
in in
stdenv.mkDerivation { stdenv.mkDerivation {