gnu: python-pandas: Fix build on 32-bit.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
CommitLineData
3e4249ce 1;;; GNU Guix --- Functional package management for GNU
a53c486d 2;;; Copyright © 2014, 2016 Eric Bavier <bavier@member.fsf.org>
1204c510 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
7355634d 4;;; Copyright © 2015, 2017 Ludovic Courtès <ludo@gnu.org>
ee077430 5;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
921cb13a 6;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
3e4249ce
EB
7;;;
8;;; This file is part of GNU Guix.
9;;;
10;;; GNU Guix is free software; you can redistribute it and/or modify it
11;;; under the terms of the GNU General Public License as published by
12;;; the Free Software Foundation; either version 3 of the License, or (at
13;;; your option) any later version.
14;;;
15;;; GNU Guix is distributed in the hope that it will be useful, but
16;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;;; GNU General Public License for more details.
19;;;
20;;; You should have received a copy of the GNU General Public License
21;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23(define-module (gnu packages llvm)
24 #:use-module (guix packages)
ac00973c 25 #:use-module ((guix licenses) #:prefix license:)
3e4249ce
EB
26 #:use-module (guix download)
27 #:use-module (guix utils)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system cmake)
30 #:use-module (gnu packages)
fd6ae1b9
LC
31 #:use-module (gnu packages gcc)
32 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
ee077430
EB
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages libffi)
3e4249ce
EB
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages python)
37 #:use-module (gnu packages xml))
38
39(define-public llvm
40 (package
41 (name "llvm")
3b956a33 42 (version "3.8.1")
3e4249ce
EB
43 (source
44 (origin
45 (method url-fetch)
46 (uri (string-append "http://llvm.org/releases/"
47 version "/llvm-" version ".src.tar.xz"))
48 (sha256
49 (base32
3b956a33 50 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))
3e4249ce
EB
51 (build-system cmake-build-system)
52 (native-inputs
3ebc0905 53 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
3e4249ce 54 ("perl" ,perl)))
ee077430 55 (inputs
44e8559d
EB
56 `(("libffi" ,libffi)))
57 (propagated-inputs
58 `(("zlib" ,zlib))) ;to use output from llvm-config
3e4249ce 59 (arguments
22d0e9b7 60 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
ee077430 61 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
ab78618f 62 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
22897187
DC
63 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
64 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
0935fb27
EB
65
66 ;; Don't use '-g' during the build, to save space.
ab78618f
EB
67 #:build-type "Release"
68 #:phases (modify-phases %standard-phases
69 (add-before 'build 'shared-lib-workaround
70 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
71 ;; doesn't seem to get the correct rpath to be able to run
72 ;; from the build directory. Set LD_LIBRARY_PATH as a
73 ;; workaround.
74 (lambda _
75 (setenv "LD_LIBRARY_PATH"
76 (string-append (getcwd) "/lib"))
77 #t)))))
3e4249ce
EB
78 (home-page "http://www.llvm.org")
79 (synopsis "Optimizing compiler infrastructure")
80 (description
e881752c
AK
81 "LLVM is a compiler infrastructure designed for compile-time, link-time,
82runtime, and idle-time optimization of programs from arbitrary programming
83languages. It currently supports compilation of C and C++ programs, using
84front-ends derived from GCC 4.0.1. A new front-end for the C family of
85languages is in development. The compiler infrastructure includes mirror sets
86of programming tools as well as libraries with equivalent functionality.")
ac00973c 87 (license license:ncsa)))
3e4249ce 88
83c49858
RW
89(define-public llvm-with-rtti
90 (package (inherit llvm)
91 (name "llvm-with-rtti")
92 (arguments
93 (substitute-keyword-arguments (package-arguments llvm)
94 ((#:configure-flags flags)
95 `(append '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
96 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
97 "-DLLVM_REQUIRES_RTTI=1")
98 ,flags))))))
99
b81f5693
AW
100(define (clang-runtime-from-llvm llvm hash)
101 (package
102 (name "clang-runtime")
103 (version (package-version llvm))
104 (source
105 (origin
106 (method url-fetch)
107 (uri (string-append "http://llvm.org/releases/"
108 version "/compiler-rt-" version ".src.tar.xz"))
109 (sha256 (base32 hash))))
110 (build-system cmake-build-system)
111 (native-inputs (package-native-inputs llvm))
112 (inputs
113 `(("llvm" ,llvm)))
114 (arguments
115 `(;; Don't use '-g' during the build to save space.
3b956a33
EB
116 #:build-type "Release"
117 #:tests? #f)) ; Tests require gtest
b81f5693
AW
118 (home-page "http://compiler-rt.llvm.org")
119 (synopsis "Runtime library for Clang/LLVM")
120 (description
121 "The \"clang-runtime\" library provides the implementations of run-time
122functions for C and C++ programs. It also provides header files that allow C
123and C++ source code to interface with the \"sanitization\" passes of the clang
124compiler. In LLVM this library is called \"compiler-rt\".")
ac00973c 125 (license license:ncsa)
9e6b9ea4
LC
126
127 ;; <http://compiler-rt.llvm.org/> doesn't list MIPS as supported.
128 (supported-systems (delete "mips64el-linux" %supported-systems))))
b81f5693 129
3b956a33
EB
130(define* (clang-from-llvm llvm clang-runtime hash
131 #:key (patches '("clang-libc-search-path.patch")))
3e4249ce
EB
132 (package
133 (name "clang")
134 (version (package-version llvm))
135 (source
136 (origin
137 (method url-fetch)
138 (uri (string-append "http://llvm.org/releases/"
139 version "/cfe-" version ".src.tar.xz"))
fd6ae1b9 140 (sha256 (base32 hash))
3b956a33 141 (patches (map search-patch patches))))
3e4249ce
EB
142 ;; Using cmake allows us to treat llvm as an external library. There
143 ;; doesn't seem to be any way to do this with clang's autotools-based
144 ;; build system.
145 (build-system cmake-build-system)
146 (native-inputs (package-native-inputs llvm))
147 (inputs
148 `(("libxml2" ,libxml2)
c92f1c0a 149 ("gcc-lib" ,gcc "lib")
3e4249ce
EB
150 ,@(package-inputs llvm)))
151 (propagated-inputs
b81f5693
AW
152 `(("llvm" ,llvm)
153 ("clang-runtime" ,clang-runtime)))
fd6ae1b9
LC
154 (arguments
155 `(#:configure-flags
156 (list "-DCLANG_INCLUDE_TESTS=True"
157
158 ;; Find libgcc_s, crtbegin.o, and crtend.o.
159 (string-append "-DGCC_INSTALL_PREFIX="
160 (assoc-ref %build-inputs "gcc-lib"))
161
162 ;; Use a sane default include directory.
163 (string-append "-DC_INCLUDE_DIRS="
164 (assoc-ref %build-inputs "libc")
165 "/include"))
166
94585e88
LC
167 ;; Don't use '-g' during the build to save space.
168 #:build-type "Release"
169
fd6ae1b9
LC
170 #:phases (modify-phases %standard-phases
171 (add-after
172 'unpack 'set-glibc-file-names
173 (lambda* (#:key inputs #:allow-other-keys)
b81f5693
AW
174 (let ((libc (assoc-ref inputs "libc"))
175 (compiler-rt (assoc-ref inputs "clang-runtime")))
fd6ae1b9 176 (substitute* "lib/Driver/Tools.cpp"
b81f5693
AW
177 ;; Patch the 'getLinuxDynamicLinker' function to that
178 ;; it uses the right dynamic linker file name.
fd6ae1b9
LC
179 (("/lib64/ld-linux-x86-64.so.2")
180 (string-append libc
b81f5693
AW
181 ,(glibc-dynamic-linker)))
182
183 ;; Link to libclang_rt files from clang-runtime.
184 (("TC\\.getDriver\\(\\)\\.ResourceDir")
185 (string-append "\"" compiler-rt "\"")))
fd6ae1b9
LC
186
187 ;; Same for libc's libdir, to allow crt1.o & co. to be
188 ;; found.
189 (substitute* "lib/Driver/ToolChains.cpp"
190 (("@GLIBC_LIBDIR@")
191 (string-append libc "/lib")))))))))
ef11ac87
LC
192
193 ;; Clang supports the same environment variables as GCC.
194 (native-search-paths
195 (list (search-path-specification
196 (variable "CPATH")
197 (files '("include")))
198 (search-path-specification
199 (variable "LIBRARY_PATH")
200 (files '("lib" "lib64")))))
201
3e4249ce
EB
202 (home-page "http://clang.llvm.org")
203 (synopsis "C language family frontend for LLVM")
204 (description
205 "Clang is a compiler front end for the C, C++, Objective-C and
206Objective-C++ programming languages. It uses LLVM as its back end. The Clang
207project includes the Clang front end, the Clang static analyzer, and several
208code analysis tools.")
ac00973c 209 (license license:ncsa)))
1204c510 210
b81f5693
AW
211(define-public clang-runtime
212 (clang-runtime-from-llvm
213 llvm
3b956a33 214 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"))
b81f5693 215
1204c510 216(define-public clang
b81f5693 217 (clang-from-llvm llvm clang-runtime
3b956a33
EB
218 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
219 #:patches '("clang-3.8-libc-search-path.patch")))
220
221(define-public llvm-3.7
222 (package (inherit llvm)
223 (version "3.7.1")
224 (source
225 (origin
226 (method url-fetch)
227 (uri (string-append "http://llvm.org/releases/"
228 version "/llvm-" version ".src.tar.xz"))
229 (sha256
230 (base32
231 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
232
233(define-public clang-runtime-3.7
234 (clang-runtime-from-llvm
235 llvm-3.7
236 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"))
237
238(define-public clang-3.7
239 (clang-from-llvm llvm-3.7 clang-runtime-3.7
3ebc0905
EB
240 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"))
241
242(define-public llvm-3.6
243 (package (inherit llvm)
244 (version "3.6.2")
245 (source
246 (origin
247 (method url-fetch)
248 (uri (string-append "http://llvm.org/releases/"
249 version "/llvm-" version ".src.tar.xz"))
250 (sha256
251 (base32
252 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
253
254(define-public clang-runtime-3.6
255 (clang-runtime-from-llvm
256 llvm-3.6
257 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"))
258
259(define-public clang-3.6
260 (clang-from-llvm llvm-3.6 clang-runtime-3.6
be23021d 261 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"))
1204c510
MW
262
263(define-public llvm-3.5
264 (package (inherit llvm)
a53c486d 265 (version "3.5.2")
1204c510
MW
266 (source
267 (origin
268 (method url-fetch)
269 (uri (string-append "http://llvm.org/releases/"
270 version "/llvm-" version ".src.tar.xz"))
271 (sha256
272 (base32
a53c486d 273 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1204c510 274
b81f5693
AW
275(define-public clang-runtime-3.5
276 (clang-runtime-from-llvm
277 llvm-3.5
a53c486d 278 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"))
b81f5693 279
1204c510 280(define-public clang-3.5
b81f5693 281 (clang-from-llvm llvm-3.5 clang-runtime-3.5
a53c486d 282 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"))
921cb13a
RW
283
284(define-public llvm-for-extempore
285 (package (inherit llvm-3.7)
7355634d 286 (name "llvm-for-extempore")
921cb13a
RW
287 (source
288 (origin
289 (inherit (package-source llvm-3.7))
39162ee4
RW
290 (patches (list (search-patch "llvm-for-extempore.patch")))))
291 ;; Extempore refuses to build on architectures other than x86_64
292 (supported-systems '("x86_64-linux"))))