From 5ad79dc4bb22326e5a98db7bf2b69a76a2e6f01e Mon Sep 17 00:00:00 2001 From: volth Date: Sun, 21 Apr 2019 17:06:50 +0000 Subject: [PATCH 1/4] compilation for particular x86_64 architecture --- nixos/modules/services/misc/nix-daemon.nix | 25 ++++++++++++++++++ .../office/libreoffice/default.nix | 2 +- .../applications/office/libreoffice/still.nix | 2 +- .../science/math/nauty/default.nix | 11 ++++---- pkgs/development/compilers/julia/shared.nix | 2 +- .../libraries/crypto++/default.nix | 12 +++------ .../libraries/fflas-ffpack/default.nix | 23 +++++++--------- pkgs/development/libraries/givaro/default.nix | 26 ++++++++----------- pkgs/development/libraries/gsl/default.nix | 2 ++ pkgs/development/libraries/gsl/gsl-1_16.nix | 2 ++ pkgs/development/libraries/linbox/default.nix | 24 ++++++++--------- .../libraries/qt-5/modules/qtbase.nix | 17 +++++++----- .../libraries/qt-5/modules/qtwebengine.nix | 5 +++- .../python-modules/tensorflow/default.nix | 6 ++--- pkgs/tools/archivers/zpaq/default.nix | 5 +--- pkgs/tools/archivers/zpaq/zpaqd.nix | 4 +-- 16 files changed, 92 insertions(+), 76 deletions(-) diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index 665215822af..62421a648e1 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -60,6 +60,7 @@ let ${optionalString (isNix20 && !cfg.distributedBuilds) '' builders = ''} + system-features = ${toString cfg.systemFeatures} $extraOptions END '' + 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 { type = types.bool; default = true; @@ -478,6 +488,21 @@ in /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} + ) + ); + }; } diff --git a/pkgs/applications/office/libreoffice/default.nix b/pkgs/applications/office/libreoffice/default.nix index a7f24fdf1f3..75d780f2333 100644 --- a/pkgs/applications/office/libreoffice/default.nix +++ b/pkgs/applications/office/libreoffice/default.nix @@ -66,7 +66,7 @@ in stdenv.mkDerivation rec { # For some reason librdf_redland sometimes refers to rasqal.h instead # of rasqal/rasqal.h - NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" ]; + NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" "-mno-fma" ]; patches = [ ./xdg-open-brief.patch diff --git a/pkgs/applications/office/libreoffice/still.nix b/pkgs/applications/office/libreoffice/still.nix index 1b7d2b0987f..9e6671838cd 100644 --- a/pkgs/applications/office/libreoffice/still.nix +++ b/pkgs/applications/office/libreoffice/still.nix @@ -66,7 +66,7 @@ in stdenv.mkDerivation rec { # For some reason librdf_redland sometimes refers to rasqal.h instead # of rasqal/rasqal.h - NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" ]; + NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" "-mno-fma" ]; patches = [ ./xdg-open-brief.patch diff --git a/pkgs/applications/science/math/nauty/default.nix b/pkgs/applications/science/math/nauty/default.nix index 7351de53cfc..226e13c004d 100644 --- a/pkgs/applications/science/math/nauty/default.nix +++ b/pkgs/applications/science/math/nauty/default.nix @@ -1,7 +1,6 @@ { stdenv , lib , fetchurl -, optimize ? false # impure }: stdenv.mkDerivation rec { name = "nauty-${version}"; @@ -11,13 +10,15 @@ stdenv.mkDerivation rec { sha256 = "05z6mk7c31j70md83396cdjmvzzip1hqb88pfszzc6k4gy8h3m2y"; }; outputs = [ "out" "dev" ]; - configureFlags = lib.optionals (!optimize) [ + configureFlags = { # Prevent nauty from sniffing some cpu features. While those are very # widely available, it can lead to nasty bugs when they are not available: # https://groups.google.com/forum/#!topic/sage-packaging/Pe4SRDNYlhA - "--disable-popcnt" - "--disable-clz" - ]; + "default" = [ "--disable-clz" "--disable-popcnt" ]; + "westmere" = [ "--disable-clz" ]; + "sandybridge" = [ "--disable-clz" ]; + "ivybridge" = [ "--disable-clz" ]; + }.${stdenv.hostPlatform.platform.gcc.arch or "default"} or []; buildInputs = []; installPhase = '' mkdir -p "$out"/{bin,share/doc/nauty} "$dev"/{lib,include/nauty} diff --git a/pkgs/development/compilers/julia/shared.nix b/pkgs/development/compilers/julia/shared.nix index ffa5e3ba55d..6706cf1e2bd 100644 --- a/pkgs/development/compilers/julia/shared.nix +++ b/pkgs/development/compilers/julia/shared.nix @@ -130,7 +130,7 @@ stdenv.mkDerivation rec { makeFlags = let 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}"); # Julia requires Pentium 4 (SSE2) or better cpuTarget = { "x86_64" = "x86-64"; "i686" = "pentium4"; }."${arch}" diff --git a/pkgs/development/libraries/crypto++/default.nix b/pkgs/development/libraries/crypto++/default.nix index cbd3e405415..61a825cd374 100644 --- a/pkgs/development/libraries/crypto++/default.nix +++ b/pkgs/development/libraries/crypto++/default.nix @@ -18,17 +18,11 @@ stdenv.mkDerivation rec { ]; - configurePhase = let - marchflags = - if stdenv.isi686 then "-march=i686" else - if stdenv.isx86_64 then "-march=nocona -mtune=generic" else - ""; - in - '' + configurePhase = '' sed -i GNUmakefile \ - -e 's|-march=native|${marchflags} -fPIC|g' \ + -e 's|-march=native|-fPIC|g' \ -e '/^CXXFLAGS =/s|-g ||' - ''; + ''; enableParallelBuilding = true; diff --git a/pkgs/development/libraries/fflas-ffpack/default.nix b/pkgs/development/libraries/fflas-ffpack/default.nix index 2dd58e64585..a37a11f5cb0 100644 --- a/pkgs/development/libraries/fflas-ffpack/default.nix +++ b/pkgs/development/libraries/fflas-ffpack/default.nix @@ -1,7 +1,6 @@ { stdenv, fetchFromGitHub, autoreconfHook, givaro, pkgconfig, blas , fetchpatch , gmpxx -, optimize ? false # impure }: stdenv.mkDerivation rec { name = "${pname}-${version}"; @@ -40,19 +39,17 @@ stdenv.mkDerivation rec { configureFlags = [ "--with-blas-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-sse" - "--disable-sse2" - "--disable-sse3" - "--disable-ssse3" - "--disable-sse41" - "--disable-sse42" - "--disable-avx" - "--disable-avx2" - "--disable-fma" - "--disable-fma4" - ]; + "default" = [ "--disable-sse3" "--disable-ssse3" "--disable-sse41" "--disable-sse42" "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "westmere" = [ "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "sandybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "ivybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "haswell" = [ "--disable-fma4" ]; + "broadwell" = [ "--disable-fma4" ]; + "skylake" = [ "--disable-fma4" ]; + "skylake-avx512" = [ "--disable-fma4" ]; + }.${stdenv.hostPlatform.platform.gcc.arch or "default"}; doCheck = true; diff --git a/pkgs/development/libraries/givaro/default.nix b/pkgs/development/libraries/givaro/default.nix index 0773daa2d09..bfbce57b0a6 100644 --- a/pkgs/development/libraries/givaro/default.nix +++ b/pkgs/development/libraries/givaro/default.nix @@ -1,6 +1,4 @@ -{ stdenv, fetchFromGitHub, automake, autoconf, libtool, autoreconfHook, gmpxx -, optimize ? false # impure -}: +{ stdenv, fetchFromGitHub, automake, autoconf, libtool, autoreconfHook, gmpxx }: stdenv.mkDerivation rec { name = "${pname}-${version}"; pname = "givaro"; @@ -19,19 +17,17 @@ stdenv.mkDerivation rec { configureFlags = [ "--disable-optimization" - ] ++ stdenv.lib.optionals (!optimize) [ + ] ++ stdenv.lib.optionals stdenv.isx86_64 { # disable SIMD instructions (which are enabled *when available* by default) - "--disable-sse" - "--disable-sse2" - "--disable-sse3" - "--disable-ssse3" - "--disable-sse41" - "--disable-sse42" - "--disable-avx" - "--disable-avx2" - "--disable-fma" - "--disable-fma4" - ]; + "default" = [ "--disable-sse3" "--disable-ssse3" "--disable-sse41" "--disable-sse42" "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "westmere" = [ "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "sandybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "ivybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "haswell" = [ "--disable-fma4" ]; + "broadwell" = [ "--disable-fma4" ]; + "skylake" = [ "--disable-fma4" ]; + "skylake-avx512" = [ "--disable-fma4" ]; + }.${stdenv.hostPlatform.platform.gcc.arch or "default"}; # On darwin, tests are linked to dylib in the nix store, so we need to make # sure tests run after installPhase. diff --git a/pkgs/development/libraries/gsl/default.nix b/pkgs/development/libraries/gsl/default.nix index 9fd3f8a7a99..1867d6cb8f6 100644 --- a/pkgs/development/libraries/gsl/default.nix +++ b/pkgs/development/libraries/gsl/default.nix @@ -8,6 +8,8 @@ stdenv.mkDerivation rec { 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 = [ # 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 diff --git a/pkgs/development/libraries/gsl/gsl-1_16.nix b/pkgs/development/libraries/gsl/gsl-1_16.nix index 69fe1b0db55..02d88e67cdd 100644 --- a/pkgs/development/libraries/gsl/gsl-1_16.nix +++ b/pkgs/development/libraries/gsl/gsl-1_16.nix @@ -8,6 +8,8 @@ stdenv.mkDerivation rec { 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 = [ # 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 diff --git a/pkgs/development/libraries/linbox/default.nix b/pkgs/development/libraries/linbox/default.nix index a9a649e2de7..ef2dbb10fba 100644 --- a/pkgs/development/libraries/linbox/default.nix +++ b/pkgs/development/libraries/linbox/default.nix @@ -7,7 +7,6 @@ , blas , fflas-ffpack , gmpxx -, optimize ? false # impure , withSage ? false # sage support }: stdenv.mkDerivation rec { @@ -37,19 +36,18 @@ stdenv.mkDerivation rec { configureFlags = [ "--with-blas-libs=-l${blas.linkName}" "--disable-optimization" - ] ++ stdenv.lib.optionals (!optimize) [ + ] ++ stdenv.lib.optionals stdenv.isx86_64 { # disable SIMD instructions (which are enabled *when available* by default) - "--disable-sse" - "--disable-sse2" - "--disable-sse3" - "--disable-ssse3" - "--disable-sse41" - "--disable-sse42" - "--disable-avx" - "--disable-avx2" - "--disable-fma" - "--disable-fma4" - ] ++ stdenv.lib.optionals withSage [ + "default" = [ "--disable-sse3" "--disable-ssse3" "--disable-sse41" "--disable-sse42" "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "westmere" = [ "--disable-avx" "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "sandybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "ivybridge" = [ "--disable-avx2" "--disable-fma" "--disable-fma4" ]; + "haswell" = [ "--disable-fma4" ]; + "broadwell" = [ "--disable-fma4" ]; + "skylake" = [ "--disable-fma4" ]; + "skylake-avx512" = [ "--disable-fma4" ]; + }.${stdenv.hostPlatform.platform.gcc.arch or "default"} + ++ stdenv.lib.optionals withSage [ "--enable-sage" ]; diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 92ac8a24201..71d27c33a92 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -266,15 +266,18 @@ stdenv.mkDerivation { ++ ( if (!stdenv.hostPlatform.isx86_64) 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_dspr2" ] diff --git a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix index 91b7acf4365..af580401887 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix @@ -103,7 +103,10 @@ EOF ''); 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_MIN_REQUIRED=MAC_OS_X_VERSION_10_10" diff --git a/pkgs/development/python-modules/tensorflow/default.nix b/pkgs/development/python-modules/tensorflow/default.nix index 8163243eb0a..a8f902fdb38 100644 --- a/pkgs/development/python-modules/tensorflow/default.nix +++ b/pkgs/development/python-modules/tensorflow/default.nix @@ -8,9 +8,9 @@ , xlaSupport ? cudaSupport # Default from ./configure script , cudaCapabilities ? [ "3.5" "5.2" ] -, sse42Support ? false -, avx2Support ? false -, fmaSupport ? false +, sse42Support ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") ["westmere" "sandybridge" "ivybridge" "haswell" "broadwell" "skylake" "skylake-avx512"] +, avx2Support ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") [ "haswell" "broadwell" "skylake" "skylake-avx512"] +, fmaSupport ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") [ "haswell" "broadwell" "skylake" "skylake-avx512"] }: assert cudaSupport -> nvidia_x11 != null diff --git a/pkgs/tools/archivers/zpaq/default.nix b/pkgs/tools/archivers/zpaq/default.nix index 309604999ba..48b3a91b971 100644 --- a/pkgs/tools/archivers/zpaq/default.nix +++ b/pkgs/tools/archivers/zpaq/default.nix @@ -19,10 +19,7 @@ stdenv.mkDerivation rec { CPPFLAGS = with stdenv; "" + (lib.optionalString (!isi686 && !isx86_64) "-DNOJIT ") + "-Dunix"; - CXXFLAGS = with stdenv; "" - + (lib.optionalString isi686 "-march=i686 -mtune=generic ") - + (lib.optionalString isx86_64 "-march=nocona -mtune=generic ") - + "-O3 -DNDEBUG"; + CXXFLAGS = "-O3 -DNDEBUG"; in '' buildFlagsArray=( "CPPFLAGS=${CPPFLAGS}" "CXXFLAGS=${CXXFLAGS}" ) ''; diff --git a/pkgs/tools/archivers/zpaq/zpaqd.nix b/pkgs/tools/archivers/zpaq/zpaqd.nix index 344f0889090..611654331c3 100644 --- a/pkgs/tools/archivers/zpaq/zpaqd.nix +++ b/pkgs/tools/archivers/zpaq/zpaqd.nix @@ -11,10 +11,8 @@ let 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.isi686) "-march=i686" - ++ stdenv.lib.optional (stdenv.hostPlatform.isx86_64) "-march=nocona" ++ stdenv.lib.optional (!stdenv.hostPlatform.isx86) "-DNOJIT"); in stdenv.mkDerivation { From 3d3f83dc514d4fe8716df41f6d5ccb6f217b1c25 Mon Sep 17 00:00:00 2001 From: volth Date: Tue, 30 Apr 2019 14:39:05 +0000 Subject: [PATCH 2/4] gsl: remove disable-fma.patch `NIX_CFLAGS_COMPILE = [ "-mno-fma" ];` disables FMA in a more reliable way. `platform.gcc.arch = "skylake"` resulting in gcc command line flag -march=skylake was able to enable FMA even with disable-fma.patch applied --- pkgs/development/libraries/gsl/default.nix | 5 --- .../libraries/gsl/disable-fma.patch | 32 ------------------- pkgs/development/libraries/gsl/gsl-1_16.nix | 2 -- 3 files changed, 39 deletions(-) delete mode 100644 pkgs/development/libraries/gsl/disable-fma.patch diff --git a/pkgs/development/libraries/gsl/default.nix b/pkgs/development/libraries/gsl/default.nix index 1867d6cb8f6..6e6b74d514e 100644 --- a/pkgs/development/libraries/gsl/default.nix +++ b/pkgs/development/libraries/gsl/default.nix @@ -10,11 +10,6 @@ stdenv.mkDerivation rec { 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 = [ - # 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 - ]; - # https://lists.gnu.org/archive/html/bug-gsl/2015-11/msg00012.html doCheck = stdenv.hostPlatform.system != "i686-linux" && stdenv.hostPlatform.system != "aarch64-linux"; diff --git a/pkgs/development/libraries/gsl/disable-fma.patch b/pkgs/development/libraries/gsl/disable-fma.patch deleted file mode 100644 index bb1eda9cccc..00000000000 --- a/pkgs/development/libraries/gsl/disable-fma.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/configure.ac 2011-09-22 16:13:22 +0000 -+++ b/configure.ac 2011-11-26 23:55:24 +0000 -@@ -381,6 +381,28 @@ - AC_SUBST(HAVE_DARWIN_IEEE_INTERFACE) - AC_SUBST(HAVE_DARWIN86_IEEE_INTERFACE) - -+dnl check for compiler flags to disable use of FMA -+save_cflags="$CFLAGS" -+AC_CACHE_CHECK([for compiler flags to disable use of FMA], ac_cv_c_fma_flags, -+[ -+if test X"$GCC" = Xyes; then -+ fma_flags='-ffp-contract=off' -+else -+ fma_flags= -+fi -+if test X"$fma_flags" != X; then -+ CFLAGS="$fma_flags $CFLAGS" -+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int foo;]])],[ac_cv_c_fma_flags="$fma_flags"],[ac_cv_c_fma_flags="none"]) -+else -+ ac_cv_c_fma_flags="none" -+fi]) -+ -+if test "$ac_cv_c_fma_flags" != "none" ; then -+ CFLAGS="$ac_cv_c_fma_flags $save_cflags" -+else -+ CFLAGS="$save_cflags" -+fi -+ - dnl Check for IEEE control flags - - save_cflags="$CFLAGS" - diff --git a/pkgs/development/libraries/gsl/gsl-1_16.nix b/pkgs/development/libraries/gsl/gsl-1_16.nix index 02d88e67cdd..07dee287714 100644 --- a/pkgs/development/libraries/gsl/gsl-1_16.nix +++ b/pkgs/development/libraries/gsl/gsl-1_16.nix @@ -11,8 +11,6 @@ stdenv.mkDerivation rec { 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 = [ - # 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 (fetchpatch { name = "bug-39055.patch"; url = "https://git.savannah.gnu.org/cgit/gsl.git/patch/?id=9cc12d"; From 5a2356cff1816f8e05024f3e943f185a1288db19 Mon Sep 17 00:00:00 2001 From: volth Date: Tue, 30 Apr 2019 16:28:21 +0000 Subject: [PATCH 3/4] nix.systemFeatures: minor refactor --- nixos/modules/services/misc/nix-daemon.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index 62421a648e1..fe68879fda9 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -363,7 +363,6 @@ in systemFeatures = mkOption { type = types.listOf types.str; - default = [ ]; example = [ "kvm" "big-parallel" "gccarch-skylake" ]; description = '' The supported features of a machine @@ -488,11 +487,11 @@ in /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: + nix.systemFeatures = mkDefault ( + [ "nixos-test" "benchmark" "big-parallel" "kvm" ] ++ + optionals (pkgs.stdenv.isx86_64 && pkgs.hostPlatform.platform ? gcc.arch) ( + # a x86_64 builder can run code for `platform.gcc.arch` and minor architectures: + [ "gccarch-${pkgs.hostPlatform.platform.gcc.arch}" ] ++ { "sandybridge" = [ "gccarch-westmere" ]; "ivybridge" = [ "gccarch-westmere" "gccarch-sandybridge" ]; "haswell" = [ "gccarch-westmere" "gccarch-sandybridge" "gccarch-ivybridge" ]; From 091de095c92ab1d2932ec9dd5e810ea2575e2432 Mon Sep 17 00:00:00 2001 From: volth Date: Sat, 4 May 2019 15:31:02 +0000 Subject: [PATCH 4/4] -mno-fma is x86_64 only; it hinders aarch64 compilation --- pkgs/applications/office/libreoffice/default.nix | 2 +- pkgs/applications/office/libreoffice/still.nix | 2 +- pkgs/development/libraries/gsl/default.nix | 3 ++- pkgs/development/libraries/gsl/gsl-1_16.nix | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/office/libreoffice/default.nix b/pkgs/applications/office/libreoffice/default.nix index 75d780f2333..ccf0b69d7c6 100644 --- a/pkgs/applications/office/libreoffice/default.nix +++ b/pkgs/applications/office/libreoffice/default.nix @@ -66,7 +66,7 @@ in stdenv.mkDerivation rec { # For some reason librdf_redland sometimes refers to rasqal.h instead # of rasqal/rasqal.h - NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" "-mno-fma" ]; + NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" ] ++ lib.optional stdenv.isx86_64 "-mno-fma"; patches = [ ./xdg-open-brief.patch diff --git a/pkgs/applications/office/libreoffice/still.nix b/pkgs/applications/office/libreoffice/still.nix index 9e6671838cd..200677435eb 100644 --- a/pkgs/applications/office/libreoffice/still.nix +++ b/pkgs/applications/office/libreoffice/still.nix @@ -66,7 +66,7 @@ in stdenv.mkDerivation rec { # For some reason librdf_redland sometimes refers to rasqal.h instead # of rasqal/rasqal.h - NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" "-mno-fma" ]; + NIX_CFLAGS_COMPILE = [ "-I${librdf_rasqal}/include/rasqal" ] ++ lib.optional stdenv.isx86_64 "-mno-fma"; patches = [ ./xdg-open-brief.patch diff --git a/pkgs/development/libraries/gsl/default.nix b/pkgs/development/libraries/gsl/default.nix index 6e6b74d514e..c8846509d00 100644 --- a/pkgs/development/libraries/gsl/default.nix +++ b/pkgs/development/libraries/gsl/default.nix @@ -8,7 +8,8 @@ stdenv.mkDerivation rec { 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) + # do not let -march=skylake to enable FMA (https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html) + NIX_CFLAGS_COMPILE = stdenv.lib.optional stdenv.isx86_64 "-mno-fma"; # https://lists.gnu.org/archive/html/bug-gsl/2015-11/msg00012.html doCheck = stdenv.hostPlatform.system != "i686-linux" && stdenv.hostPlatform.system != "aarch64-linux"; diff --git a/pkgs/development/libraries/gsl/gsl-1_16.nix b/pkgs/development/libraries/gsl/gsl-1_16.nix index 07dee287714..e5772c8772e 100644 --- a/pkgs/development/libraries/gsl/gsl-1_16.nix +++ b/pkgs/development/libraries/gsl/gsl-1_16.nix @@ -8,7 +8,8 @@ stdenv.mkDerivation rec { 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) + # do not let -march=skylake to enable FMA (https://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html) + NIX_CFLAGS_COMPILE = stdenv.lib.optional stdenv.isx86_64 "-mno-fma"; patches = [ (fetchpatch {