gnu: fontconfig: Add replacement with font-dejavu instead of gs-fonts.
[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, 2020 Ludovic Courtès <ludo@gnu.org>
5 ;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
6 ;;; Copyright © 2016, 2018, 2019, 2020 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 ;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
18 ;;;
19 ;;; This file is part of GNU Guix.
20 ;;;
21 ;;; GNU Guix is free software; you can redistribute it and/or modify it
22 ;;; under the terms of the GNU General Public License as published by
23 ;;; the Free Software Foundation; either version 3 of the License, or (at
24 ;;; your option) any later version.
25 ;;;
26 ;;; GNU Guix is distributed in the hope that it will be useful, but
27 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 ;;; GNU General Public License for more details.
30 ;;;
31 ;;; You should have received a copy of the GNU General Public License
32 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
33
34 (define-module (gnu packages llvm)
35 #:use-module (guix packages)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (guix download)
38 #:use-module (guix git-download)
39 #:use-module (guix utils)
40 #:use-module (guix build-system gnu)
41 #:use-module (guix build-system cmake)
42 #:use-module (guix build-system emacs)
43 #:use-module (guix build-system python)
44 #:use-module (guix build-system trivial)
45 #:use-module (gnu packages)
46 #:use-module (gnu packages base)
47 #:use-module (gnu packages gcc)
48 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
49 #:use-module (gnu packages compression)
50 #:use-module (gnu packages libffi)
51 #:use-module (gnu packages mpi)
52 #:use-module (gnu packages onc-rpc)
53 #:use-module (gnu packages perl)
54 #:use-module (gnu packages pkg-config)
55 #:use-module (gnu packages python)
56 #:use-module (gnu packages xml)
57 #:export (system->llvm-target))
58
59 (define* (system->llvm-target #:optional
60 (system (or (and=> (%current-target-system)
61 gnu-triplet->nix-system)
62 (%current-system))))
63 "Return the LLVM target name that corresponds to SYSTEM, a system type such
64 as \"x86_64-linux\"."
65 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
66 (letrec-syntax ((matches (syntax-rules (=>)
67 ((_ (system-prefix => target) rest ...)
68 (if (string-prefix? system-prefix system)
69 target
70 (matches rest ...)))
71 ((_)
72 (error "LLVM target for system is unknown" system)))))
73 (matches ("aarch64" => "AArch64")
74 ("armhf" => "ARM")
75 ("mips64el" => "Mips")
76 ("powerpc" => "PowerPC")
77 ("riscv" => "RISCV")
78 ("x86_64" => "X86")
79 ("i686" => "X86")
80 ("i586" => "X86"))))
81
82 (define (llvm-download-uri component version)
83 (if (version>=? version "9.0.1")
84 (string-append "https://github.com/llvm/llvm-project/releases/download"
85 "/llvmorg-" version "/" component "-" version ".src.tar.xz")
86 (string-append "https://releases.llvm.org/" version "/" component "-"
87 version ".src.tar.xz")))
88
89 (define-public llvm-10
90 (package
91 (name "llvm")
92 (version "10.0.0")
93 (source
94 (origin
95 (method url-fetch)
96 (uri (llvm-download-uri "llvm" version))
97 (sha256
98 (base32
99 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))
100 (build-system cmake-build-system)
101 (outputs '("out" "opt-viewer"))
102 (native-inputs
103 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
104 ("perl" ,perl)))
105 (inputs
106 `(("libffi" ,libffi)))
107 (propagated-inputs
108 `(("zlib" ,zlib))) ;to use output from llvm-config
109 (arguments
110 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
111 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
112 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
113 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
114 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
115 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
116
117 ;; Don't use '-g' during the build, to save space.
118 #:build-type "Release"
119 #:phases
120 (modify-phases %standard-phases
121 (add-before 'build 'shared-lib-workaround
122 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
123 ;; doesn't seem to get the correct rpath to be able to run
124 ;; from the build directory. Set LD_LIBRARY_PATH as a
125 ;; workaround.
126 (lambda _
127 (setenv "LD_LIBRARY_PATH"
128 (string-append (getcwd) "/lib"))
129 #t))
130 (add-after 'install 'install-opt-viewer
131 (lambda* (#:key outputs #:allow-other-keys)
132 (let* ((out (assoc-ref outputs "out"))
133 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
134 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
135 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
136 (mkdir-p opt-viewer-share-dir)
137 (rename-file (string-append out "/share/opt-viewer")
138 opt-viewer-dir))
139 #t)))))
140 (home-page "https://www.llvm.org")
141 (synopsis "Optimizing compiler infrastructure")
142 (description
143 "LLVM is a compiler infrastructure designed for compile-time, link-time,
144 runtime, and idle-time optimization of programs from arbitrary programming
145 languages. It currently supports compilation of C and C++ programs, using
146 front-ends derived from GCC 4.0.1. A new front-end for the C family of
147 languages is in development. The compiler infrastructure includes mirror sets
148 of programming tools as well as libraries with equivalent functionality.")
149 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
150
151 (define* (clang-runtime-from-llvm llvm hash
152 #:optional (patches '()))
153 (package
154 (name "clang-runtime")
155 (version (package-version llvm))
156 (source
157 (origin
158 (method url-fetch)
159 (uri (llvm-download-uri "compiler-rt" version))
160 (sha256 (base32 hash))
161 (patches (map search-patch patches))))
162 (build-system cmake-build-system)
163 (native-inputs (package-native-inputs llvm))
164 (inputs
165 `(("llvm" ,llvm)))
166 (arguments
167 `(;; Don't use '-g' during the build to save space.
168 #:build-type "Release"
169 #:tests? #f ; Tests require gtest
170 #:modules ((srfi srfi-1)
171 (ice-9 match)
172 ,@%cmake-build-system-modules)
173 #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
174 (add-after 'set-paths 'hide-glibc
175 ;; Work around https://issues.guix.info/issue/36882. We need to
176 ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
177 ;; in GCC, at the bottom of GCC include search-path is used.
178 (lambda* (#:key inputs #:allow-other-keys)
179 (let* ((filters '("libc"))
180 (input-directories
181 (filter-map (lambda (input)
182 (match input
183 ((name . dir)
184 (and (not (member name filters))
185 dir))))
186 inputs)))
187 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
188 '("include")
189 input-directories)
190 #t))))))
191 (home-page "https://compiler-rt.llvm.org")
192 (synopsis "Runtime library for Clang/LLVM")
193 (description
194 "The \"clang-runtime\" library provides the implementations of run-time
195 functions for C and C++ programs. It also provides header files that allow C
196 and C++ source code to interface with the \"sanitization\" passes of the clang
197 compiler. In LLVM this library is called \"compiler-rt\".")
198 (license (package-license llvm))
199
200 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
201 (supported-systems (delete "mips64el-linux" %supported-systems))))
202
203 (define* (clang-from-llvm llvm clang-runtime hash
204 #:key (patches '()))
205 (package
206 (name "clang")
207 (version (package-version llvm))
208 (source
209 (origin
210 (method url-fetch)
211 (uri (llvm-download-uri (if (version>=? version "9.0.1")
212 "clang"
213 "cfe")
214 version))
215 (sha256 (base32 hash))
216 (patches (map search-patch patches))))
217 ;; Using cmake allows us to treat llvm as an external library. There
218 ;; doesn't seem to be any way to do this with clang's autotools-based
219 ;; build system.
220 (build-system cmake-build-system)
221 (native-inputs (package-native-inputs llvm))
222 (inputs
223 `(("libxml2" ,libxml2)
224 ("gcc-lib" ,gcc "lib")
225 ,@(package-inputs llvm)))
226 (propagated-inputs
227 `(("llvm" ,llvm)
228 ("clang-runtime" ,clang-runtime)))
229 (arguments
230 `(#:configure-flags
231 (list "-DCLANG_INCLUDE_TESTS=True"
232
233 ;; Find libgcc_s, crtbegin.o, and crtend.o.
234 (string-append "-DGCC_INSTALL_PREFIX="
235 (assoc-ref %build-inputs "gcc-lib"))
236
237 ;; Use a sane default include directory.
238 (string-append "-DC_INCLUDE_DIRS="
239 (assoc-ref %build-inputs "libc")
240 "/include"))
241
242 ;; Don't use '-g' during the build to save space.
243 #:build-type "Release"
244
245 #:phases (modify-phases %standard-phases
246 (add-after 'unpack 'add-missing-triplets
247 (lambda _
248 ;; Clang iterates through known triplets to search for
249 ;; GCC's headers, but does not recognize some of the
250 ;; triplets that are used in Guix.
251 (substitute* ,@(if (version>=? version "6.0")
252 '("lib/Driver/ToolChains/Gnu.cpp")
253 '("lib/Driver/ToolChains.cpp"))
254 (("\"aarch64-linux-gnu\"," all)
255 (string-append "\"aarch64-unknown-linux-gnu\", "
256 all))
257 (("\"arm-linux-gnueabihf\"," all)
258 (string-append all
259 " \"arm-unknown-linux-gnueabihf\","))
260 (("\"i686-pc-linux-gnu\"," all)
261 (string-append "\"i686-unknown-linux-gnu\", "
262 all)))
263 #t))
264 (add-after 'unpack 'set-glibc-file-names
265 (lambda* (#:key inputs #:allow-other-keys)
266 (let ((libc (assoc-ref inputs "libc"))
267 (compiler-rt (assoc-ref inputs "clang-runtime"))
268 (gcc (assoc-ref inputs "gcc")))
269 ,@(cond
270 ((version>=? version "6.0")
271 `(;; Link to libclang_rt files from clang-runtime.
272 (substitute* "lib/Driver/ToolChain.cpp"
273 (("getDriver\\(\\)\\.ResourceDir")
274 (string-append "\"" compiler-rt "\"")))
275
276 ;; Make "LibDir" refer to <glibc>/lib so that it
277 ;; uses the right dynamic linker file name.
278 (substitute* "lib/Driver/ToolChains/Linux.cpp"
279 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
280 (string-append declaration "\"" libc "/lib\";\n"))
281
282 ;; Make clang look for libstdc++ in the right
283 ;; location.
284 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
285 (string-append
286 "LibStdCXXIncludePathCandidates[] = { \"" gcc
287 "/include/c++\","))
288
289 ;; Make sure libc's libdir is on the search path, to
290 ;; allow crt1.o & co. to be found.
291 (("@GLIBC_LIBDIR@")
292 (string-append libc "/lib")))))
293 (else
294 `((substitute* "lib/Driver/Tools.cpp"
295 ;; Patch the 'getLinuxDynamicLinker' function so that
296 ;; it uses the right dynamic linker file name.
297 (("/lib64/ld-linux-x86-64.so.2")
298 (string-append libc
299 ,(glibc-dynamic-linker))))
300
301 ;; Link to libclang_rt files from clang-runtime.
302 ;; This substitution needed slight adjustment in 3.8.
303 ,@(if (version>=? version "3.8")
304 '((substitute* "lib/Driver/Tools.cpp"
305 (("TC\\.getDriver\\(\\)\\.ResourceDir")
306 (string-append "\"" compiler-rt "\""))))
307 '((substitute* "lib/Driver/ToolChain.cpp"
308 (("getDriver\\(\\)\\.ResourceDir")
309 (string-append "\"" compiler-rt "\"")))))
310
311 ;; Make sure libc's libdir is on the search path, to
312 ;; allow crt1.o & co. to be found.
313 (substitute* "lib/Driver/ToolChains.cpp"
314 (("@GLIBC_LIBDIR@")
315 (string-append libc "/lib"))))))
316 #t)))
317 (add-after 'install 'install-clean-up-/share/clang
318 (lambda* (#:key outputs #:allow-other-keys)
319 (let* ((out (assoc-ref outputs "out"))
320 (compl-dir (string-append
321 out "/etc/bash_completion.d")))
322 (with-directory-excursion (string-append out
323 "/share/clang")
324 (for-each
325 (lambda (file)
326 (when (file-exists? file)
327 (delete-file file)))
328 ;; Delete extensions for proprietary text editors.
329 '("clang-format-bbedit.applescript"
330 "clang-format-sublime.py"
331 ;; Delete Emacs extensions: see their respective Emacs
332 ;; Guix package instead.
333 "clang-rename.el" "clang-format.el"))
334 ;; Install bash completion.
335 (when (file-exists? "bash-autocomplete.sh")
336 (mkdir-p compl-dir)
337 (rename-file "bash-autocomplete.sh"
338 (string-append compl-dir "/clang")))))
339 #t)))))
340
341 ;; Clang supports the same environment variables as GCC.
342 (native-search-paths
343 (list (search-path-specification
344 (variable "C_INCLUDE_PATH")
345 (files '("include")))
346 (search-path-specification
347 (variable "CPLUS_INCLUDE_PATH")
348 (files '("include/c++" "include")))
349 (search-path-specification
350 (variable "LIBRARY_PATH")
351 (files '("lib" "lib64")))))
352
353 (home-page "https://clang.llvm.org")
354 (synopsis "C language family frontend for LLVM")
355 (description
356 "Clang is a compiler front end for the C, C++, Objective-C and
357 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
358 project includes the Clang front end, the Clang static analyzer, and several
359 code analysis tools.")
360 (license (if (version>=? version "9.0")
361 license:asl2.0 ;with LLVM exceptions
362 license:ncsa))))
363
364 (define (make-clang-toolchain clang)
365 (package
366 (name (string-append (package-name clang) "-toolchain"))
367 (version (package-version clang))
368 (source #f)
369 (build-system trivial-build-system)
370 (arguments
371 '(#:modules ((guix build union))
372 #:builder (begin
373 (use-modules (ice-9 match)
374 (srfi srfi-26)
375 (guix build union))
376
377 (let ((out (assoc-ref %outputs "out")))
378
379 (match %build-inputs
380 (((names . directories) ...)
381 (union-build out directories)))
382
383 (union-build (assoc-ref %outputs "debug")
384 (list (assoc-ref %build-inputs
385 "libc-debug")))
386 (union-build (assoc-ref %outputs "static")
387 (list (assoc-ref %build-inputs
388 "libc-static")))
389 #t))))
390
391 (native-search-paths (package-native-search-paths clang))
392 (search-paths (package-search-paths clang))
393
394 (license (package-license clang))
395 (home-page "https://clang.llvm.org")
396 (synopsis "Complete Clang toolchain for C/C++ development")
397 (description "This package provides a complete Clang toolchain for C/C++
398 development to be installed in user profiles. This includes Clang, as well as
399 libc (headers and binaries, plus debugging symbols in the @code{debug}
400 output), and Binutils.")
401 (outputs '("out" "debug" "static"))
402 (inputs `(("clang" ,clang)
403 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
404 ("binutils" ,binutils)
405 ("libc" ,glibc)
406 ("libc-debug" ,glibc "debug")
407 ("libc-static" ,glibc "static")))))
408
409 (define-public clang-runtime-10
410 (clang-runtime-from-llvm
411 llvm-10
412 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
413
414 (define-public clang-10
415 (clang-from-llvm llvm-10 clang-runtime-10
416 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
417 #:patches '("clang-10.0-libc-search-path.patch")))
418
419 (define-public clang-toolchain-10
420 (make-clang-toolchain clang-10))
421
422 (define-public llvm-9
423 (package
424 (inherit llvm-10)
425 (version "9.0.1")
426 (source
427 (origin
428 (method url-fetch)
429 (uri (llvm-download-uri "llvm" version))
430 (sha256
431 (base32
432 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))))))
433
434 (define-public clang-runtime-9
435 (clang-runtime-from-llvm
436 llvm-9
437 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
438 '("clang-runtime-9-libsanitizer-mode-field.patch")))
439
440 (define-public clang-9
441 (clang-from-llvm llvm-9 clang-runtime-9
442 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
443 #:patches '("clang-9.0-libc-search-path.patch")))
444
445 (define-public clang-toolchain-9
446 (make-clang-toolchain clang-9))
447
448 ;; Default LLVM and Clang version.
449 (define-public llvm llvm-9)
450 (define-public clang-runtime clang-runtime-9)
451 (define-public clang clang-9)
452 (define-public clang-toolchain clang-toolchain-9)
453
454 (define-public llvm-8
455 (package
456 (inherit llvm)
457 (version "8.0.0")
458 (source (origin
459 (method url-fetch)
460 (uri (llvm-download-uri "llvm" version))
461 (sha256
462 (base32
463 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
464 (license license:ncsa)))
465
466 (define-public clang-runtime-8
467 (clang-runtime-from-llvm
468 llvm-8
469 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
470 '("clang-runtime-9-libsanitizer-mode-field.patch")))
471
472 (define-public clang-8
473 (clang-from-llvm llvm-8 clang-runtime-8
474 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
475 #:patches '("clang-7.0-libc-search-path.patch")))
476
477 (define-public clang-toolchain-8
478 (make-clang-toolchain clang-8))
479
480 (define-public llvm-7
481 (package
482 (inherit llvm-8)
483 (version "7.0.1")
484 (source (origin
485 (method url-fetch)
486 (uri (llvm-download-uri "llvm" version))
487 (sha256
488 (base32
489 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
490
491 (define-public clang-runtime-7
492 (clang-runtime-from-llvm
493 llvm-7
494 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
495 '("clang-runtime-9-libsanitizer-mode-field.patch")))
496
497 (define-public clang-7
498 (clang-from-llvm llvm-7 clang-runtime-7
499 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
500 #:patches '("clang-7.0-libc-search-path.patch")))
501
502 (define-public clang-toolchain-7
503 (make-clang-toolchain clang-7))
504
505 (define-public llvm-6
506 (package
507 (inherit llvm-7)
508 (version "6.0.1")
509 (source (origin
510 (method url-fetch)
511 (uri (llvm-download-uri "llvm" version))
512 (sha256
513 (base32
514 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
515
516 (define-public clang-runtime-6
517 (clang-runtime-from-llvm
518 llvm-6
519 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
520 '("clang-runtime-9-libsanitizer-mode-field.patch")))
521
522 (define-public clang-6
523 (clang-from-llvm llvm-6 clang-runtime-6
524 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
525 #:patches '("clang-6.0-libc-search-path.patch")))
526
527 (define-public clang-toolchain-6
528 (make-clang-toolchain clang-6))
529
530 (define-public llvm-3.9.1
531 (package (inherit llvm-6)
532 (name "llvm")
533 (version "3.9.1")
534 (source
535 (origin
536 (method url-fetch)
537 (uri (llvm-download-uri "llvm" version))
538 (sha256
539 (base32
540 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
541 (outputs '("out"))
542 (arguments
543 (substitute-keyword-arguments (package-arguments llvm)
544 ((#:phases phases)
545 `(modify-phases ,phases
546 (delete 'install-opt-viewer)))))))
547
548 (define-public clang-runtime-3.9.1
549 (clang-runtime-from-llvm
550 llvm-3.9.1
551 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
552 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
553 "clang-runtime-asan-build-fixes.patch"
554 "clang-runtime-esan-build-fixes.patch"
555 "clang-3.5-libsanitizer-ustat-fix.patch")))
556
557 (define-public clang-3.9.1
558 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
559 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
560 #:patches '("clang-3.8-libc-search-path.patch")))
561
562 (define-public llvm-3.8
563 (package (inherit llvm-3.9.1)
564 (name "llvm")
565 (version "3.8.1")
566 (source
567 (origin
568 (method url-fetch)
569 (uri (llvm-download-uri "llvm" version))
570 (sha256
571 (base32
572 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
573
574 (define-public clang-runtime-3.8
575 (clang-runtime-from-llvm
576 llvm-3.8
577 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
578 '("clang-runtime-asan-build-fixes.patch"
579 "clang-runtime-3.8-libsanitizer-mode-field.patch"
580 "clang-3.5-libsanitizer-ustat-fix.patch")))
581
582 (define-public clang-3.8
583 (clang-from-llvm llvm-3.8 clang-runtime-3.8
584 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
585 #:patches '("clang-3.8-libc-search-path.patch")))
586
587 (define-public llvm-3.7
588 (package (inherit llvm-3.8)
589 (version "3.7.1")
590 (source
591 (origin
592 (method url-fetch)
593 (uri (llvm-download-uri "llvm" version))
594 (sha256
595 (base32
596 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
597
598 (define-public clang-runtime-3.7
599 (clang-runtime-from-llvm
600 llvm-3.7
601 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
602 '("clang-runtime-asan-build-fixes.patch"
603 "clang-runtime-3.8-libsanitizer-mode-field.patch"
604 "clang-3.5-libsanitizer-ustat-fix.patch")))
605
606 (define-public clang-3.7
607 (clang-from-llvm llvm-3.7 clang-runtime-3.7
608 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
609 #:patches '("clang-3.5-libc-search-path.patch")))
610
611 (define-public llvm-3.6
612 (package (inherit llvm-3.7)
613 (version "3.6.2")
614 (source
615 (origin
616 (method url-fetch)
617 (uri (llvm-download-uri "llvm" version))
618 (sha256
619 (base32
620 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
621
622 (define-public clang-runtime-3.6
623 (clang-runtime-from-llvm
624 llvm-3.6
625 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
626 '("clang-runtime-asan-build-fixes.patch")))
627
628 (define-public clang-3.6
629 (clang-from-llvm llvm-3.6 clang-runtime-3.6
630 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
631 #:patches '("clang-3.5-libc-search-path.patch")))
632
633 (define-public llvm-3.5
634 (package (inherit llvm-3.6)
635 (version "3.5.2")
636 (source
637 (origin
638 (method url-fetch)
639 (uri (llvm-download-uri "llvm" version))
640 (patches
641 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
642 (sha256
643 (base32
644 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
645
646 (define-public clang-runtime-3.5
647 (let ((runtime (clang-runtime-from-llvm
648 llvm-3.5
649 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
650 '("clang-runtime-asan-build-fixes.patch"
651 "clang-3.5-libsanitizer-ustat-fix.patch"))))
652 (package
653 (inherit runtime)
654 (arguments
655 (substitute-keyword-arguments (package-arguments runtime)
656 ((#:phases phases '%standard-phases)
657 `(modify-phases ,phases
658 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
659 ;; libtirpc.
660 (add-after 'unpack 'find-rpc-includes
661 (lambda* (#:key inputs #:allow-other-keys)
662 (setenv "CPATH"
663 (string-append (assoc-ref inputs "libtirpc")
664 "/include/tirpc/:"
665 (or (getenv "CPATH") "")))
666 (setenv "CPLUS_INCLUDE_PATH"
667 (string-append (assoc-ref inputs "libtirpc")
668 "/include/tirpc/:"
669 (or (getenv "CPLUS_INCLUDE_PATH") "")))
670 #t))))))
671 (inputs
672 `(("libtirpc" ,libtirpc)
673 ("llvm" ,llvm-3.5))))))
674
675 (define-public clang-3.5
676 (clang-from-llvm llvm-3.5 clang-runtime-3.5
677 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
678 #:patches '("clang-3.5-libc-search-path.patch")))
679
680 (define-public llvm-for-extempore
681 (package (inherit llvm-3.8)
682 (name "llvm-for-extempore")
683 (source
684 (origin
685 (method url-fetch)
686 (uri (string-append "http://extempore.moso.com.au/extras/"
687 "llvm-3.8.0.src-patched-for-extempore.tar.xz"))
688 (sha256
689 (base32
690 "1svdl6fxn8l01ni8mpm0bd5h856ahv3h9sdzgmymr6fayckjvqzs"))))
691 ;; Extempore refuses to build on architectures other than x86_64
692 (supported-systems '("x86_64-linux"))))
693
694 (define-public libcxx
695 (package
696 (name "libcxx")
697 (version "9.0.1")
698 (source
699 (origin
700 (method url-fetch)
701 (uri (llvm-download-uri "libcxx" version))
702 (sha256
703 (base32
704 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
705 (build-system cmake-build-system)
706 (arguments
707 `(#:phases
708 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
709 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
710 (lambda* (#:key inputs #:allow-other-keys)
711 (let ((gcc (assoc-ref inputs "gcc")))
712 ;; Hide GCC's C++ headers so that they do not interfere with
713 ;; the ones we are attempting to build.
714 (setenv "CPLUS_INCLUDE_PATH"
715 (string-join (delete (string-append gcc "/include/c++")
716 (string-split (getenv "CPLUS_INCLUDE_PATH")
717 #\:))
718 ":"))
719 (format #t
720 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
721 (getenv "CPLUS_INCLUDE_PATH"))
722 #t))))))
723 (native-inputs
724 `(("clang" ,clang)
725 ("llvm" ,llvm)))
726 (home-page "https://libcxx.llvm.org")
727 (synopsis "C++ standard library")
728 (description
729 "This package provides an implementation of the C++ standard library for
730 use with Clang, targeting C++11, C++14 and above.")
731 (license license:expat)))
732
733 ;; Libcxx files specifically used by PySide2.
734 (define-public libcxx-6
735 (package
736 (inherit libcxx)
737 (version (package-version llvm-6))
738 (source
739 (origin
740 (inherit (package-source libcxx))
741 (uri (llvm-download-uri "libcxx" version))
742 (sha256
743 (base32
744 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
745 (native-inputs
746 `(("clang" ,clang-6)
747 ("llvm" ,llvm-6)))))
748
749 (define-public libclc
750 (package
751 (name "libclc")
752 (version "9.0.1")
753 (source
754 (origin
755 (method git-fetch)
756 (uri (git-reference
757 (url "https://github.com/llvm/llvm-project.git")
758 (commit (string-append "llvmorg-" version))))
759 (file-name (git-file-name name version))
760 (sha256
761 (base32
762 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
763 (build-system cmake-build-system)
764 (arguments
765 `(#:configure-flags
766 (list (string-append "-DLLVM_CLANG="
767 (assoc-ref %build-inputs "clang")
768 "/bin/clang")
769 (string-append "-DPYTHON="
770 (assoc-ref %build-inputs "python")
771 "/bin/python3"))
772 #:phases
773 (modify-phases %standard-phases
774 (add-after 'unpack 'chdir
775 (lambda _ (chdir "libclc") #t)))))
776 (native-inputs
777 `(("clang" ,clang)
778 ("llvm" ,llvm)
779 ("python" ,python)))
780 (home-page "https://libclc.llvm.org")
781 (synopsis "Libraries for the OpenCL programming language")
782 (description
783 "This package provides an implementation of the OpenCL library
784 requirements according to version 1.1 of the OpenCL specification.")
785 ;; Apache license 2.0 with LLVM exception
786 (license license:asl2.0)))
787
788 (define-public libomp
789 (package
790 (name "libomp")
791 (version "9.0.1")
792 (source (origin
793 (method url-fetch)
794 (uri (llvm-download-uri "openmp" version))
795 (sha256
796 (base32
797 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
798 (file-name (string-append "libomp-" version ".tar.xz"))))
799 (build-system cmake-build-system)
800 ;; XXX: Note this gets built with GCC because building with Clang itself
801 ;; fails (missing <atomic>, even when libcxx is added as an input.)
802 (arguments
803 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
804 "-DOPENMP_TEST_C_COMPILER=clang"
805 "-DOPENMP_TEST_CXX_COMPILER=clang++")
806 #:test-target "check-libomp"))
807 (native-inputs
808 `(("clang" ,clang)
809 ("llvm" ,llvm)
810 ("perl" ,perl)
811 ("pkg-config" ,pkg-config)))
812 (inputs
813 `(("hwloc" ,hwloc "lib")))
814 (home-page "https://openmp.llvm.org")
815 (synopsis "OpenMP run-time support library")
816 (description
817 "This package provides the run-time support library developed by the LLVM
818 project for the OpenMP multi-theaded programming extension. This package
819 notably provides @file{libgomp.so}, which is has a binary interface compatible
820 with that of libgomp, the GNU Offloading and Multi Processing Library.")
821 (license license:expat)))
822
823 (define-public python-llvmlite
824 (package
825 (name "python-llvmlite")
826 (version "0.30.0")
827 (source
828 (origin
829 (method url-fetch)
830 (uri (pypi-uri "llvmlite" version))
831 (sha256
832 (base32
833 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
834 (build-system python-build-system)
835 (arguments
836 ;; FIXME: One test fails unable to find libm.so
837 ;; https://github.com/numba/llvmlite/issues/537
838 `(#:tests? #f))
839 (inputs
840 `(("llvm"
841 ,(package
842 (inherit llvm-7)
843 (source (origin
844 (inherit (package-source llvm-7))
845 (patches
846 (list
847 (origin
848 (method url-fetch)
849 (uri (string-append "https://raw.githubusercontent.com/numba/"
850 "llvmlite/v" version "/conda-recipes/"
851 "D47188-svml-VF.patch"))
852 (sha256
853 (base32
854 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
855 (origin
856 (method url-fetch)
857 (uri (string-append "https://raw.githubusercontent.com/numba/"
858 "llvmlite/v" version "/conda-recipes/"
859 "twine_cfg_undefined_behavior.patch"))
860 (sha256
861 (base32
862 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
863 (home-page "http://llvmlite.pydata.org")
864 (synopsis "Wrapper around basic LLVM functionality")
865 (description
866 "This package provides a Python binding to LLVM for use in Numba.")
867 (license license:bsd-3)))
868
869 (define (package-elisp-from-package source-package package-name
870 source-files)
871 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
872 SOURCE-FILES found in SOURCE-PACKAGE."
873 (let ((orig (package-source source-package)))
874 (package
875 (inherit source-package)
876 (name package-name)
877 (build-system emacs-build-system)
878 (source (origin
879 (method (origin-method orig))
880 (uri (origin-uri orig))
881 (sha256 (origin-sha256 orig))
882 (file-name (string-append package-name "-"
883 (package-version source-package)))
884 (modules '((guix build utils)
885 (srfi srfi-1)
886 (ice-9 ftw)))
887 (snippet
888 `(let* ((source-files (quote ,source-files))
889 (basenames (map basename source-files)))
890 (map copy-file
891 source-files basenames)
892 (map delete-file-recursively
893 (fold delete
894 (scandir ".")
895 (append '("." "..") basenames)))
896 #t)))))))
897
898 (define-public emacs-clang-format
899 (package
900 (inherit clang)
901 (name "emacs-clang-format")
902 (build-system emacs-build-system)
903 (inputs
904 `(("clang" ,clang)))
905 (arguments
906 `(#:phases
907 (modify-phases %standard-phases
908 (add-after 'unpack 'configure
909 (lambda* (#:key inputs #:allow-other-keys)
910 (let ((clang (assoc-ref inputs "clang")))
911 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
912 (emacs-substitute-variables "clang-format.el"
913 ("clang-format-executable"
914 (string-append clang "/bin/clang-format"))))
915 #t)))))
916 (synopsis "Format code using clang-format")
917 (description "This package filters code through @code{clang-format}
918 to fix its formatting. @code{clang-format} is a tool that formats
919 C/C++/Obj-C code according to a set of style options, see
920 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
921
922 (define-public emacs-clang-rename
923 (package
924 (inherit clang)
925 (name "emacs-clang-rename")
926 (build-system emacs-build-system)
927 (inputs
928 `(("clang" ,clang)))
929 (arguments
930 `(#:phases
931 (modify-phases %standard-phases
932 (add-after 'unpack 'configure
933 (lambda* (#:key inputs #:allow-other-keys)
934 (let ((clang (assoc-ref inputs "clang")))
935 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
936 (emacs-substitute-variables "clang-rename.el"
937 ("clang-rename-binary"
938 (string-append clang "/bin/clang-rename"))))
939 #t)))))
940 (synopsis "Rename every occurrence of a symbol using clang-rename")
941 (description "This package renames every occurrence of a symbol at point
942 using @code{clang-rename}.")))