Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
CommitLineData
3e4249ce 1;;; GNU Guix --- Functional package management for GNU
fc9dbf41 2;;; Copyright © 2014, 2016, 2018 Eric Bavier <bavier@member.fsf.org>
1204c510 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
286bea0d 4;;; Copyright © 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
ee077430 5;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
9f0ce5ec 6;;; Copyright © 2016, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
584da12d 7;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
d199a4c7 8;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
e2170c31 9;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
0627f93d 10;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
7628ff1f
TG
11;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
12;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
c5296e20 13;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
5dea5cbc 14;;; Copyright © 2019 Arm Ltd <David.Truby@arm.com>
57c7bfec 15;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
66087272 16;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
3e4249ce
EB
17;;;
18;;; This file is part of GNU Guix.
19;;;
20;;; GNU Guix is free software; you can redistribute it and/or modify it
21;;; under the terms of the GNU General Public License as published by
22;;; the Free Software Foundation; either version 3 of the License, or (at
23;;; your option) any later version.
24;;;
25;;; GNU Guix is distributed in the hope that it will be useful, but
26;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28;;; GNU General Public License for more details.
29;;;
30;;; You should have received a copy of the GNU General Public License
31;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32
33(define-module (gnu packages llvm)
34 #:use-module (guix packages)
ac00973c 35 #:use-module ((guix licenses) #:prefix license:)
3e4249ce 36 #:use-module (guix download)
a2cc25ab 37 #:use-module (guix git-download)
3e4249ce
EB
38 #:use-module (guix utils)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system cmake)
7628ff1f 41 #:use-module (guix build-system emacs)
8892cac3 42 #:use-module (guix build-system python)
57c7bfec 43 #:use-module (guix build-system trivial)
3e4249ce 44 #:use-module (gnu packages)
57c7bfec 45 #:use-module (gnu packages base)
fd6ae1b9
LC
46 #:use-module (gnu packages gcc)
47 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
ee077430
EB
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages libffi)
698e91f0 50 #:use-module (gnu packages mpi)
3e4249ce 51 #:use-module (gnu packages perl)
698e91f0 52 #:use-module (gnu packages pkg-config)
3e4249ce 53 #:use-module (gnu packages python)
96a9a8d3
LC
54 #:use-module (gnu packages xml)
55 #:export (system->llvm-target))
56
57(define* (system->llvm-target #:optional
58 (system (or (and=> (%current-target-system)
59 gnu-triplet->nix-system)
60 (%current-system))))
61 "Return the LLVM target name that corresponds to SYSTEM, a system type such
62as \"x86_64-linux\"."
63 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
64 (letrec-syntax ((matches (syntax-rules (=>)
65 ((_ (system-prefix => target) rest ...)
66 (if (string-prefix? system-prefix system)
67 target
68 (matches rest ...)))
69 ((_)
70 (error "LLVM target for system is unknown" system)))))
71 (matches ("aarch64" => "AArch64")
72 ("armhf" => "ARM")
73 ("mips64el" => "Mips")
74 ("powerpc" => "PowerPC")
75 ("riscv" => "RISCV")
76 ("x86_64" => "X86")
77 ("i686" => "X86"))))
3e4249ce 78
f5de2b9a 79(define-public llvm-8
3e4249ce
EB
80 (package
81 (name "llvm")
c5296e20 82 (version "8.0.0")
3e4249ce
EB
83 (source
84 (origin
85 (method url-fetch)
3bdcc668 86 (uri (string-append "https://llvm.org/releases/"
3e4249ce
EB
87 version "/llvm-" version ".src.tar.xz"))
88 (sha256
89 (base32
c5296e20 90 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
3e4249ce 91 (build-system cmake-build-system)
50b61ec2 92 (outputs '("out" "opt-viewer"))
3e4249ce 93 (native-inputs
3ebc0905 94 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
3e4249ce 95 ("perl" ,perl)))
ee077430 96 (inputs
44e8559d
EB
97 `(("libffi" ,libffi)))
98 (propagated-inputs
99 `(("zlib" ,zlib))) ;to use output from llvm-config
3e4249ce 100 (arguments
22d0e9b7 101 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
ee077430 102 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
ab78618f 103 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
22897187 104 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
fc9dbf41 105 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
22897187 106 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
0935fb27
EB
107
108 ;; Don't use '-g' during the build, to save space.
ab78618f 109 #:build-type "Release"
50b61ec2
JL
110 #:phases
111 (modify-phases %standard-phases
112 (add-before 'build 'shared-lib-workaround
113 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
114 ;; doesn't seem to get the correct rpath to be able to run
115 ;; from the build directory. Set LD_LIBRARY_PATH as a
116 ;; workaround.
117 (lambda _
118 (setenv "LD_LIBRARY_PATH"
119 (string-append (getcwd) "/lib"))
120 #t))
121 (add-after 'install 'install-opt-viewer
122 (lambda* (#:key outputs #:allow-other-keys)
123 (let* ((out (assoc-ref outputs "out"))
124 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
125 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
126 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
127 (mkdir-p opt-viewer-share-dir)
128 (rename-file (string-append out "/share/opt-viewer")
129 opt-viewer-dir))
130 #t)))))
ac97dce1 131 (home-page "https://www.llvm.org")
3e4249ce
EB
132 (synopsis "Optimizing compiler infrastructure")
133 (description
e881752c
AK
134 "LLVM is a compiler infrastructure designed for compile-time, link-time,
135runtime, and idle-time optimization of programs from arbitrary programming
136languages. It currently supports compilation of C and C++ programs, using
137front-ends derived from GCC 4.0.1. A new front-end for the C family of
138languages is in development. The compiler infrastructure includes mirror sets
139of programming tools as well as libraries with equivalent functionality.")
ac00973c 140 (license license:ncsa)))
3e4249ce 141
f5de2b9a
IP
142(define-public llvm llvm-8)
143
6b26f915
LC
144(define* (clang-runtime-from-llvm llvm hash
145 #:optional (patches '()))
b81f5693
AW
146 (package
147 (name "clang-runtime")
148 (version (package-version llvm))
149 (source
150 (origin
151 (method url-fetch)
3bdcc668 152 (uri (string-append "https://llvm.org/releases/"
b81f5693 153 version "/compiler-rt-" version ".src.tar.xz"))
6b26f915
LC
154 (sha256 (base32 hash))
155 (patches (map search-patch patches))))
b81f5693
AW
156 (build-system cmake-build-system)
157 (native-inputs (package-native-inputs llvm))
158 (inputs
159 `(("llvm" ,llvm)))
160 (arguments
161 `(;; Don't use '-g' during the build to save space.
3b956a33
EB
162 #:build-type "Release"
163 #:tests? #f)) ; Tests require gtest
ac97dce1 164 (home-page "https://compiler-rt.llvm.org")
b81f5693
AW
165 (synopsis "Runtime library for Clang/LLVM")
166 (description
167 "The \"clang-runtime\" library provides the implementations of run-time
168functions for C and C++ programs. It also provides header files that allow C
169and C++ source code to interface with the \"sanitization\" passes of the clang
170compiler. In LLVM this library is called \"compiler-rt\".")
ac00973c 171 (license license:ncsa)
9e6b9ea4 172
ac97dce1 173 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
9e6b9ea4 174 (supported-systems (delete "mips64el-linux" %supported-systems))))
b81f5693 175
3b956a33 176(define* (clang-from-llvm llvm clang-runtime hash
9bdbabe9 177 #:key (patches '()))
3e4249ce
EB
178 (package
179 (name "clang")
180 (version (package-version llvm))
181 (source
182 (origin
183 (method url-fetch)
3bdcc668 184 (uri (string-append "https://llvm.org/releases/"
3e4249ce 185 version "/cfe-" version ".src.tar.xz"))
fd6ae1b9 186 (sha256 (base32 hash))
3b956a33 187 (patches (map search-patch patches))))
3e4249ce
EB
188 ;; Using cmake allows us to treat llvm as an external library. There
189 ;; doesn't seem to be any way to do this with clang's autotools-based
190 ;; build system.
191 (build-system cmake-build-system)
192 (native-inputs (package-native-inputs llvm))
193 (inputs
194 `(("libxml2" ,libxml2)
c92f1c0a 195 ("gcc-lib" ,gcc "lib")
3e4249ce
EB
196 ,@(package-inputs llvm)))
197 (propagated-inputs
b81f5693
AW
198 `(("llvm" ,llvm)
199 ("clang-runtime" ,clang-runtime)))
fd6ae1b9
LC
200 (arguments
201 `(#:configure-flags
202 (list "-DCLANG_INCLUDE_TESTS=True"
203
204 ;; Find libgcc_s, crtbegin.o, and crtend.o.
205 (string-append "-DGCC_INSTALL_PREFIX="
206 (assoc-ref %build-inputs "gcc-lib"))
207
208 ;; Use a sane default include directory.
209 (string-append "-DC_INCLUDE_DIRS="
210 (assoc-ref %build-inputs "libc")
211 "/include"))
212
94585e88
LC
213 ;; Don't use '-g' during the build to save space.
214 #:build-type "Release"
215
fd6ae1b9
LC
216 #:phases (modify-phases %standard-phases
217 (add-after
218 'unpack 'set-glibc-file-names
219 (lambda* (#:key inputs #:allow-other-keys)
b81f5693 220 (let ((libc (assoc-ref inputs "libc"))
07c07de3 221 (compiler-rt (assoc-ref inputs "clang-runtime"))
496bbeee 222 (gcc (assoc-ref inputs "gcc"))
07c07de3
MO
223 (version
224 (string->number
225 ,(version-major (package-version clang-runtime)))))
226 (cond
227 ((> version 3)
9bdbabe9
MB
228 ;; Link to libclang_rt files from clang-runtime.
229 (substitute* "lib/Driver/ToolChain.cpp"
230 (("getDriver\\(\\)\\.ResourceDir")
231 (string-append "\"" compiler-rt "\"")))
232
233 ;; Make "LibDir" refer to <glibc>/lib so that it
234 ;; uses the right dynamic linker file name.
235 (substitute* "lib/Driver/ToolChains/Linux.cpp"
236 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
237 (string-append declaration "\"" libc "/lib\";\n"))
238
496bbeee
DT
239 ;; Make clang look for libstdc++ in the right
240 ;; location.
241 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
242 (string-append
243 "LibStdCXXIncludePathCandidates[] = { \"" gcc "/include/c++\","))
244
9bdbabe9
MB
245 ;; Make sure libc's libdir is on the search path, to
246 ;; allow crt1.o & co. to be found.
247 (("@GLIBC_LIBDIR@")
248 (string-append libc "/lib"))))
07c07de3 249 (else
9bdbabe9
MB
250 (substitute* "lib/Driver/Tools.cpp"
251 ;; Patch the 'getLinuxDynamicLinker' function so that
252 ;; it uses the right dynamic linker file name.
253 (("/lib64/ld-linux-x86-64.so.2")
254 (string-append libc
255 ,(glibc-dynamic-linker))))
256
257 ;; Link to libclang_rt files from clang-runtime.
258 ;; This substitution needed slight adjustment in 3.8.
259 (if (< 3.8 (string->number ,(version-major+minor
260 (package-version
261 clang-runtime))))
262 (substitute* "lib/Driver/Tools.cpp"
263 (("TC\\.getDriver\\(\\)\\.ResourceDir")
264 (string-append "\"" compiler-rt "\"")))
265 (substitute* "lib/Driver/ToolChain.cpp"
266 (("getDriver\\(\\)\\.ResourceDir")
267 (string-append "\"" compiler-rt "\""))))
268
269 ;; Make sure libc's libdir is on the search path, to
270 ;; allow crt1.o & co. to be found.
271 (substitute* "lib/Driver/ToolChains.cpp"
272 (("@GLIBC_LIBDIR@")
273 (string-append libc "/lib")))))
1c7372a5
PN
274 #t)))
275 (add-after 'install 'install-clean-up-/share/clang
276 (lambda* (#:key outputs #:allow-other-keys)
277 (let* ((out (assoc-ref outputs "out"))
278 (compl-dir (string-append
279 out "/etc/bash_completion.d")))
280 (with-directory-excursion (string-append out
281 "/share/clang")
ad8a4a66
PN
282 (for-each
283 (lambda (file)
284 (when (file-exists? file)
285 (delete-file file)))
286 ;; Delete extensions for proprietary text editors.
287 '("clang-format-bbedit.applescript"
288 "clang-format-sublime.py"
289 ;; Delete Emacs extensions: see their respective Emacs
290 ;; Guix package instead.
291 "clang-rename.el" "clang-format.el"))
1c7372a5 292 ;; Install bash completion.
ad8a4a66
PN
293 (when (file-exists? "bash-autocomplete.sh")
294 (mkdir-p compl-dir)
295 (rename-file "bash-autocomplete.sh"
296 (string-append compl-dir "/clang")))))
1c7372a5 297 #t)))))
ef11ac87
LC
298
299 ;; Clang supports the same environment variables as GCC.
300 (native-search-paths
301 (list (search-path-specification
302 (variable "CPATH")
303 (files '("include")))
304 (search-path-specification
305 (variable "LIBRARY_PATH")
306 (files '("lib" "lib64")))))
307
ac97dce1 308 (home-page "https://clang.llvm.org")
3e4249ce
EB
309 (synopsis "C language family frontend for LLVM")
310 (description
311 "Clang is a compiler front end for the C, C++, Objective-C and
312Objective-C++ programming languages. It uses LLVM as its back end. The Clang
313project includes the Clang front end, the Clang static analyzer, and several
314code analysis tools.")
ac00973c 315 (license license:ncsa)))
1204c510 316
57c7bfec
MO
317(define (make-clang-toolchain clang)
318 (package
319 (name (string-append (package-name clang) "-toolchain"))
320 (version (package-version clang))
321 (source #f)
322 (build-system trivial-build-system)
323 (arguments
324 '(#:modules ((guix build union))
325 #:builder (begin
326 (use-modules (ice-9 match)
327 (srfi srfi-26)
328 (guix build union))
329
330 (let ((out (assoc-ref %outputs "out")))
331
332 (match %build-inputs
333 (((names . directories) ...)
334 (union-build out directories)))
335
336 (union-build (assoc-ref %outputs "debug")
337 (list (assoc-ref %build-inputs
338 "libc-debug")))
339 (union-build (assoc-ref %outputs "static")
340 (list (assoc-ref %build-inputs
341 "libc-static")))
342 #t))))
343
344 (native-search-paths (package-native-search-paths clang))
345 (search-paths (package-search-paths clang))
346
347 (license (package-license clang))
348 (home-page "https://clang.llvm.org")
349 (synopsis "Complete Clang toolchain for C/C++ development")
350 (description "This package provides a complete Clang toolchain for C/C++
351development to be installed in user profiles. This includes Clang, as well as
352libc (headers and binaries, plus debugging symbols in the @code{debug}
353output), and Binutils.")
354 (outputs '("out" "debug" "static"))
355 (inputs `(("clang" ,clang)
356 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
357 ("binutils" ,binutils)
358 ("libc" ,glibc)
359 ("libc-debug" ,glibc "debug")
360 ("libc-static" ,glibc "static")))))
361
9f0ce5ec
RW
362(define-public libcxx
363 (package
364 (name "libcxx")
365 (version (package-version llvm))
366 (source
367 (origin
368 (method url-fetch)
369 (uri (string-append "http://llvm.org/releases/"
370 version "/libcxx-" version ".src.tar.xz"))
371 (sha256
372 (base32
4980b0b5 373 "1qlx3wlxrnc5cwc1fcfc2vhfsl7j4294hi8y5kxj8hy8wxsjd462"))))
9f0ce5ec
RW
374 (build-system cmake-build-system)
375 (native-inputs
376 `(("clang" ,clang)
377 ("llvm" ,llvm)))
378 (home-page "https://libcxx.llvm.org")
379 (synopsis "C++ standard library")
380 (description
381 "This package provides an implementation of the C++ standard library for
382use with Clang, targeting C++11, C++14 and above.")
383 (license license:expat)))
384
a2cc25ab
RW
385(define-public libclc
386 (package
387 (name "libclc")
388 (version (package-version llvm))
389 (source
390 (origin
391 (method git-fetch)
392 (uri (git-reference
393 (url "https://github.com/llvm/llvm-project.git")
394 (commit (string-append "llvmorg-" version))))
f1d4d79f 395 (file-name (git-file-name name version))
a2cc25ab
RW
396 (sha256
397 (base32
398 "052h16wjcnqginzp7ki4il2xmm25v9nyk0wcz7cg03gbryhl7aqa"))))
399 (build-system cmake-build-system)
400 (arguments
401 `(#:configure-flags
402 (list (string-append "-DLLVM_CLANG="
403 (assoc-ref %build-inputs "clang")
404 "/bin/clang")
405 (string-append "-DPYTHON="
406 (assoc-ref %build-inputs "python")
407 "/bin/python3"))
408 #:phases
409 (modify-phases %standard-phases
410 (add-after 'unpack 'chdir
411 (lambda _ (chdir "libclc") #t)))))
412 (native-inputs
413 `(("clang" ,clang)
414 ("llvm" ,llvm)
415 ("python" ,python)))
416 (home-page "https://libclc.llvm.org")
417 (synopsis "Libraries for the OpenCL programming language")
418 (description
419 "This package provides an implementation of the OpenCL library
420requirements according to version 1.1 of the OpenCL specification.")
421 ;; Apache license 2.0 with LLVM exception
422 (license license:asl2.0)))
423
698e91f0
LC
424(define-public libomp
425 (package
426 (name "libomp")
427 (version (package-version llvm))
428 (source (origin
429 (method url-fetch)
69e3512b 430 (uri (string-append "https://releases.llvm.org/"
698e91f0
LC
431 version "/openmp-" version
432 ".src.tar.xz"))
433 (sha256
434 (base32
e2170c31 435 "1mf9cpgvix34xlpv0inkgl3qmdvgvp96f7sksqizri0n5xfp1cgp"))
698e91f0
LC
436 (file-name (string-append "libomp-" version ".tar.xz"))))
437 (build-system cmake-build-system)
438 ;; XXX: Note this gets built with GCC because building with Clang itself
439 ;; fails (missing <atomic>, even when libcxx is added as an input.)
440 (arguments
441 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
442 "-DOPENMP_TEST_C_COMPILER=clang"
443 "-DOPENMP_TEST_CXX_COMPILER=clang++")
9338cbdb 444 #:test-target "check-libomp"))
698e91f0
LC
445 (native-inputs
446 `(("clang" ,clang)
447 ("llvm" ,llvm)
448 ("perl" ,perl)
449 ("pkg-config" ,pkg-config)))
450 (inputs
451 `(("hwloc" ,hwloc "lib")))
452 (home-page "https://openmp.llvm.org")
453 (synopsis "OpenMP run-time support library")
454 (description
455 "This package provides the run-time support library developed by the LLVM
456project for the OpenMP multi-theaded programming extension. This package
457notably provides @file{libgomp.so}, which is has a binary interface compatible
458with that of libgomp, the GNU Offloading and Multi Processing Library.")
459 (license license:expat)))
460
b81f5693
AW
461(define-public clang-runtime
462 (clang-runtime-from-llvm
463 llvm
c5296e20 464 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"))
b81f5693 465
1204c510 466(define-public clang
b81f5693 467 (clang-from-llvm llvm clang-runtime
c5296e20 468 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
d199a4c7
MB
469 #:patches '("clang-7.0-libc-search-path.patch")))
470
57c7bfec
MO
471(define-public clang-toolchain
472 (make-clang-toolchain clang))
473
96d5a206
DT
474(define-public llvm-9
475 (package
476 (inherit llvm)
477 (version "9.0.0")
478 (source (origin
479 (method url-fetch)
480 (uri (string-append "https://llvm.org/releases/"
481 version "/llvm-" version ".src.tar.xz"))
482 (sha256
483 (base32
484 "117ymdz1by2nkfq1c2p9m4050dp848kbjbiv6nsfj8hzy9f5d86n"))))
485 (license license:asl2.0)))
486
487(define-public clang-runtime-9
488 (clang-runtime-from-llvm
489 llvm-9
490 "03ni43lbkp63lr3p6sc94dphqmvnz5av5mml0xmk930xvnbcvr2n"))
491
492(define-public clang-9
493 (clang-from-llvm llvm-9 clang-runtime-9
494 "0426ma80i41qsgzm1qdz81mjskck426diygxi2k5vji2gkpixa3v"))
495
496(define-public clang-toolchain-9
497 (make-clang-toolchain clang-9))
498
4289d1d7
MB
499(define-public llvm-7
500 (package
501 (inherit llvm)
502 (version "7.0.1")
503 (source (origin
504 (method url-fetch)
505 (uri (string-append "https://llvm.org/releases/"
506 version "/llvm-" version ".src.tar.xz"))
507 (sha256
508 (base32
509 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
510
511(define-public clang-runtime-7
512 (clang-runtime-from-llvm
513 llvm-7
514 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"))
515
516(define-public clang-7
517 (clang-from-llvm llvm-7 clang-runtime
518 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
519 #:patches '("clang-7.0-libc-search-path.patch")))
520
57c7bfec
MO
521(define-public clang-toolchain-7
522 (make-clang-toolchain clang-7))
523
d199a4c7
MB
524(define-public llvm-6
525 (package
526 (inherit llvm)
527 (version "6.0.1")
528 (source (origin
529 (method url-fetch)
530 (uri (string-append "https://llvm.org/releases/"
531 version "/llvm-" version ".src.tar.xz"))
532 (sha256
533 (base32
534 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
535
536(define-public clang-runtime-6
537 (clang-runtime-from-llvm
538 llvm-6
539 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"))
540
541(define-public clang-6
542 (clang-from-llvm llvm-6 clang-runtime
148df605 543 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
9bdbabe9 544 #:patches '("clang-6.0-libc-search-path.patch")))
3b956a33 545
57c7bfec
MO
546(define-public clang-toolchain-6
547 (make-clang-toolchain clang-6))
548
8b5107d2
JS
549;; Libcxx files specifically used by PySide2.
550(define-public libcxx-6
551 (package
552 (inherit libcxx)
553 (version (package-version llvm-6))
554 (source
555 (origin
556 (inherit (package-source libcxx))
557 (uri (string-append "http://llvm.org/releases/"
558 version "/libcxx-" version ".src.tar.xz"))
559 (sha256
560 (base32
561 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
562 (native-inputs
563 `(("clang" ,clang-6)
564 ("llvm" ,llvm-6)))))
565
584da12d
RJ
566(define-public llvm-3.9.1
567 (package (inherit llvm)
568 (name "llvm")
569 (version "3.9.1")
570 (source
571 (origin
572 (method url-fetch)
3bdcc668 573 (uri (string-append "https://llvm.org/releases/"
584da12d
RJ
574 version "/llvm-" version ".src.tar.xz"))
575 (sha256
576 (base32
577 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
578
579(define-public clang-runtime-3.9.1
580 (clang-runtime-from-llvm
581 llvm-3.9.1
6b26f915
LC
582 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
583 '("clang-runtime-asan-build-fixes.patch"
0627f93d 584 "clang-runtime-esan-build-fixes.patch"
1a2d8d06 585 "clang-3.5-libsanitizer-ustat-fix.patch")))
584da12d
RJ
586
587(define-public clang-3.9.1
588 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
589 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
9bdbabe9
MB
590 #:patches '("clang-3.8-libc-search-path.patch")))
591
592(define-public llvm-3.8
593 (package (inherit llvm)
594 (name "llvm")
595 (version "3.8.1")
596 (source
597 (origin
598 (method url-fetch)
599 (uri (string-append "https://llvm.org/releases/"
600 version "/llvm-" version ".src.tar.xz"))
601 (sha256
602 (base32
603 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
604
605(define-public clang-runtime-3.8
606 (clang-runtime-from-llvm
607 llvm-3.8
608 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
0627f93d 609 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 610 "clang-3.5-libsanitizer-ustat-fix.patch")))
9bdbabe9
MB
611
612(define-public clang-3.8
613 (clang-from-llvm llvm-3.8 clang-runtime-3.8
614 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
615 #:patches '("clang-3.8-libc-search-path.patch")))
584da12d 616
3b956a33
EB
617(define-public llvm-3.7
618 (package (inherit llvm)
619 (version "3.7.1")
620 (source
621 (origin
622 (method url-fetch)
3bdcc668 623 (uri (string-append "https://llvm.org/releases/"
3b956a33
EB
624 version "/llvm-" version ".src.tar.xz"))
625 (sha256
626 (base32
627 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
628
629(define-public clang-runtime-3.7
630 (clang-runtime-from-llvm
631 llvm-3.7
6b26f915 632 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
0627f93d 633 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 634 "clang-3.5-libsanitizer-ustat-fix.patch")))
3b956a33
EB
635
636(define-public clang-3.7
637 (clang-from-llvm llvm-3.7 clang-runtime-3.7
9bdbabe9
MB
638 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
639 #:patches '("clang-3.5-libc-search-path.patch")))
3ebc0905
EB
640
641(define-public llvm-3.6
642 (package (inherit llvm)
643 (version "3.6.2")
644 (source
645 (origin
646 (method url-fetch)
3bdcc668 647 (uri (string-append "https://llvm.org/releases/"
3ebc0905
EB
648 version "/llvm-" version ".src.tar.xz"))
649 (sha256
650 (base32
651 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
652
653(define-public clang-runtime-3.6
654 (clang-runtime-from-llvm
655 llvm-3.6
6b26f915
LC
656 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
657 '("clang-runtime-asan-build-fixes.patch")))
3ebc0905
EB
658
659(define-public clang-3.6
660 (clang-from-llvm llvm-3.6 clang-runtime-3.6
9bdbabe9
MB
661 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
662 #:patches '("clang-3.5-libc-search-path.patch")))
1204c510
MW
663
664(define-public llvm-3.5
665 (package (inherit llvm)
a53c486d 666 (version "3.5.2")
1204c510
MW
667 (source
668 (origin
669 (method url-fetch)
3bdcc668 670 (uri (string-append "https://llvm.org/releases/"
1204c510 671 version "/llvm-" version ".src.tar.xz"))
6ba4eca2
RW
672 (patches
673 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1204c510
MW
674 (sha256
675 (base32
a53c486d 676 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1204c510 677
b81f5693
AW
678(define-public clang-runtime-3.5
679 (clang-runtime-from-llvm
680 llvm-3.5
6b26f915 681 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
286bea0d
LC
682 '("clang-runtime-asan-build-fixes.patch"
683 "clang-3.5-libsanitizer-ustat-fix.patch")))
b81f5693 684
1204c510 685(define-public clang-3.5
b81f5693 686 (clang-from-llvm llvm-3.5 clang-runtime-3.5
9bdbabe9
MB
687 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
688 #:patches '("clang-3.5-libc-search-path.patch")))
921cb13a
RW
689
690(define-public llvm-for-extempore
691 (package (inherit llvm-3.7)
7355634d 692 (name "llvm-for-extempore")
921cb13a
RW
693 (source
694 (origin
695 (inherit (package-source llvm-3.7))
39162ee4
RW
696 (patches (list (search-patch "llvm-for-extempore.patch")))))
697 ;; Extempore refuses to build on architectures other than x86_64
698 (supported-systems '("x86_64-linux"))))
8892cac3
RW
699
700(define-public python-llvmlite
701 (package
702 (name "python-llvmlite")
66087272 703 (version "0.30.0")
8892cac3
RW
704 (source
705 (origin
706 (method url-fetch)
707 (uri (pypi-uri "llvmlite" version))
708 (sha256
709 (base32
66087272 710 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
8892cac3 711 (build-system python-build-system)
66087272
BG
712 (arguments
713 ;; FIXME: One test fails unable to find libm.so
714 ;; https://github.com/numba/llvmlite/issues/537
715 `(#:tests? #f))
8892cac3
RW
716 (inputs
717 `(("llvm"
718 ,(package
4289d1d7 719 (inherit llvm-7)
8892cac3 720 (source (origin
4289d1d7 721 (inherit (package-source llvm-7))
8892cac3
RW
722 (patches
723 (list
724 (origin
725 (method url-fetch)
726 (uri (string-append "https://raw.githubusercontent.com/numba/"
727 "llvmlite/v" version "/conda-recipes/"
f9325407 728 "D47188-svml-VF.patch"))
8892cac3
RW
729 (sha256
730 (base32
f9325407 731 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
8892cac3
RW
732 (origin
733 (method url-fetch)
734 (uri (string-append "https://raw.githubusercontent.com/numba/"
735 "llvmlite/v" version "/conda-recipes/"
736 "twine_cfg_undefined_behavior.patch"))
737 (sha256
738 (base32
7a20877a 739 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
8892cac3
RW
740 (home-page "http://llvmlite.pydata.org")
741 (synopsis "Wrapper around basic LLVM functionality")
742 (description
743 "This package provides a Python binding to LLVM for use in Numba.")
744 (license license:bsd-3)))
7628ff1f 745
67eebb19
LC
746(define (package-elisp-from-package source-package package-name
747 source-files)
748 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
749SOURCE-FILES found in SOURCE-PACKAGE."
750 (let ((orig (package-source source-package)))
751 (package
752 (inherit source-package)
753 (name package-name)
754 (build-system emacs-build-system)
755 (source (origin
756 (method (origin-method orig))
757 (uri (origin-uri orig))
758 (sha256 (origin-sha256 orig))
759 (file-name (string-append package-name "-"
760 (package-version source-package)))
761 (modules '((guix build utils)
762 (srfi srfi-1)
763 (ice-9 ftw)))
764 (snippet
765 `(let* ((source-files (quote ,source-files))
766 (basenames (map basename source-files)))
767 (map copy-file
768 source-files basenames)
769 (map delete-file-recursively
770 (fold delete
771 (scandir ".")
772 (append '("." "..") basenames)))
773 #t)))))))
774
7628ff1f
TG
775(define-public emacs-clang-format
776 (package
777 (inherit clang)
778 (name "emacs-clang-format")
779 (build-system emacs-build-system)
780 (inputs
781 `(("clang" ,clang)))
782 (arguments
783 `(#:phases
784 (modify-phases %standard-phases
785 (add-after 'unpack 'configure
786 (lambda* (#:key inputs #:allow-other-keys)
787 (let ((clang (assoc-ref inputs "clang")))
788 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
789 (emacs-substitute-variables "clang-format.el"
790 ("clang-format-executable"
791 (string-append clang "/bin/clang-format"))))
792 #t)))))
793 (synopsis "Format code using clang-format")
794 (description "This package allows to filter code through @code{clang-format}
795to fix its formatting. @code{clang-format} is a tool that formats
796C/C++/Obj-C code according to a set of style options, see
3bdcc668 797@url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
51002b72
PN
798
799(define-public emacs-clang-rename
800 (package
801 (inherit clang)
802 (name "emacs-clang-rename")
803 (build-system emacs-build-system)
804 (inputs
805 `(("clang" ,clang)))
806 (arguments
807 `(#:phases
808 (modify-phases %standard-phases
809 (add-after 'unpack 'configure
810 (lambda* (#:key inputs #:allow-other-keys)
811 (let ((clang (assoc-ref inputs "clang")))
812 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
813 (emacs-substitute-variables "clang-rename.el"
814 ("clang-rename-binary"
815 (string-append clang "/bin/clang-rename"))))
816 #t)))))
817 (synopsis "Rename every occurrence of a symbol using clang-rename")
818 (description "This package renames every occurrence of a symbol at point
819using @code{clang-rename}.")))