From 32322da1a6ec982e390a15481b5d086116e09d47 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 12 Feb 2019 02:45:32 -0600 Subject: [PATCH] openblas: fix config breakage introduced for configs using 'false' My earlier change mistakenly expected `toString false` to produce '0' instead of the empty string, leading to unexpected config changes. Intended to address issue mentioned here and in following discussion: https://github.com/NixOS/nixpkgs/pull/53972#issuecomment-459981602 Sorry, folks! (special-case handling of bools here makes this "cleanup" a bit less of an obvious win but hopefully still preferable overall :)) ----------- makeFlags in resulting derivation, according to this one-liner: $ nix show-derivation -f . openblas|jq ".[].env.makeFlags" before: "BINARY=64 CC=cc CROSS= DYNAMIC_ARCH=1 FC=gfortran HOSTCC=cc INTERFACE64=1 NO_BINARY_MODE= NO_STATIC=1 NUM_THREADS=64 PREFIX=/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9 TARGET=ATHLON USE_OPENMP=1" after: "BINARY=64 CC=cc CROSS=0 DYNAMIC_ARCH=1 FC=gfortran HOSTCC=cc INTERFACE64=1 NO_BINARY_MODE=0 NO_STATIC=1 NUM_THREADS=64 PREFIX=/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9 TARGET=ATHLON USE_OPENMP=1" Without knowing how `placeholder` works, it seems interesting if entirely unrelated that the `PREFIX` is same for both! :). TIL. --- .../libraries/science/math/openblas/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix index 68439f5921d8..f4a97b7cf854 100644 --- a/pkgs/development/libraries/science/math/openblas/default.nix +++ b/pkgs/development/libraries/science/math/openblas/default.nix @@ -74,6 +74,14 @@ let if blas64_ != null then blas64_ else hasPrefix "x86_64" stdenv.hostPlatform.system; + # Convert flag values to format OpenBLAS's build expects. + # `toString` is almost what we need other than bools, + # which we need to map {true -> 1, false -> 0} + # (`toString` produces empty string `""` for false instead of `0`) + mkMakeFlagValue = val: + if !builtins.isBool val then toString val + else if val then "1" else "0"; + mkMakeFlagsFromConfig = mapAttrsToList (var: val: "${var}=${mkMakeFlagValue val}"); in stdenv.mkDerivation rec { name = "openblas-${version}"; @@ -109,7 +117,7 @@ stdenv.mkDerivation rec { buildPackages.stdenv.cc ]; - makeFlags = mapAttrsToList (var: val: "${var}=${toString val}") (config // { + makeFlags = mkMakeFlagsFromConfig (config // { FC = "${stdenv.cc.targetPrefix}gfortran"; CC = "${stdenv.cc.targetPrefix}${if stdenv.cc.isClang then "clang" else "cc"}"; PREFIX = placeholder "out";