From bd280660f75b0da002a6faa456e10ea63d6851bf Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Thu, 4 Jun 2015 11:07:44 -0500 Subject: [PATCH] julia03: clean up LDFLAGS and LD_LIBRARY_PATH There were a few unused LDFLAGS and LD_LIBRARY_PATH settings. There was also an incorrect setting; Julia prefers to be linked to threaded FFTW. The libary names are now set correctly so that it's not necessary to link system libraries into $out/lib/julia as if they were private libraries. The LDFLAGS were also moved out of NIX_LDFLAGS so they will affect only the Julia build itself, and not all the individual private libraries. --- pkgs/development/compilers/julia/0.3.nix | 117 ++++++++++++----------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/pkgs/development/compilers/julia/0.3.nix b/pkgs/development/compilers/julia/0.3.nix index 563e59a2f585..3eb55ad8ac05 100644 --- a/pkgs/development/compilers/julia/0.3.nix +++ b/pkgs/development/compilers/julia/0.3.nix @@ -8,38 +8,12 @@ with stdenv.lib; let realGcc = stdenv.cc.cc; - 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"; - utf8proc_ver = "1.1.6"; - - dsfmt_src = fetchurl { - url = "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-src-${dsfmt_ver}.tar.gz"; - name = "dsfmt-${dsfmt_ver}.tar.gz"; - md5 = "cb61be3be7254eae39684612c524740d"; - }; - grisu_src = fetchurl { - url = "http://double-conversion.googlecode.com/files/double-conversion-${grisu_ver}.tar.gz"; - md5 = "29b533ed4311161267bff1a9a97e2953"; - }; - 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 utf8proc_src ]; - src = fetchgit { url = "git://github.com/JuliaLang/julia.git"; rev = "refs/tags/v${version}"; @@ -47,6 +21,27 @@ stdenv.mkDerivation rec { name = "julia-git-v${version}"; }; + extraSrcs = + let + dsfmt_ver = "2.2"; + grisu_ver = "1.1.1"; + utf8proc_ver = "1.1.6"; + + dsfmt_src = fetchurl { + url = "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/dSFMT-src-${dsfmt_ver}.tar.gz"; + name = "dsfmt-${dsfmt_ver}.tar.gz"; + md5 = "cb61be3be7254eae39684612c524740d"; + }; + grisu_src = fetchurl { + url = "http://double-conversion.googlecode.com/files/double-conversion-${grisu_ver}.tar.gz"; + md5 = "29b533ed4311161267bff1a9a97e2953"; + }; + 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 [ dsfmt_src grisu_src utf8proc_src ]; + buildInputs = [ gfortran perl m4 gmp pcre llvm readline zlib @@ -55,31 +50,37 @@ stdenv.mkDerivation rec { ]; makeFlags = - [ - "USE_SYSTEM_PATCHELF=1" - "USE_SYSTEM_BLAS=1" - "USE_SYSTEM_LAPACK=1" - "USE_SYSTEM_ARPACK=1" + let + arch = head (splitString "-" stdenv.system); + march = + { + "x86_64-linux" = "x86-64"; + "i686-linux" = "i686"; + }."${stdenv.system}" or (throw "unsupported system: ${stdenv.system}"); + in [ "ARCH=${arch}" "MARCH=${march}" "JULIA_CPU_TARGET=${march}" "PREFIX=$(out)" "prefix=$(out)" "SHELL=${stdenv.shell}" + + "USE_SYSTEM_PATCHELF=1" + + "USE_SYSTEM_BLAS=1" + "LIBBLAS=-lopenblas" + "LIBBLASNAME=libopenblas" + + "USE_SYSTEM_LAPACK=1" + "LIBLAPACK=-lopenblas" + "LIBLAPACKNAME=libopenblas" + + "USE_SYSTEM_ARPACK=1" ]; 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 @@ -92,6 +93,24 @@ stdenv.mkDerivation rec { sed -e "s@/sbin/ldconfig@true@" -i src/ccall.* ''; + # Julia tries to load these libraries dynamically at runtime, but they can't be found. + # Easier by far to link against them as usual. + # These go in LDFLAGS, where they affect only Julia itself, and not NIX_LDFLAGS, + # where they would also be used for all the private libraries Julia builds. + LDFLAGS = [ + "-larpack" + "-lfftw3_threads" + "-lfftw3f_threads" + "-lglpk" + "-lgmp" + "-lmpfr" + "-lopenblas" + "-lpcre" + "-lsuitesparse" + "-lunistring" + "-lz" + ]; + configurePhase = '' for i in GMP LLVM PCRE READLINE FFTW LIBUNWIND SUITESPARSE GLPK ZLIB MPFR; do @@ -106,27 +125,9 @@ stdenv.mkDerivation rec { copy_kill_hash "$i" deps done - ${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 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/usr/lib:$PWD/usr/lib/julia" - export PATH="$PATH:${stdenv.cc.libc}/sbin" ''; - preBuild = '' - # Link dynamically loaded shared libraries into output so they are found at runtime. - mkdir -p "$out/lib/julia" - ln -s "${openblas}/lib/libopenblas.so" "$out/lib/julia/libblas.so" - ln -s "${openblas}/lib/libopenblas.so" "$out/lib/julia/liblapack.so" - ln -s "${suitesparse}/lib/libsuitesparse.so" "$out/lib/julia/libsuitesparse.so" - ln -s "${arpack}/lib/libarpack.so" "$out/lib/julia/libarpack.so" - for i in umfpack cholmod amd camd colamd spqr; do - ln -s libsuitesparse.so "$out/lib/julia/lib$i.so"; - done - ''; - dontStrip = true; dontPatchELF = true;