3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix

116 lines
2.8 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, gfortran, perl, which, config, coreutils
# Most packages depending on openblas expect integer width to match
# pointer width, but some expect to use 32-bit integers always
# (for compatibility with reference BLAS).
, blas64 ? null
}:
2014-08-28 22:39:01 +01:00
with stdenv.lib;
2015-02-26 12:44:03 +00:00
2015-10-11 15:16:27 +01:00
let blas64_ = blas64; in
let
# To add support for a new platform, add an element to this set.
configs = {
armv7l-linux = {
BINARY = "32";
TARGET = "ARMV7";
DYNAMIC_ARCH = "0";
CC = "gcc";
USE_OPENMP = "1";
};
2014-08-28 22:39:01 +01:00
i686-linux = {
BINARY = "32";
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;
2017-07-28 17:08:06 +01:00
version = "0.2.20";
2015-10-11 15:16:27 +01:00
in
stdenv.mkDerivation {
2014-08-28 22:39:01 +01:00
name = "openblas-${version}";
src = fetchurl {
2015-11-05 16:24:31 +00:00
url = "https://github.com/xianyi/OpenBLAS/archive/v${version}.tar.gz";
2017-07-28 17:08:06 +01:00
sha256 = "157kpkbpwlr57dkmqiwr3qp9fglfidagv7l6fibrhln6v4aqpwsy";
2014-08-28 22:39:01 +01:00
name = "openblas-${version}.tar.gz";
};
2015-10-11 15:16:27 +01:00
inherit blas64;
2016-10-20 22:37:50 +01:00
# Some hardening features are disabled due to sporadic failures in
# OpenBLAS-based programs. The problem may not be with OpenBLAS itself, but
# with how these flags interact with hardening measures used downstream.
# In either case, OpenBLAS must only be used by trusted code--it is
# inherently unsuitable for security-conscious applications--so there should
# be no objection to disabling these hardening measures.
hardeningDisable = [
# don't modify or move the stack
"stackprotector" "pic"
# don't alter index arithmetic
"strictoverflow"
# don't interfere with dynamic target detection
2016-10-20 22:37:50 +01:00
"relro" "bindnow"
];
nativeBuildInputs =
[gfortran perl which]
++ optionals stdenv.isDarwin [coreutils];
makeFlags =
[
"FC=gfortran"
''PREFIX="''$(out)"''
"NUM_THREADS=64"
"INTERFACE64=${if blas64 then "1" else "0"}"
"NO_STATIC=1"
]
++ mapAttrsToList (var: val: var + "=" + val) config;
2014-08-28 22:39:01 +01:00
2015-10-11 15:16:27 +01:00
doCheck = true;
checkTarget = "tests";
2014-08-29 16:02:39 +01:00
meta = with stdenv.lib; {
2014-08-28 22:39:01 +01:00
description = "Basic Linear Algebra Subprograms";
2014-08-29 16:02:39 +01:00
license = licenses.bsd3;
homepage = https://github.com/xianyi/OpenBLAS;
platforms = platforms.unix;
2014-08-29 16:02:39 +01:00
maintainers = with maintainers; [ ttuegel ];
2014-08-28 22:39:01 +01:00
};
}