julia03: refactor and build with openblas
Compared to ATLAS, OpenBLAS offers better performance, faster builds, and dynamic architecture detection.
This commit is contained in:
parent
4f98287afa
commit
77a454b866
@ -1,26 +1,24 @@
|
||||
{ stdenv, fetchgit, gfortran, perl, m4, llvm, gmp, pcre, zlib
|
||||
, readline, fftwSinglePrec, fftw, libunwind, suitesparse, glpk, fetchurl
|
||||
, ncurses, libunistring, patchelf, openblas, liblapack
|
||||
, tcl, tk, xproto, libX11, git, mpfr, which, wget
|
||||
} :
|
||||
, readline, fftwSinglePrec, fftw, libunwind, suitesparse, glpk, fetchurl
|
||||
, ncurses, libunistring, patchelf, openblas
|
||||
, tcl, tk, xproto, libX11, git, mpfr, which
|
||||
}:
|
||||
|
||||
assert stdenv.isLinux;
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
realGcc = stdenv.cc.cc;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "julia";
|
||||
version = "0.3.6";
|
||||
name = "${pname}-${version}";
|
||||
arch = head (splitString "-" stdenv.system);
|
||||
march =
|
||||
{
|
||||
"x86_64-linux" = "x86-64";
|
||||
"i686-linux" = "i686";
|
||||
}."${stdenv.system}" or (throw "unsupported system: ${stdenv.system}");
|
||||
|
||||
dsfmt_ver = "2.2";
|
||||
grisu_ver = "1.1.1";
|
||||
openblas_ver = "v0.2.13";
|
||||
lapack_ver = "3.5.0";
|
||||
arpack_ver = "3.1.5";
|
||||
patchelf_ver = "0.8";
|
||||
pcre_ver = "8.36";
|
||||
utf8proc_ver = "1.1.6";
|
||||
|
||||
dsfmt_src = fetchurl {
|
||||
@ -32,33 +30,26 @@ stdenv.mkDerivation rec {
|
||||
url = "http://double-conversion.googlecode.com/files/double-conversion-${grisu_ver}.tar.gz";
|
||||
md5 = "29b533ed4311161267bff1a9a97e2953";
|
||||
};
|
||||
openblas_src = fetchurl {
|
||||
url = "https://github.com/xianyi/OpenBLAS/tarball/${openblas_ver}";
|
||||
name = "openblas-${openblas_ver}.tar.gz";
|
||||
md5 = "74adf4c0d0d82bff4774be5bf2134183";
|
||||
};
|
||||
arpack_src = fetchurl rec {
|
||||
url = "https://github.com/opencollab/arpack-ng/archive/${arpack_ver}.tar.gz";
|
||||
md5 = "d84e1b6108d9ee67c0d21aba7099e953";
|
||||
name = "arpack-ng-${arpack_ver}.tar.gz";
|
||||
};
|
||||
lapack_src = fetchurl {
|
||||
url = "http://www.netlib.org/lapack/lapack-${lapack_ver}.tgz";
|
||||
name = "lapack-${lapack_ver}.tgz";
|
||||
md5 = "b1d3e3e425b2e44a06760ff173104bdf";
|
||||
};
|
||||
patchelf_src = fetchurl {
|
||||
url = "http://hydra.nixos.org/build/1524660/download/2/patchelf-${patchelf_ver}.tar.bz2";
|
||||
md5 = "5087261514b4b5814a39c3d3a36eb6ef";
|
||||
};
|
||||
pcre_src = fetchurl {
|
||||
url = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-${pcre_ver}.tar.bz2";
|
||||
md5 = "b767bc9af0c20bc9c1fe403b0d41ad97";
|
||||
};
|
||||
utf8proc_src = fetchurl {
|
||||
url = "http://www.public-software-group.org/pub/projects/utf8proc/v${utf8proc_ver}/utf8proc-v${utf8proc_ver}.tar.gz";
|
||||
md5 = "2462346301fac2994c34f5574d6c3ca7";
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "julia";
|
||||
version = "0.3.6";
|
||||
name = "${pname}-${version}";
|
||||
|
||||
extraSrcs = [ dsfmt_src grisu_src arpack_src utf8proc_src ];
|
||||
|
||||
src = fetchgit {
|
||||
url = "git://github.com/JuliaLang/julia.git";
|
||||
@ -67,57 +58,79 @@ stdenv.mkDerivation rec {
|
||||
name = "julia-git-v${version}";
|
||||
};
|
||||
|
||||
buildInputs = [ gfortran perl m4 gmp pcre llvm readline zlib
|
||||
buildInputs =
|
||||
[
|
||||
gfortran perl m4 gmp pcre llvm readline zlib
|
||||
fftw fftwSinglePrec libunwind suitesparse glpk ncurses libunistring patchelf
|
||||
openblas liblapack tcl tk xproto libX11 git mpfr which wget
|
||||
openblas tcl tk xproto libX11 git mpfr which
|
||||
];
|
||||
|
||||
makeFlags =
|
||||
[
|
||||
"USE_SYSTEM_PATCHELF=1"
|
||||
"USE_SYSTEM_OPENBLAS=1"
|
||||
"USE_SYSTEM_BLAS=1"
|
||||
"USE_SYSTEM_LAPACK=1"
|
||||
"ARCH=${arch}"
|
||||
"MARCH=${march}"
|
||||
"JULIA_CPU_TARGET=${march}"
|
||||
"PREFIX=$(out)"
|
||||
"prefix=$(out)"
|
||||
"SHELL=${stdenv.shell}"
|
||||
];
|
||||
|
||||
GLPK_PREFIX = "${glpk}/include";
|
||||
|
||||
NIX_CFLAGS_COMPILE = [ "-fPIC" ];
|
||||
NIX_LDFLAGS =
|
||||
optionals
|
||||
(realGcc != null)
|
||||
[
|
||||
"-L${realGcc}/lib"
|
||||
"-L${realGcc}/lib64"
|
||||
"-lpcre" "-lm" "-lfftw3f" "-lfftw3" "-lglpk"
|
||||
"-lunistring" "-lz" "-lgmp" "-lmpfr" "-lopenblas"
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
sed -e "s@/usr/local/lib@$out/lib@g" -i deps/Makefile
|
||||
sed -e "s@/usr/lib@$out/lib@g" -i deps/Makefile
|
||||
|
||||
patchShebangs . contrib
|
||||
|
||||
# ldconfig doesn't seem to ever work on NixOS; system-wide ldconfig cache
|
||||
# is probably not what we want anyway on non-NixOS
|
||||
sed -e "s@/sbin/ldconfig@true@" -i src/ccall.*
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
for i in GMP LLVM PCRE READLINE FFTW LIBUNWIND SUITESPARSE GLPK ZLIB MPFR;
|
||||
do
|
||||
makeFlags="$makeFlags USE_SYSTEM_$i=1 "
|
||||
done
|
||||
makeFlags="$makeFlags JULIA_CPU_TARGET=core2";
|
||||
|
||||
copy_kill_hash(){
|
||||
cp "$1" "$2/$(basename "$1" | sed -e 's/^[a-z0-9]*-//')"
|
||||
}
|
||||
|
||||
for i in "${grisu_src}" "${dsfmt_src}" "${arpack_src}" "${patchelf_src}" \
|
||||
"${pcre_src}" "${utf8proc_src}" "${lapack_src}" "${openblas_src}"; do
|
||||
for i in $extraSrcs; do
|
||||
copy_kill_hash "$i" deps
|
||||
done
|
||||
|
||||
${if realGcc ==null then "" else
|
||||
''export NIX_LDFLAGS="$NIX_LDFLAGS -L${realGcc}/lib -L${realGcc}/lib64 -lpcre -llapack -lm -lfftw3f -lfftw3 -lglpk -lunistring -lz -lgmp -lmpfr -lblas -lopenblas -L$out/lib"''}
|
||||
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -fPIC "
|
||||
${if realGcc ==null then "" else ''export NIX_LDFLAGS="$NIX_LDFLAGS -L$out/lib"''}
|
||||
|
||||
export LDFLAGS="-L${suitesparse}/lib -L$out/lib/julia -Wl,-rpath,$out/lib/julia"
|
||||
|
||||
export GLPK_PREFIX="${glpk}/include"
|
||||
|
||||
mkdir -p "$out/lib"
|
||||
sed -e "s@/usr/local/lib@$out/lib@g" -i deps/Makefile
|
||||
sed -e "s@/usr/lib@$out/lib@g" -i deps/Makefile
|
||||
|
||||
export makeFlags="$makeFlags PREFIX=$out SHELL=${stdenv.shell} prefix=$out"
|
||||
|
||||
export dontPatchELF=1
|
||||
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/usr/lib:$PWD/usr/lib/julia"
|
||||
|
||||
patchShebangs . contrib
|
||||
|
||||
export PATH="$PATH:${stdenv.cc.libc}/sbin"
|
||||
|
||||
# ldconfig doesn't seem to ever work on NixOS; system-wide ldconfig cache
|
||||
# is probably not what we want anyway on non-NixOS
|
||||
sed -e "s@/sbin/ldconfig@true@" -i src/ccall.*
|
||||
|
||||
ln -s "${openblas}/lib/libopenblas.so" "$out/lib/libblas.so"
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
mkdir -p "$out/lib"
|
||||
ln -s "${openblas}/lib/libopenblas.so" "$out/lib/libblas.so"
|
||||
ln -s "${openblas}/lib/libopenblas.so" "$out/lib/liblapack.so"
|
||||
|
||||
mkdir -p usr/lib
|
||||
|
||||
echo "$out"
|
||||
@ -137,6 +150,7 @@ stdenv.mkDerivation rec {
|
||||
'';
|
||||
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
@ -147,8 +161,8 @@ stdenv.mkDerivation rec {
|
||||
description = "High-level performance-oriented dynamical language for technical computing";
|
||||
homepage = "http://julialang.org/";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
maintainers = [ stdenv.lib.maintainers.raskin ];
|
||||
platforms = with stdenv.lib.platforms; linux;
|
||||
maintainers = with stdenv.lib.maintainers; [ raskin ttuegel ];
|
||||
platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
|
||||
broken = false;
|
||||
};
|
||||
}
|
||||
|
@ -3994,13 +3994,8 @@ let
|
||||
suitesparse = suitesparse_4_2;
|
||||
};
|
||||
|
||||
julia03 = let
|
||||
liblapack = liblapack_3_5_0.override {shared = true;};
|
||||
in callPackage ../development/compilers/julia/0.3.nix {
|
||||
inherit liblapack;
|
||||
suitesparse = suitesparse_4_2.override {
|
||||
inherit liblapack;
|
||||
};
|
||||
julia03 = callPackage ../development/compilers/julia/0.3.nix {
|
||||
suitesparse = suitesparse_4_2;
|
||||
llvm = llvm_33;
|
||||
};
|
||||
julia = julia03;
|
||||
|
Loading…
Reference in New Issue
Block a user