1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu packages julia)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix build-system gnu)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages algebra)
26 #:use-module (gnu packages base)
27 #:use-module (gnu packages elf)
28 #:use-module (gnu packages gcc)
29 #:use-module (gnu packages llvm)
30 #:use-module (gnu packages libunwind)
31 #:use-module (gnu packages maths)
32 #:use-module (gnu packages multiprecision) ; mpfr
33 #:use-module (gnu packages pcre)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages python)
37 #:use-module (gnu packages textutils)
38 #:use-module (gnu packages version-control)
39 #:use-module (ice-9 match))
48 "https://github.com/JuliaLang/julia/releases/download/v"
49 version "/julia-" version "_c8ceeefcc1.tar.gz"))
52 "0j6mw6wr35lxid10nh9gz7k6wck3a90ic92w99n1r052325gl9r7"))
53 (patches (list (search-patch "julia-0.3.10-fix-empty-array.patch")))))
54 (build-system gnu-build-system)
56 `(#:test-target "test"
57 #:modules ((ice-9 match)
58 (guix build gnu-build-system)
62 ;; The DSOs use $ORIGIN to refer to each other, but (guix build
63 ;; gremlin) doesn't support it yet, so skip this phase.
64 #:validate-runpath? #f
67 (modify-phases %standard-phases
70 'unpack 'hardcode-soname-map
71 ;; ./src/ccall.cpp creates a map from library names to paths using the
72 ;; output of "/sbin/ldconfig -p". Since ldconfig is not used in Guix,
73 ;; we patch ccall.cpp to contain a static map.
74 (lambda* (#:key inputs #:allow-other-keys)
75 (use-modules (ice-9 match))
76 (substitute* "src/ccall.cpp"
77 (("jl_read_sonames.*;")
80 ((input libname soname)
82 "sonameMap[\"" libname "\"] = "
83 "\"" (assoc-ref inputs input) "/lib/" soname "\";")))
84 '(("libc" "libc" "libc.so.6")
85 ("pcre" "libpcre" "libpcre.so")
86 ("mpfr" "libmpfr" "libmpfr.so")
87 ("openblas" "libblas" "libopenblas.so")
88 ("arpack-ng" "libarpack" "libarpack.so")
89 ("lapack" "liblapack" "liblapack.so")
90 ("gmp" "libgmp" "libgmp.so")
91 ("openlibm" "libopenlibm" "libopenlibm.so")
92 ("openspecfun" "libopenspecfun" "libopenspecfun.so")
93 ("fftw" "libfftw3" "libfftw3.so")
94 ("fftwf" "libfftw3f" "libfftw3f.so"))))))
96 ;; This phase will no longer be necessary in 0.3.11; see
97 ;; https://github.com/JuliaLang/julia/issues/12028
99 'build 'fix-building-with-mcjit-llvm
101 (substitute* "src/cgutils.cpp"
102 (("addComdat\\(gv\\);") ""))
105 'build 'patch-include-path
107 (substitute* "deps/Makefile"
108 (("/usr/include/double-conversion")
109 (string-append (assoc-ref %build-inputs "double-conversion")
110 "/include/double-conversion")))
113 'build 'replace-default-shell
115 (substitute* "base/client.jl"
116 (("/bin/sh") (which "sh")))
119 'check 'disable-broken-test
120 ;; One test fails because it produces slightly different output.
122 (substitute* "test/repl.jl"
123 (("@test output") "# @test output"))
127 (string-append "prefix=" (assoc-ref %outputs "out"))
129 ;; Passing the MARCH flag is necessary to build binary substitutes for
130 ;; the supported architectures.
131 ,(match (or (%current-target-system)
133 ("x86_64-linux" "MARCH=x86-64")
134 ("i686-linux" "MARCH=pentium4")
135 ;; Prevent errors when querying this package on unsupported
136 ;; platforms, e.g. when running "guix package --search="
137 (_ "MARCH=UNSUPPORTED"))
139 "CONFIG_SHELL=bash" ;needed to build bundled libraries
140 "USE_SYSTEM_LIBUV=0" ;Julia expects a modified libuv
141 "USE_SYSTEM_DSFMT=0" ;not packaged for Guix and upstream has no
142 ;build system for a shared library.
143 "USE_SYSTEM_RMATH=0" ;Julia uses a bundled version of R's math
144 ;library, patched to use the DSFMT RNG.
146 "USE_SYSTEM_LAPACK=1"
148 "USE_BLAS64=0" ;needed when USE_SYSTEM_BLAS=1
151 "LIBFFTWNAME=libfftw3"
152 "LIBFFTWFNAME=libfftw3f"
154 ;; TODO: Suitesparse does not install shared libraries, so we cannot
155 ;; use the suitesparse package.
156 ;; "USE_SYSTEM_SUITESPARSE=1"
157 ;; (string-append "SUITESPARSE_INC=-I "
158 ;; (assoc-ref %build-inputs "suitesparse")
161 "USE_SYSTEM_GRISU=1" ;for double-conversion
162 "USE_SYSTEM_UTF8PROC=1"
164 "USE_SYSTEM_LIBUNWIND=1"
166 "USE_SYSTEM_OPENLIBM=1"
169 "USE_SYSTEM_ARPACK=1"
170 "USE_SYSTEM_LIBGIT2=1"
171 "USE_SYSTEM_OPENSPECFUN=1")))
174 ("arpack-ng" ,arpack-ng)
176 ("openblas" ,openblas) ;Julia does not build with Atlas
177 ("libunwind" ,libunwind)
178 ("openlibm" ,openlibm)
179 ("openspecfun" ,openspecfun)
180 ("double-conversion" ,double-conversion)
183 ("fortran" ,gfortran)
185 ("utf8proc" ,utf8proc)
191 ("patchelf" ,patchelf)
192 ("pkg-config" ,pkg-config)
195 ;; Julia is not officially released for ARM and MIPS.
196 ;; See https://github.com/JuliaLang/julia/issues/10639
197 (supported-systems '("i686-linux" "x86_64-linux"))
198 (home-page "http://julialang.org/")
199 (synopsis "High-performance dynamic language for technical computing")
201 "Julia is a high-level, high-performance dynamic programming language for
202 technical computing, with syntax that is familiar to users of other technical
203 computing environments. It provides a sophisticated compiler, distributed
204 parallel execution, numerical accuracy, and an extensive mathematical function
206 (license license:expat)))