gnu: ruby-pandoc-ruby: Use pandoc instead of ghc-pandoc.
[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 ,@(if (version>? version "3.8")
392 `((add-after 'install 'symlink-cfi_blacklist
393 (lambda* (#:key inputs outputs #:allow-other-keys)
394 (let* ((out (assoc-ref outputs "out"))
395 (lib-share (string-append out "/lib/clang/"
396 ,version "/share"))
397 (compiler-rt (assoc-ref inputs "clang-runtime"))
398 ;; The location varies between Clang versions.
399 (cfi-blacklist
400 (cond
401 ((file-exists?
402 (string-append compiler-rt "/cfi_blacklist.txt"))
403 (string-append compiler-rt "/cfi_blacklist.txt"))
404 (else (string-append compiler-rt
405 "/share/cfi_blacklist.txt")))))
406 (mkdir-p lib-share)
407 ;; Symlink cfi_blacklist.txt to where Clang expects
408 ;; to find it.
409 (symlink cfi-blacklist
410 (string-append lib-share "/cfi_blacklist.txt"))
411 #t))))
412 '())
413 (add-after 'install 'install-clean-up-/share/clang
414 (lambda* (#:key outputs #:allow-other-keys)
415 (let* ((out (assoc-ref outputs "out"))
416 (compl-dir (string-append
417 out "/etc/bash_completion.d")))
418 (with-directory-excursion (string-append out
419 "/share/clang")
420 (for-each
421 (lambda (file)
422 (when (file-exists? file)
423 (delete-file file)))
424 ;; Delete extensions for proprietary text editors.
425 '("clang-format-bbedit.applescript"
426 "clang-format-sublime.py"
427 ;; Delete Emacs extensions: see their respective Emacs
428 ;; Guix package instead.
429 "clang-rename.el" "clang-format.el"))
430 ;; Install bash completion.
431 (when (file-exists? "bash-autocomplete.sh")
432 (mkdir-p compl-dir)
433 (rename-file "bash-autocomplete.sh"
434 (string-append compl-dir "/clang")))))
435 #t)))))
436
437 ;; Clang supports the same environment variables as GCC.
438 (native-search-paths
439 (list (search-path-specification
440 (variable "C_INCLUDE_PATH")
441 (files '("include")))
442 (search-path-specification
443 (variable "CPLUS_INCLUDE_PATH")
444 (files '("include/c++" "include")))
445 (search-path-specification
446 (variable "LIBRARY_PATH")
447 (files '("lib" "lib64")))))
448
449 (home-page "https://clang.llvm.org")
450 (synopsis "C language family frontend for LLVM")
451 (description
452 "Clang is a compiler front end for the C, C++, Objective-C and
453 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
454 project includes the Clang front end, the Clang static analyzer, and several
455 code analysis tools.")
456 (license (if (version>=? version "9.0")
457 license:asl2.0 ;with LLVM exceptions
458 license:ncsa))))
459
460 (define (make-clang-toolchain clang)
461 (package
462 (name (string-append (package-name clang) "-toolchain"))
463 (version (package-version clang))
464 (source #f)
465 (build-system trivial-build-system)
466 (arguments
467 '(#:modules ((guix build union))
468 #:builder (begin
469 (use-modules (ice-9 match)
470 (srfi srfi-26)
471 (guix build union))
472
473 (let ((out (assoc-ref %outputs "out")))
474
475 (match %build-inputs
476 (((names . directories) ...)
477 (union-build out directories)))
478
479 (union-build (assoc-ref %outputs "debug")
480 (list (assoc-ref %build-inputs
481 "libc-debug")))
482 (union-build (assoc-ref %outputs "static")
483 (list (assoc-ref %build-inputs
484 "libc-static")))
485 #t))))
486
487 (native-search-paths (package-native-search-paths clang))
488 (search-paths (package-search-paths clang))
489
490 (license (package-license clang))
491 (home-page "https://clang.llvm.org")
492 (synopsis "Complete Clang toolchain for C/C++ development")
493 (description "This package provides a complete Clang toolchain for C/C++
494 development to be installed in user profiles. This includes Clang, as well as
495 libc (headers and binaries, plus debugging symbols in the @code{debug}
496 output), and Binutils.")
497 (outputs '("out" "debug" "static"))
498 (inputs `(("clang" ,clang)
499 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
500 ("binutils" ,binutils)
501 ("libc" ,glibc)
502 ("libc-debug" ,glibc "debug")
503 ("libc-static" ,glibc "static")))))
504
505 (define-public clang-runtime-10
506 (clang-runtime-from-llvm
507 llvm-10
508 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
509
510 (define-public clang-10
511 (clang-from-llvm llvm-10 clang-runtime-10
512 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
513 #:patches '("clang-10.0-libc-search-path.patch")
514 #:tools-extra
515 (origin
516 (method url-fetch)
517 (uri (llvm-download-uri "clang-tools-extra"
518 (package-version llvm-10)))
519 (sha256
520 (base32
521 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
522
523 (define-public clang-toolchain-10
524 (make-clang-toolchain clang-10))
525
526 (define-public llvm-9
527 (package
528 (inherit llvm-10)
529 (version "9.0.1")
530 (source
531 (origin
532 (method url-fetch)
533 (uri (llvm-download-uri "llvm" version))
534 (sha256
535 (base32
536 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
537 (patch-flags '("-p2"))
538 (patches (search-patches
539 "llvm-9-fix-bitcast-miscompilation.patch"
540 "llvm-9-fix-scev-miscompilation.patch"
541 "llvm-9-fix-lpad-miscompilation.patch"))))))
542
543 (define-public clang-runtime-9
544 (clang-runtime-from-llvm
545 llvm-9
546 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
547 '("clang-runtime-9-libsanitizer-mode-field.patch")))
548
549 (define-public clang-9
550 (clang-from-llvm llvm-9 clang-runtime-9
551 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
552 #:patches '("clang-9.0-libc-search-path.patch")))
553
554 (define-public clang-toolchain-9
555 (make-clang-toolchain clang-9))
556
557 ;; Default LLVM and Clang version.
558 (define-public llvm llvm-9)
559 (define-public clang-runtime clang-runtime-9)
560 (define-public clang clang-9)
561 (define-public clang-toolchain clang-toolchain-9)
562
563 (define-public lld
564 (package
565 (name "lld")
566 (version (package-version llvm-10))
567 (source (origin
568 (method url-fetch)
569 (uri (llvm-download-uri "lld" version))
570 (sha256
571 (base32
572 "026pwcbczcg0j5c9h7hxxrn3ki81ia9m9sfn0sy0bvzffv2xg85r"))))
573 (build-system cmake-build-system)
574 (inputs
575 `(("llvm" ,llvm-10)))
576 (arguments
577 `(#:build-type "Release"
578 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
579 ;; package.
580 #:tests? #f))
581 (home-page "https://lld.llvm.org/")
582 (synopsis "Linker from the LLVM project")
583 (description "LLD is a high-performance linker, built as a set of reusable
584 components which highly leverage existing libraries in the larger LLVM Project.")
585 (license license:asl2.0))) ; With LLVM exception
586
587 (define-public llvm-8
588 (package
589 (inherit llvm)
590 (version "8.0.0")
591 (source (origin
592 (method url-fetch)
593 (uri (llvm-download-uri "llvm" version))
594 (sha256
595 (base32
596 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
597 (license license:ncsa)))
598
599 (define-public clang-runtime-8
600 (clang-runtime-from-llvm
601 llvm-8
602 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
603 '("clang-runtime-9-libsanitizer-mode-field.patch")))
604
605 (define-public clang-8
606 (clang-from-llvm llvm-8 clang-runtime-8
607 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
608 #:patches '("clang-7.0-libc-search-path.patch")))
609
610 (define-public clang-toolchain-8
611 (make-clang-toolchain clang-8))
612
613 (define-public llvm-7
614 (package
615 (inherit llvm-8)
616 (version "7.0.1")
617 (source (origin
618 (method url-fetch)
619 (uri (llvm-download-uri "llvm" version))
620 (sha256
621 (base32
622 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
623
624 (define-public clang-runtime-7
625 (clang-runtime-from-llvm
626 llvm-7
627 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
628 '("clang-runtime-9-libsanitizer-mode-field.patch")))
629
630 (define-public clang-7
631 (clang-from-llvm llvm-7 clang-runtime-7
632 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
633 #:patches '("clang-7.0-libc-search-path.patch")))
634
635 (define-public clang-toolchain-7
636 (make-clang-toolchain clang-7))
637
638 (define-public llvm-6
639 (package
640 (inherit llvm-7)
641 (version "6.0.1")
642 (source (origin
643 (method url-fetch)
644 (uri (llvm-download-uri "llvm" version))
645 (sha256
646 (base32
647 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
648
649 (define-public clang-runtime-6
650 (clang-runtime-from-llvm
651 llvm-6
652 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
653 '("clang-runtime-9-libsanitizer-mode-field.patch")))
654
655 (define-public clang-6
656 (clang-from-llvm llvm-6 clang-runtime-6
657 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
658 #:patches '("clang-6.0-libc-search-path.patch")))
659
660 (define-public clang-toolchain-6
661 (make-clang-toolchain clang-6))
662
663 (define-public llvm-3.9.1
664 (package (inherit llvm-6)
665 (name "llvm")
666 (version "3.9.1")
667 (source
668 (origin
669 (method url-fetch)
670 (uri (llvm-download-uri "llvm" version))
671 (sha256
672 (base32
673 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
674 (outputs '("out"))
675 (arguments
676 (substitute-keyword-arguments (package-arguments llvm)
677 ((#:phases phases)
678 `(modify-phases ,phases
679 (delete 'install-opt-viewer)))))))
680
681 (define-public clang-runtime-3.9.1
682 (clang-runtime-from-llvm
683 llvm-3.9.1
684 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
685 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
686 "clang-runtime-asan-build-fixes.patch"
687 "clang-runtime-esan-build-fixes.patch"
688 "clang-3.5-libsanitizer-ustat-fix.patch")))
689
690 (define-public clang-3.9.1
691 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
692 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
693 #:patches '("clang-3.8-libc-search-path.patch")))
694
695 (define-public llvm-3.8
696 (package (inherit llvm-3.9.1)
697 (name "llvm")
698 (version "3.8.1")
699 (source
700 (origin
701 (method url-fetch)
702 (uri (llvm-download-uri "llvm" version))
703 (sha256
704 (base32
705 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
706
707 (define-public clang-runtime-3.8
708 (clang-runtime-from-llvm
709 llvm-3.8
710 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
711 '("clang-runtime-asan-build-fixes.patch"
712 "clang-runtime-3.8-libsanitizer-mode-field.patch"
713 "clang-3.5-libsanitizer-ustat-fix.patch")))
714
715 (define-public clang-3.8
716 (clang-from-llvm llvm-3.8 clang-runtime-3.8
717 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
718 #:patches '("clang-3.8-libc-search-path.patch")))
719
720 (define-public llvm-3.7
721 (package (inherit llvm-3.8)
722 (version "3.7.1")
723 (source
724 (origin
725 (method url-fetch)
726 (uri (llvm-download-uri "llvm" version))
727 (sha256
728 (base32
729 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
730
731 (define-public clang-runtime-3.7
732 (clang-runtime-from-llvm
733 llvm-3.7
734 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
735 '("clang-runtime-asan-build-fixes.patch"
736 "clang-runtime-3.8-libsanitizer-mode-field.patch"
737 "clang-3.5-libsanitizer-ustat-fix.patch")))
738
739 (define-public clang-3.7
740 (clang-from-llvm llvm-3.7 clang-runtime-3.7
741 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
742 #:patches '("clang-3.5-libc-search-path.patch")))
743
744 (define-public llvm-3.6
745 (package (inherit llvm-3.7)
746 (version "3.6.2")
747 (source
748 (origin
749 (method url-fetch)
750 (uri (llvm-download-uri "llvm" version))
751 (sha256
752 (base32
753 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
754
755 (define-public clang-runtime-3.6
756 (clang-runtime-from-llvm
757 llvm-3.6
758 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
759 '("clang-runtime-asan-build-fixes.patch")))
760
761 (define-public clang-3.6
762 (clang-from-llvm llvm-3.6 clang-runtime-3.6
763 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
764 #:patches '("clang-3.5-libc-search-path.patch")))
765
766 (define-public llvm-3.5
767 (package (inherit llvm-3.6)
768 (version "3.5.2")
769 (source
770 (origin
771 (method url-fetch)
772 (uri (llvm-download-uri "llvm" version))
773 (patches
774 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
775 (sha256
776 (base32
777 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
778
779 (define-public clang-runtime-3.5
780 (let ((runtime (clang-runtime-from-llvm
781 llvm-3.5
782 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
783 '("clang-runtime-asan-build-fixes.patch"
784 "clang-runtime-3.5-libsanitizer-mode-field.patch"
785 "clang-3.5-libsanitizer-ustat-fix.patch"))))
786 (package
787 (inherit runtime)
788 (arguments
789 (substitute-keyword-arguments (package-arguments runtime)
790 ((#:phases phases '%standard-phases)
791 `(modify-phases ,phases
792 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
793 ;; libtirpc.
794 (add-after 'unpack 'find-rpc-includes
795 (lambda* (#:key inputs #:allow-other-keys)
796 (setenv "CPATH"
797 (string-append (assoc-ref inputs "libtirpc")
798 "/include/tirpc/:"
799 (or (getenv "CPATH") "")))
800 (setenv "CPLUS_INCLUDE_PATH"
801 (string-append (assoc-ref inputs "libtirpc")
802 "/include/tirpc/:"
803 (or (getenv "CPLUS_INCLUDE_PATH") "")))
804 #t))))))
805 (inputs
806 `(("libtirpc" ,libtirpc)
807 ("llvm" ,llvm-3.5))))))
808
809 (define-public clang-3.5
810 (clang-from-llvm llvm-3.5 clang-runtime-3.5
811 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
812 #:patches '("clang-3.5-libc-search-path.patch")))
813
814 (define-public llvm-for-extempore
815 (package (inherit llvm-3.8)
816 (name "llvm-for-extempore")
817 (source
818 (origin
819 (method url-fetch)
820 (uri (string-append "http://extempore.moso.com.au/extras/"
821 "llvm-3.8.0.src-patched-for-extempore.tar.xz"))
822 (sha256
823 (base32
824 "1svdl6fxn8l01ni8mpm0bd5h856ahv3h9sdzgmymr6fayckjvqzs"))))
825 ;; Extempore refuses to build on architectures other than x86_64
826 (supported-systems '("x86_64-linux"))))
827
828 (define-public libcxx
829 (package
830 (name "libcxx")
831 (version "9.0.1")
832 (source
833 (origin
834 (method url-fetch)
835 (uri (llvm-download-uri "libcxx" version))
836 (sha256
837 (base32
838 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
839 (build-system cmake-build-system)
840 (arguments
841 `(#:phases
842 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
843 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
844 (lambda* (#:key inputs #:allow-other-keys)
845 (let ((gcc (assoc-ref inputs "gcc")))
846 ;; Hide GCC's C++ headers so that they do not interfere with
847 ;; the ones we are attempting to build.
848 (setenv "CPLUS_INCLUDE_PATH"
849 (string-join (delete (string-append gcc "/include/c++")
850 (string-split (getenv "CPLUS_INCLUDE_PATH")
851 #\:))
852 ":"))
853 (format #t
854 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
855 (getenv "CPLUS_INCLUDE_PATH"))
856 #t))))))
857 (native-inputs
858 `(("clang" ,clang)
859 ("llvm" ,llvm)))
860 (home-page "https://libcxx.llvm.org")
861 (synopsis "C++ standard library")
862 (description
863 "This package provides an implementation of the C++ standard library for
864 use with Clang, targeting C++11, C++14 and above.")
865 (license license:expat)))
866
867 ;; Libcxx files specifically used by PySide2.
868 (define-public libcxx-6
869 (package
870 (inherit libcxx)
871 (version (package-version llvm-6))
872 (source
873 (origin
874 (inherit (package-source libcxx))
875 (uri (llvm-download-uri "libcxx" version))
876 (sha256
877 (base32
878 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
879 (native-inputs
880 `(("clang" ,clang-6)
881 ("llvm" ,llvm-6)))))
882
883 (define-public libclc
884 (package
885 (name "libclc")
886 (version "9.0.1")
887 (source
888 (origin
889 (method git-fetch)
890 (uri (git-reference
891 (url "https://github.com/llvm/llvm-project")
892 (commit (string-append "llvmorg-" version))))
893 (file-name (git-file-name name version))
894 (sha256
895 (base32
896 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
897 (build-system cmake-build-system)
898 (arguments
899 `(#:configure-flags
900 (list (string-append "-DLLVM_CLANG="
901 (assoc-ref %build-inputs "clang")
902 "/bin/clang")
903 (string-append "-DPYTHON="
904 (assoc-ref %build-inputs "python")
905 "/bin/python3"))
906 #:phases
907 (modify-phases %standard-phases
908 (add-after 'unpack 'chdir
909 (lambda _ (chdir "libclc") #t)))))
910 (native-inputs
911 `(("clang" ,clang)
912 ("llvm" ,llvm)
913 ("python" ,python)))
914 (home-page "https://libclc.llvm.org")
915 (synopsis "Libraries for the OpenCL programming language")
916 (description
917 "This package provides an implementation of the OpenCL library
918 requirements according to version 1.1 of the OpenCL specification.")
919 ;; Apache license 2.0 with LLVM exception
920 (license license:asl2.0)))
921
922 (define-public libomp
923 (package
924 (name "libomp")
925 (version "9.0.1")
926 (source (origin
927 (method url-fetch)
928 (uri (llvm-download-uri "openmp" version))
929 (sha256
930 (base32
931 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
932 (file-name (string-append "libomp-" version ".tar.xz"))))
933 (build-system cmake-build-system)
934 ;; XXX: Note this gets built with GCC because building with Clang itself
935 ;; fails (missing <atomic>, even when libcxx is added as an input.)
936 (arguments
937 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
938 "-DOPENMP_TEST_C_COMPILER=clang"
939 "-DOPENMP_TEST_CXX_COMPILER=clang++")
940 #:test-target "check-libomp"))
941 (native-inputs
942 `(("clang" ,clang)
943 ("llvm" ,llvm)
944 ("perl" ,perl)
945 ("pkg-config" ,pkg-config)))
946 (inputs
947 `(("hwloc" ,hwloc "lib")))
948 (home-page "https://openmp.llvm.org")
949 (synopsis "OpenMP run-time support library")
950 (description
951 "This package provides the run-time support library developed by the LLVM
952 project for the OpenMP multi-theaded programming extension. This package
953 notably provides @file{libgomp.so}, which is has a binary interface compatible
954 with that of libgomp, the GNU Offloading and Multi Processing Library.")
955 (license license:expat)))
956
957 (define-public python-llvmlite
958 (package
959 (name "python-llvmlite")
960 (version "0.30.0")
961 (source
962 (origin
963 (method url-fetch)
964 (uri (pypi-uri "llvmlite" version))
965 (sha256
966 (base32
967 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
968 (build-system python-build-system)
969 (arguments
970 ;; FIXME: One test fails unable to find libm.so
971 ;; https://github.com/numba/llvmlite/issues/537
972 `(#:tests? #f))
973 (inputs
974 `(("llvm"
975 ,(let ((patches-commit "486edd5fb2a6667feb5c865f300c0da73785434a"))
976 (package
977 (inherit llvm-7)
978 (source
979 (origin
980 (inherit (package-source llvm-7))
981 (patches
982 (list
983 (origin
984 (method url-fetch)
985 (uri (string-append
986 "https://raw.githubusercontent.com/numba/"
987 "llvmlite/" patches-commit "/conda-recipes/"
988 "D47188-svml-VF.patch"))
989 (sha256
990 (base32
991 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
992 (origin
993 (method url-fetch)
994 (uri (string-append
995 "https://raw.githubusercontent.com/numba/"
996 "llvmlite/" patches-commit "/conda-recipes/"
997 "twine_cfg_undefined_behavior.patch"))
998 (sha256
999 (base32
1000 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp"))))))))))))
1001 (home-page "http://llvmlite.pydata.org")
1002 (synopsis "Wrapper around basic LLVM functionality")
1003 (description
1004 "This package provides a Python binding to LLVM for use in Numba.")
1005 (license license:bsd-3)))
1006
1007 (define-public emacs-clang-format
1008 (package
1009 (inherit clang)
1010 (name "emacs-clang-format")
1011 (build-system emacs-build-system)
1012 (inputs
1013 `(("clang" ,clang)))
1014 (arguments
1015 `(#:phases
1016 (modify-phases %standard-phases
1017 (add-after 'unpack 'configure
1018 (lambda* (#:key inputs #:allow-other-keys)
1019 (let ((clang (assoc-ref inputs "clang")))
1020 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
1021 (emacs-substitute-variables "clang-format.el"
1022 ("clang-format-executable"
1023 (string-append clang "/bin/clang-format"))))
1024 #t)))))
1025 (synopsis "Format code using clang-format")
1026 (description "This package filters code through @code{clang-format}
1027 to fix its formatting. @code{clang-format} is a tool that formats
1028 C/C++/Obj-C code according to a set of style options, see
1029 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
1030
1031 (define-public emacs-clang-rename
1032 (package
1033 (inherit clang)
1034 (name "emacs-clang-rename")
1035 (build-system emacs-build-system)
1036 (inputs
1037 `(("clang" ,clang)))
1038 (arguments
1039 `(#:phases
1040 (modify-phases %standard-phases
1041 (add-after 'unpack 'configure
1042 (lambda* (#:key inputs #:allow-other-keys)
1043 (let ((clang (assoc-ref inputs "clang")))
1044 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1045 (emacs-substitute-variables "clang-rename.el"
1046 ("clang-rename-binary"
1047 (string-append clang "/bin/clang-rename"))))
1048 #t)))))
1049 (synopsis "Rename every occurrence of a symbol using clang-rename")
1050 (description "This package renames every occurrence of a symbol at point
1051 using @code{clang-rename}.")))