gnu: python-llvmlite: Remove obsolete patch.
[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>
6b26f915 4;;; Copyright © 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
ee077430 5;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
8892cac3 6;;; Copyright © 2016, 2018 Ricardo Wurmus <rekado@elephly.net>
584da12d 7;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
9bdbabe9 8;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
148df605 9;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
3e4249ce
EB
10;;;
11;;; This file is part of GNU Guix.
12;;;
13;;; GNU Guix is free software; you can redistribute it and/or modify it
14;;; under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 3 of the License, or (at
16;;; your option) any later version.
17;;;
18;;; GNU Guix is distributed in the hope that it will be useful, but
19;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;;; GNU General Public License for more details.
22;;;
23;;; You should have received a copy of the GNU General Public License
24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26(define-module (gnu packages llvm)
27 #:use-module (guix packages)
ac00973c 28 #:use-module ((guix licenses) #:prefix license:)
3e4249ce
EB
29 #:use-module (guix download)
30 #:use-module (guix utils)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system cmake)
8892cac3 33 #:use-module (guix build-system python)
3e4249ce 34 #:use-module (gnu packages)
fd6ae1b9
LC
35 #:use-module (gnu packages gcc)
36 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
ee077430
EB
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages libffi)
3e4249ce
EB
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages python)
41 #:use-module (gnu packages xml))
42
43(define-public llvm
44 (package
45 (name "llvm")
148df605 46 (version "6.0.1")
3e4249ce
EB
47 (source
48 (origin
49 (method url-fetch)
50 (uri (string-append "http://llvm.org/releases/"
51 version "/llvm-" version ".src.tar.xz"))
52 (sha256
53 (base32
148df605 54 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))
3e4249ce
EB
55 (build-system cmake-build-system)
56 (native-inputs
3ebc0905 57 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
3e4249ce 58 ("perl" ,perl)))
ee077430 59 (inputs
44e8559d
EB
60 `(("libffi" ,libffi)))
61 (propagated-inputs
62 `(("zlib" ,zlib))) ;to use output from llvm-config
3e4249ce 63 (arguments
22d0e9b7 64 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
ee077430 65 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
ab78618f 66 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
22897187
DC
67 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
68 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
0935fb27
EB
69
70 ;; Don't use '-g' during the build, to save space.
ab78618f
EB
71 #:build-type "Release"
72 #:phases (modify-phases %standard-phases
73 (add-before 'build 'shared-lib-workaround
74 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
75 ;; doesn't seem to get the correct rpath to be able to run
76 ;; from the build directory. Set LD_LIBRARY_PATH as a
77 ;; workaround.
78 (lambda _
79 (setenv "LD_LIBRARY_PATH"
80 (string-append (getcwd) "/lib"))
81 #t)))))
ac97dce1 82 (home-page "https://www.llvm.org")
3e4249ce
EB
83 (synopsis "Optimizing compiler infrastructure")
84 (description
e881752c
AK
85 "LLVM is a compiler infrastructure designed for compile-time, link-time,
86runtime, and idle-time optimization of programs from arbitrary programming
87languages. It currently supports compilation of C and C++ programs, using
88front-ends derived from GCC 4.0.1. A new front-end for the C family of
89languages is in development. The compiler infrastructure includes mirror sets
90of programming tools as well as libraries with equivalent functionality.")
ac00973c 91 (license license:ncsa)))
3e4249ce 92
83c49858
RW
93(define-public llvm-with-rtti
94 (package (inherit llvm)
95 (name "llvm-with-rtti")
96 (arguments
97 (substitute-keyword-arguments (package-arguments llvm)
98 ((#:configure-flags flags)
99 `(append '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
100 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
101 "-DLLVM_REQUIRES_RTTI=1")
102 ,flags))))))
103
6b26f915
LC
104(define* (clang-runtime-from-llvm llvm hash
105 #:optional (patches '()))
b81f5693
AW
106 (package
107 (name "clang-runtime")
108 (version (package-version llvm))
109 (source
110 (origin
111 (method url-fetch)
112 (uri (string-append "http://llvm.org/releases/"
113 version "/compiler-rt-" version ".src.tar.xz"))
6b26f915
LC
114 (sha256 (base32 hash))
115 (patches (map search-patch patches))))
b81f5693
AW
116 (build-system cmake-build-system)
117 (native-inputs (package-native-inputs llvm))
118 (inputs
119 `(("llvm" ,llvm)))
120 (arguments
121 `(;; Don't use '-g' during the build to save space.
3b956a33
EB
122 #:build-type "Release"
123 #:tests? #f)) ; Tests require gtest
ac97dce1 124 (home-page "https://compiler-rt.llvm.org")
b81f5693
AW
125 (synopsis "Runtime library for Clang/LLVM")
126 (description
127 "The \"clang-runtime\" library provides the implementations of run-time
128functions for C and C++ programs. It also provides header files that allow C
129and C++ source code to interface with the \"sanitization\" passes of the clang
130compiler. In LLVM this library is called \"compiler-rt\".")
ac00973c 131 (license license:ncsa)
9e6b9ea4 132
ac97dce1 133 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
9e6b9ea4 134 (supported-systems (delete "mips64el-linux" %supported-systems))))
b81f5693 135
3b956a33 136(define* (clang-from-llvm llvm clang-runtime hash
9bdbabe9 137 #:key (patches '()))
3e4249ce
EB
138 (package
139 (name "clang")
140 (version (package-version llvm))
141 (source
142 (origin
143 (method url-fetch)
144 (uri (string-append "http://llvm.org/releases/"
145 version "/cfe-" version ".src.tar.xz"))
fd6ae1b9 146 (sha256 (base32 hash))
3b956a33 147 (patches (map search-patch patches))))
3e4249ce
EB
148 ;; Using cmake allows us to treat llvm as an external library. There
149 ;; doesn't seem to be any way to do this with clang's autotools-based
150 ;; build system.
151 (build-system cmake-build-system)
152 (native-inputs (package-native-inputs llvm))
153 (inputs
154 `(("libxml2" ,libxml2)
c92f1c0a 155 ("gcc-lib" ,gcc "lib")
3e4249ce
EB
156 ,@(package-inputs llvm)))
157 (propagated-inputs
b81f5693
AW
158 `(("llvm" ,llvm)
159 ("clang-runtime" ,clang-runtime)))
fd6ae1b9
LC
160 (arguments
161 `(#:configure-flags
162 (list "-DCLANG_INCLUDE_TESTS=True"
163
164 ;; Find libgcc_s, crtbegin.o, and crtend.o.
165 (string-append "-DGCC_INSTALL_PREFIX="
166 (assoc-ref %build-inputs "gcc-lib"))
167
168 ;; Use a sane default include directory.
169 (string-append "-DC_INCLUDE_DIRS="
170 (assoc-ref %build-inputs "libc")
171 "/include"))
172
94585e88
LC
173 ;; Don't use '-g' during the build to save space.
174 #:build-type "Release"
175
fd6ae1b9
LC
176 #:phases (modify-phases %standard-phases
177 (add-after
178 'unpack 'set-glibc-file-names
179 (lambda* (#:key inputs #:allow-other-keys)
b81f5693
AW
180 (let ((libc (assoc-ref inputs "libc"))
181 (compiler-rt (assoc-ref inputs "clang-runtime")))
9bdbabe9
MB
182 (case (string->number ,(version-major
183 (package-version clang-runtime)))
184 ((6)
185 ;; Link to libclang_rt files from clang-runtime.
186 (substitute* "lib/Driver/ToolChain.cpp"
187 (("getDriver\\(\\)\\.ResourceDir")
188 (string-append "\"" compiler-rt "\"")))
189
190 ;; Make "LibDir" refer to <glibc>/lib so that it
191 ;; uses the right dynamic linker file name.
192 (substitute* "lib/Driver/ToolChains/Linux.cpp"
193 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
194 (string-append declaration "\"" libc "/lib\";\n"))
195
196 ;; Make sure libc's libdir is on the search path, to
197 ;; allow crt1.o & co. to be found.
198 (("@GLIBC_LIBDIR@")
199 (string-append libc "/lib"))))
200 ((3)
201 (substitute* "lib/Driver/Tools.cpp"
202 ;; Patch the 'getLinuxDynamicLinker' function so that
203 ;; it uses the right dynamic linker file name.
204 (("/lib64/ld-linux-x86-64.so.2")
205 (string-append libc
206 ,(glibc-dynamic-linker))))
207
208 ;; Link to libclang_rt files from clang-runtime.
209 ;; This substitution needed slight adjustment in 3.8.
210 (if (< 3.8 (string->number ,(version-major+minor
211 (package-version
212 clang-runtime))))
213 (substitute* "lib/Driver/Tools.cpp"
214 (("TC\\.getDriver\\(\\)\\.ResourceDir")
215 (string-append "\"" compiler-rt "\"")))
216 (substitute* "lib/Driver/ToolChain.cpp"
217 (("getDriver\\(\\)\\.ResourceDir")
218 (string-append "\"" compiler-rt "\""))))
219
220 ;; Make sure libc's libdir is on the search path, to
221 ;; allow crt1.o & co. to be found.
222 (substitute* "lib/Driver/ToolChains.cpp"
223 (("@GLIBC_LIBDIR@")
224 (string-append libc "/lib")))))
225 #t))))))
ef11ac87
LC
226
227 ;; Clang supports the same environment variables as GCC.
228 (native-search-paths
229 (list (search-path-specification
230 (variable "CPATH")
231 (files '("include")))
232 (search-path-specification
233 (variable "LIBRARY_PATH")
234 (files '("lib" "lib64")))))
235
ac97dce1 236 (home-page "https://clang.llvm.org")
3e4249ce
EB
237 (synopsis "C language family frontend for LLVM")
238 (description
239 "Clang is a compiler front end for the C, C++, Objective-C and
240Objective-C++ programming languages. It uses LLVM as its back end. The Clang
241project includes the Clang front end, the Clang static analyzer, and several
242code analysis tools.")
ac00973c 243 (license license:ncsa)))
1204c510 244
b81f5693
AW
245(define-public clang-runtime
246 (clang-runtime-from-llvm
247 llvm
148df605 248 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"))
b81f5693 249
1204c510 250(define-public clang
b81f5693 251 (clang-from-llvm llvm clang-runtime
148df605 252 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
9bdbabe9 253 #:patches '("clang-6.0-libc-search-path.patch")))
3b956a33 254
584da12d
RJ
255(define-public llvm-3.9.1
256 (package (inherit llvm)
257 (name "llvm")
258 (version "3.9.1")
259 (source
260 (origin
261 (method url-fetch)
262 (uri (string-append "http://llvm.org/releases/"
263 version "/llvm-" version ".src.tar.xz"))
264 (sha256
265 (base32
266 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
267
268(define-public clang-runtime-3.9.1
269 (clang-runtime-from-llvm
270 llvm-3.9.1
6b26f915
LC
271 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
272 '("clang-runtime-asan-build-fixes.patch"
273 "clang-runtime-esan-build-fixes.patch")))
584da12d
RJ
274
275(define-public clang-3.9.1
276 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
277 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
9bdbabe9
MB
278 #:patches '("clang-3.8-libc-search-path.patch")))
279
280(define-public llvm-3.8
281 (package (inherit llvm)
282 (name "llvm")
283 (version "3.8.1")
284 (source
285 (origin
286 (method url-fetch)
287 (uri (string-append "https://llvm.org/releases/"
288 version "/llvm-" version ".src.tar.xz"))
289 (sha256
290 (base32
291 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
292
293(define-public clang-runtime-3.8
294 (clang-runtime-from-llvm
295 llvm-3.8
296 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
297 '("clang-runtime-asan-build-fixes.patch")))
298
299(define-public clang-3.8
300 (clang-from-llvm llvm-3.8 clang-runtime-3.8
301 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
302 #:patches '("clang-3.8-libc-search-path.patch")))
584da12d 303
3b956a33
EB
304(define-public llvm-3.7
305 (package (inherit llvm)
306 (version "3.7.1")
307 (source
308 (origin
309 (method url-fetch)
310 (uri (string-append "http://llvm.org/releases/"
311 version "/llvm-" version ".src.tar.xz"))
312 (sha256
313 (base32
314 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
315
316(define-public clang-runtime-3.7
317 (clang-runtime-from-llvm
318 llvm-3.7
6b26f915
LC
319 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
320 '("clang-runtime-asan-build-fixes.patch")))
3b956a33
EB
321
322(define-public clang-3.7
323 (clang-from-llvm llvm-3.7 clang-runtime-3.7
9bdbabe9
MB
324 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
325 #:patches '("clang-3.5-libc-search-path.patch")))
3ebc0905
EB
326
327(define-public llvm-3.6
328 (package (inherit llvm)
329 (version "3.6.2")
330 (source
331 (origin
332 (method url-fetch)
333 (uri (string-append "http://llvm.org/releases/"
334 version "/llvm-" version ".src.tar.xz"))
335 (sha256
336 (base32
337 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
338
339(define-public clang-runtime-3.6
340 (clang-runtime-from-llvm
341 llvm-3.6
6b26f915
LC
342 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
343 '("clang-runtime-asan-build-fixes.patch")))
3ebc0905
EB
344
345(define-public clang-3.6
346 (clang-from-llvm llvm-3.6 clang-runtime-3.6
9bdbabe9
MB
347 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
348 #:patches '("clang-3.5-libc-search-path.patch")))
1204c510
MW
349
350(define-public llvm-3.5
351 (package (inherit llvm)
a53c486d 352 (version "3.5.2")
1204c510
MW
353 (source
354 (origin
355 (method url-fetch)
356 (uri (string-append "http://llvm.org/releases/"
357 version "/llvm-" version ".src.tar.xz"))
6ba4eca2
RW
358 (patches
359 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1204c510
MW
360 (sha256
361 (base32
a53c486d 362 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1204c510 363
b81f5693
AW
364(define-public clang-runtime-3.5
365 (clang-runtime-from-llvm
366 llvm-3.5
6b26f915
LC
367 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
368 '("clang-runtime-asan-build-fixes.patch")))
b81f5693 369
1204c510 370(define-public clang-3.5
b81f5693 371 (clang-from-llvm llvm-3.5 clang-runtime-3.5
9bdbabe9
MB
372 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
373 #:patches '("clang-3.5-libc-search-path.patch")))
921cb13a
RW
374
375(define-public llvm-for-extempore
376 (package (inherit llvm-3.7)
7355634d 377 (name "llvm-for-extempore")
921cb13a
RW
378 (source
379 (origin
380 (inherit (package-source llvm-3.7))
39162ee4
RW
381 (patches (list (search-patch "llvm-for-extempore.patch")))))
382 ;; Extempore refuses to build on architectures other than x86_64
383 (supported-systems '("x86_64-linux"))))
8892cac3
RW
384
385(define-public python-llvmlite
386 (package
387 (name "python-llvmlite")
388 (version "0.24.0")
389 (source
390 (origin
391 (method url-fetch)
392 (uri (pypi-uri "llvmlite" version))
393 (sha256
394 (base32
395 "01zwjlc3c5mhrwmv4b73zgbskwqps9ly0nrh54bbj1f1l72f839j"))))
396 (build-system python-build-system)
397 (inputs
398 `(("llvm"
399 ,(package
400 (inherit llvm)
401 (source (origin
402 (inherit (package-source llvm))
403 (patches
404 (list
405 (origin
406 (method url-fetch)
407 (uri (string-append "https://raw.githubusercontent.com/numba/"
408 "llvmlite/v" version "/conda-recipes/"
409 "D47188-svml.patch"))
410 (sha256
411 (base32
412 "0mrj24jvkv3hjcmyg98zmvmyl1znlh2j63rdr69f6g7s96d2pfv1")))
413 (origin
414 (method url-fetch)
415 (uri (string-append "https://raw.githubusercontent.com/numba/"
416 "llvmlite/v" version "/conda-recipes/"
417 "twine_cfg_undefined_behavior.patch"))
418 (sha256
419 (base32
7a20877a 420 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
8892cac3
RW
421 (home-page "http://llvmlite.pydata.org")
422 (synopsis "Wrapper around basic LLVM functionality")
423 (description
424 "This package provides a Python binding to LLVM for use in Numba.")
425 (license license:bsd-3)))