openblas: refactor and set TARGET always

This commit is contained in:
Thomas Tuegel 2016-12-10 16:49:45 -06:00
parent f576c490e3
commit bed668c051
No known key found for this signature in database
GPG Key ID: 22CBF5249D4B4D59

View File

@ -1,6 +1,7 @@
{ stdenv, fetchurl, gfortran, perl, which, config, coreutils { stdenv, fetchurl, gfortran, perl, which, config, coreutils
# Most packages depending on openblas expect integer width to match pointer width, # Most packages depending on openblas expect integer width to match
# but some expect to use 32-bit integers always (for compatibility with reference BLAS). # pointer width, but some expect to use 32-bit integers always
# (for compatibility with reference BLAS).
, blas64 ? null , blas64 ? null
}: }:
@ -8,20 +9,57 @@ with stdenv.lib;
let blas64_ = blas64; in let blas64_ = blas64; in
let local = config.openblas.preferLocalBuild or false; let
binary = # To add support for a new platform, add an element to this set.
{ i686-linux = "32"; configs = {
armv7l-linux = "32"; armv7l-linux = {
x86_64-linux = "64"; BINARY = "32";
x86_64-darwin = "64"; TARGET = "ARMV7";
}."${stdenv.system}" or (throw "unsupported system: ${stdenv.system}"); DYNAMIC_ARCH = "0";
genericFlags = CC = "gcc";
[ "DYNAMIC_ARCH=${if stdenv.system == "armv7l-linux" then "0" else "1"}" USE_OPENMP = "1";
"NUM_THREADS=64" };
];
localFlags = config.openblas.flags or i686-linux = {
optionals (hasAttr "target" config.openblas) [ "TARGET=${config.openblas.target}" ]; BINARY = "32";
blas64 = if blas64_ != null then blas64_ else hasPrefix "x86_64" stdenv.system; TARGET = "P2";
DYNAMIC_ARCH = "1";
CC = "gcc";
USE_OPENMP = "1";
};
x86_64-darwin = {
BINARY = "64";
TARGET = "ATHLON";
DYNAMIC_ARCH = "1";
# Note that clang is available through the stdenv on OSX and
# thus is not an explicit dependency.
CC = "clang";
USE_OPENMP = "0";
MACOSX_DEPLOYMENT_TARGET = "10.7";
};
x86_64-linux = {
BINARY = "64";
TARGET = "ATHLON";
DYNAMIC_ARCH = "1";
CC = "gcc";
USE_OPENMP = "1";
};
};
in
let
config =
configs.${stdenv.system}
or (throw "unsupported system: ${stdenv.system}");
in
let
blas64 =
if blas64_ != null
then blas64_
else hasPrefix "x86_64" stdenv.system;
version = "0.2.19"; version = "0.2.19";
in in
@ -46,29 +84,22 @@ stdenv.mkDerivation {
"stackprotector" "pic" "stackprotector" "pic"
# don't alter index arithmetic # don't alter index arithmetic
"strictoverflow" "strictoverflow"
# don't interfere with dynamic target detection. # don't interfere with dynamic target detection
"relro" "bindnow" "relro" "bindnow"
]; ];
nativeBuildInputs = optionals stdenv.isDarwin [coreutils] ++ [gfortran perl which]; nativeBuildInputs =
[gfortran perl which]
++ optionals stdenv.isDarwin [coreutils];
makeFlags = makeFlags =
(if local then localFlags else genericFlags)
++
optionals stdenv.isDarwin ["MACOSX_DEPLOYMENT_TARGET=10.7"]
++
[ [
"FC=gfortran" "FC=gfortran"
# Note that clang is available through the stdenv on OSX and
# thus is not an explicit dependency.
"CC=${if stdenv.isDarwin then "clang" else "gcc"}"
''PREFIX="''$(out)"'' ''PREFIX="''$(out)"''
"BINARY=${binary}" "NUM_THREADS=64"
"USE_OPENMP=${if stdenv.isDarwin then "0" else "1"}"
"INTERFACE64=${if blas64 then "1" else "0"}" "INTERFACE64=${if blas64 then "1" else "0"}"
] ]
++ ++ mapAttrsToList (var: val: var + "=" + val) config;
optionals (stdenv.system == "armv7l-linux") ["TARGET=ARMV7"];
doCheck = true; doCheck = true;
checkTarget = "tests"; checkTarget = "tests";