2018-07-08 23:01:03 +01:00
|
|
|
{ stdenv, fetchFromGitHub, fetchpatch, gfortran, perl, which, config, coreutils
|
2016-12-10 22:49:45 +00:00
|
|
|
# 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).
|
2015-06-04 00:16:06 +01:00
|
|
|
, blas64 ? null
|
2019-01-05 12:46:40 +00:00
|
|
|
, buildPackages
|
2015-06-04 00:16:06 +01:00
|
|
|
}:
|
2014-08-28 22:39:01 +01:00
|
|
|
|
2015-04-17 13:35:19 +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
|
|
|
|
|
2016-12-10 22:49:45 +00:00
|
|
|
let
|
|
|
|
# To add support for a new platform, add an element to this set.
|
|
|
|
configs = {
|
2017-12-29 22:19:15 +00:00
|
|
|
armv6l-linux = {
|
2019-01-15 15:36:07 +00:00
|
|
|
BINARY = 32;
|
2017-12-29 22:19:15 +00:00
|
|
|
TARGET = "ARMV6";
|
2019-01-15 15:36:07 +00:00
|
|
|
DYNAMIC_ARCH = false;
|
|
|
|
USE_OPENMP = true;
|
2017-12-29 22:19:15 +00:00
|
|
|
};
|
|
|
|
|
2016-12-10 22:49:45 +00:00
|
|
|
armv7l-linux = {
|
2019-01-15 15:36:07 +00:00
|
|
|
BINARY = 32;
|
2016-12-10 22:49:45 +00:00
|
|
|
TARGET = "ARMV7";
|
2019-01-15 15:36:07 +00:00
|
|
|
DYNAMIC_ARCH = false;
|
|
|
|
USE_OPENMP = true;
|
2016-12-10 22:49:45 +00:00
|
|
|
};
|
2014-08-28 22:39:01 +01:00
|
|
|
|
2017-12-07 23:59:50 +00:00
|
|
|
aarch64-linux = {
|
2019-01-15 15:36:07 +00:00
|
|
|
BINARY = 64;
|
2017-12-07 23:59:50 +00:00
|
|
|
TARGET = "ARMV8";
|
2019-01-15 15:36:07 +00:00
|
|
|
DYNAMIC_ARCH = true;
|
|
|
|
USE_OPENMP = true;
|
2017-12-07 23:59:50 +00:00
|
|
|
};
|
|
|
|
|
2016-12-10 22:49:45 +00:00
|
|
|
i686-linux = {
|
2019-01-15 15:36:07 +00:00
|
|
|
BINARY = 32;
|
2016-12-10 22:49:45 +00:00
|
|
|
TARGET = "P2";
|
2019-01-15 15:36:07 +00:00
|
|
|
DYNAMIC_ARCH = true;
|
|
|
|
USE_OPENMP = true;
|
2016-12-10 22:49:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
x86_64-darwin = {
|
2019-01-15 15:36:07 +00:00
|
|
|
BINARY = 64;
|
2016-12-10 22:49:45 +00:00
|
|
|
TARGET = "ATHLON";
|
2019-01-15 15:36:07 +00:00
|
|
|
DYNAMIC_ARCH = true;
|
|
|
|
USE_OPENMP = false;
|
2016-12-10 22:49:45 +00:00
|
|
|
MACOSX_DEPLOYMENT_TARGET = "10.7";
|
|
|
|
};
|
|
|
|
|
|
|
|
x86_64-linux = {
|
2019-01-15 15:36:07 +00:00
|
|
|
BINARY = 64;
|
2016-12-10 22:49:45 +00:00
|
|
|
TARGET = "ATHLON";
|
2019-01-15 15:36:07 +00:00
|
|
|
DYNAMIC_ARCH = true;
|
|
|
|
USE_OPENMP = true;
|
2016-12-10 22:49:45 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
let
|
|
|
|
config =
|
2018-08-20 20:11:29 +01:00
|
|
|
configs.${stdenv.hostPlatform.system}
|
|
|
|
or (throw "unsupported system: ${stdenv.hostPlatform.system}");
|
2016-12-10 22:49:45 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
let
|
|
|
|
blas64 =
|
|
|
|
if blas64_ != null
|
|
|
|
then blas64_
|
2018-08-20 20:11:29 +01:00
|
|
|
else hasPrefix "x86_64" stdenv.hostPlatform.system;
|
2015-10-11 15:16:27 +01:00
|
|
|
in
|
2018-03-12 17:40:49 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2014-08-28 22:39:01 +01:00
|
|
|
name = "openblas-${version}";
|
2019-01-15 15:36:07 +00:00
|
|
|
version = "0.3.5";
|
2018-07-08 23:01:03 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "xianyi";
|
|
|
|
repo = "OpenBLAS";
|
|
|
|
rev = "v${version}";
|
2019-01-15 15:36:07 +00:00
|
|
|
sha256 = "0hwfplr6ciqjvfqkya5vz92z2rx8bhdg5mkh923z246ylhs6d94k";
|
2014-08-28 22:39:01 +01:00
|
|
|
};
|
|
|
|
|
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"
|
2016-12-10 22:49:45 +00:00
|
|
|
# don't interfere with dynamic target detection
|
2016-10-20 22:37:50 +01:00
|
|
|
"relro" "bindnow"
|
|
|
|
];
|
|
|
|
|
2019-01-05 12:46:40 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
perl
|
|
|
|
which
|
|
|
|
buildPackages.gfortran
|
|
|
|
buildPackages.stdenv.cc
|
|
|
|
] ++ optionals stdenv.isDarwin [
|
|
|
|
coreutils
|
|
|
|
];
|
2015-04-17 13:35:19 +01:00
|
|
|
|
2019-01-15 15:36:07 +00:00
|
|
|
makeFlags = mapAttrsToList (var: val: "${var}=${toString val}") (config // {
|
|
|
|
FC = "${stdenv.cc.targetPrefix}gfortran";
|
|
|
|
CC = "${stdenv.cc.targetPrefix}cc";
|
|
|
|
PREFIX = placeholder "out";
|
|
|
|
NUM_THREADS = 64;
|
|
|
|
INTERFACE64 = blas64;
|
|
|
|
NO_STATIC = true;
|
|
|
|
CROSS = stdenv.hostPlatform != stdenv.buildPlatform;
|
|
|
|
HOSTCC = "${buildPackages.stdenv.cc.targetPrefix}cc";
|
|
|
|
NO_BINARY_MODE = stdenv.hostPlatform != stdenv.buildPlatform;
|
|
|
|
});
|
|
|
|
|
|
|
|
doCheck = true;
|
2015-10-11 15:16:27 +01:00
|
|
|
checkTarget = "tests";
|
2015-06-04 00:16:06 +01:00
|
|
|
|
2018-08-17 13:49:52 +01:00
|
|
|
postInstall = ''
|
|
|
|
# Write pkgconfig aliases. Upstream report:
|
|
|
|
# https://github.com/xianyi/OpenBLAS/issues/1740
|
|
|
|
for alias in blas cblas lapack; do
|
2018-09-03 22:56:40 +01:00
|
|
|
cat <<EOF > $out/lib/pkgconfig/$alias.pc
|
2018-08-17 13:49:52 +01:00
|
|
|
Name: $alias
|
|
|
|
Version: ${version}
|
|
|
|
Description: $alias provided by the OpenBLAS package.
|
|
|
|
Cflags: -I$out/include
|
|
|
|
Libs: -L$out/lib -lopenblas
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
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;
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = https://github.com/xianyi/OpenBLAS;
|
2015-11-17 20:29:29 +00:00
|
|
|
platforms = platforms.unix;
|
2014-08-29 16:02:39 +01:00
|
|
|
maintainers = with maintainers; [ ttuegel ];
|
2014-08-28 22:39:01 +01:00
|
|
|
};
|
2018-08-14 07:00:54 +01:00
|
|
|
|
|
|
|
# We use linkName to pass a different name to --with-blas-libs for
|
|
|
|
# fflas-ffpack and linbox, because we use blas on darwin but openblas
|
|
|
|
# elsewhere.
|
|
|
|
# See see https://github.com/NixOS/nixpkgs/pull/45013.
|
|
|
|
passthru.linkName = "openblas";
|
2014-08-28 22:39:01 +01:00
|
|
|
}
|