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