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