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>
20 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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 libedit)
52 #:use-module (gnu packages libffi)
53 #:use-module (gnu packages lua)
54 #:use-module (gnu packages mpi)
55 #:use-module (gnu packages ncurses)
56 #:use-module (gnu packages onc-rpc)
57 #:use-module (gnu packages perl)
58 #:use-module (gnu packages pkg-config)
59 #:use-module (gnu packages python)
60 #:use-module (gnu packages swig)
61 #:use-module (gnu packages xml)
62 #:export (system->llvm-target))
64 (define* (system->llvm-target #:optional
65 (system (or (and=> (%current-target-system)
66 gnu-triplet->nix-system)
68 "Return the LLVM target name that corresponds to SYSTEM, a system type such
70 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
71 (letrec-syntax ((matches (syntax-rules (=>)
72 ((_ (system-prefix => target) rest ...)
73 (if (string-prefix? system-prefix system)
77 (error "LLVM target for system is unknown" system)))))
78 (matches ("aarch64" => "AArch64")
80 ("mips64el" => "Mips")
81 ("powerpc" => "PowerPC")
87 (define (llvm-uri component version)
88 (if (version>=? version "9.0.1")
89 (string-append "https://github.com/llvm/llvm-project/releases/download"
90 "/llvmorg-" version "/" component "-" version ".src.tar.xz")
91 (string-append "https://releases.llvm.org/" version "/" component "-"
92 version ".src.tar.xz")))
94 (define* (clang-runtime-from-llvm llvm hash
95 #:optional (patches '()))
97 (name "clang-runtime")
98 (version (package-version llvm))
102 (uri (llvm-uri "compiler-rt" version))
103 (sha256 (base32 hash))
104 (patches (map search-patch patches))))
105 (build-system cmake-build-system)
106 (native-inputs (package-native-inputs llvm))
110 `(;; Don't use '-g' during the build to save space.
111 #:build-type "Release"
112 #:tests? #f ; Tests require gtest
113 #:modules ((srfi srfi-1)
115 ,@%cmake-build-system-modules)
116 #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
117 (add-after 'set-paths 'hide-glibc
118 ;; Work around https://issues.guix.info/issue/36882. We need to
119 ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
120 ;; in GCC, at the bottom of GCC include search-path is used.
121 (lambda* (#:key inputs #:allow-other-keys)
122 (let* ((filters '("libc"))
124 (filter-map (lambda (input)
127 (and (not (member name filters))
130 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
134 (home-page "https://compiler-rt.llvm.org")
135 (synopsis "Runtime library for Clang/LLVM")
137 "The \"clang-runtime\" library provides the implementations of run-time
138 functions for C and C++ programs. It also provides header files that allow C
139 and C++ source code to interface with the \"sanitization\" passes of the clang
140 compiler. In LLVM this library is called \"compiler-rt\".")
141 (license (package-license llvm))
143 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
144 (supported-systems (delete "mips64el-linux" %supported-systems))))
146 (define* (clang-from-llvm llvm clang-runtime hash
147 #:key (patches '()) tools-extra)
148 "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
149 given PATCHES. When TOOLS-EXTRA is given, it must point to the
150 'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
151 'modularize', and other tools."
154 (version (package-version llvm))
158 (uri (llvm-uri (if (version>=? version "9.0.1")
162 (sha256 (base32 hash))
163 (patches (map search-patch patches))))
164 ;; Using cmake allows us to treat llvm as an external library. There
165 ;; doesn't seem to be any way to do this with clang's autotools-based
167 (build-system cmake-build-system)
168 (outputs (if tools-extra '("out" "extra") '("out")))
169 (native-inputs (package-native-inputs llvm))
171 `(("libxml2" ,libxml2)
172 ("gcc-lib" ,gcc "lib")
173 ,@(package-inputs llvm)
175 `(("clang-tools-extra" ,tools-extra))
179 ("clang-runtime" ,clang-runtime)))
182 (list "-DCLANG_INCLUDE_TESTS=True"
184 ;; Find libgcc_s, crtbegin.o, and crtend.o.
185 (string-append "-DGCC_INSTALL_PREFIX="
186 (assoc-ref %build-inputs "gcc-lib"))
188 ;; Use a sane default include directory.
189 (string-append "-DC_INCLUDE_DIRS="
190 (assoc-ref %build-inputs "libc")
193 ;; Don't use '-g' during the build to save space.
194 #:build-type "Release"
196 #:phases (modify-phases %standard-phases
198 `((add-after 'unpack 'add-tools-extra
199 (lambda* (#:key inputs #:allow-other-keys)
200 ;; Unpack the 'clang-tools-extra' tarball under
202 (let ((extra (assoc-ref inputs
203 "clang-tools-extra")))
204 (invoke "tar" "xf" extra)
205 (rename-file ,(string-append
207 (package-version llvm)
211 (add-after 'install 'move-extra-tools
212 (lambda* (#:key outputs #:allow-other-keys)
213 ;; Move the extra tools to the "extra" output.
214 ;; These programs alone weigh in at 296 MiB,
215 ;; because they statically-link a whole bunch of
217 (let* ((out (assoc-ref outputs "out"))
218 (extra (assoc-ref outputs "extra"))
219 (bin (string-append out "/bin"))
220 (bin* (string-append extra "/bin"))
221 (lib (string-append out "/lib")))
222 (define (move program)
223 (rename-file (string-append bin "/" program)
224 (string-append bin* "/"
229 '("clang-apply-replacements"
230 "clang-change-namespace"
233 "clang-include-fixer"
236 "clang-reorder-fields"
242 ;; Remove MiBs of .a files coming from
243 ;; 'clang-tools-extra'.
244 (for-each (lambda (component)
246 (string-append lib "/libclang"
248 '("ApplyReplacements"
256 (for-each delete-file
259 "^(libfindAllSymbols|libclangTidy)"))
262 (add-after 'unpack 'add-missing-triplets
264 ;; Clang iterates through known triplets to search for
265 ;; GCC's headers, but does not recognize some of the
266 ;; triplets that are used in Guix.
267 (substitute* ,@(if (version>=? version "6.0")
268 '("lib/Driver/ToolChains/Gnu.cpp")
269 '("lib/Driver/ToolChains.cpp"))
270 (("\"aarch64-linux-gnu\"," all)
271 (string-append "\"aarch64-unknown-linux-gnu\", "
273 (("\"arm-linux-gnueabihf\"," all)
275 " \"arm-unknown-linux-gnueabihf\","))
276 (("\"i686-pc-linux-gnu\"," all)
277 (string-append "\"i686-unknown-linux-gnu\", "
280 (add-after 'unpack 'set-glibc-file-names
281 (lambda* (#:key inputs #:allow-other-keys)
282 (let ((libc (assoc-ref inputs "libc"))
283 (compiler-rt (assoc-ref inputs "clang-runtime"))
284 (gcc (assoc-ref inputs "gcc")))
286 ((version>=? version "6.0")
287 `(;; Link to libclang_rt files from clang-runtime.
288 (substitute* "lib/Driver/ToolChain.cpp"
289 (("getDriver\\(\\)\\.ResourceDir")
290 (string-append "\"" compiler-rt "\"")))
292 ;; Make "LibDir" refer to <glibc>/lib so that it
293 ;; uses the right dynamic linker file name.
294 (substitute* "lib/Driver/ToolChains/Linux.cpp"
295 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
296 (string-append declaration "\"" libc "/lib\";\n"))
298 ;; Make clang look for libstdc++ in the right
300 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
302 "LibStdCXXIncludePathCandidates[] = { \"" gcc
305 ;; Make sure libc's libdir is on the search path, to
306 ;; allow crt1.o & co. to be found.
308 (string-append libc "/lib")))))
310 `((substitute* "lib/Driver/Tools.cpp"
311 ;; Patch the 'getLinuxDynamicLinker' function so that
312 ;; it uses the right dynamic linker file name.
313 (("/lib64/ld-linux-x86-64.so.2")
315 ,(glibc-dynamic-linker))))
317 ;; Link to libclang_rt files from clang-runtime.
318 ;; This substitution needed slight adjustment in 3.8.
319 ,@(if (version>=? version "3.8")
320 '((substitute* "lib/Driver/Tools.cpp"
321 (("TC\\.getDriver\\(\\)\\.ResourceDir")
322 (string-append "\"" compiler-rt "\""))))
323 '((substitute* "lib/Driver/ToolChain.cpp"
324 (("getDriver\\(\\)\\.ResourceDir")
325 (string-append "\"" compiler-rt "\"")))))
327 ;; Make sure libc's libdir is on the search path, to
328 ;; allow crt1.o & co. to be found.
329 (substitute* "lib/Driver/ToolChains.cpp"
331 (string-append libc "/lib"))))))
333 ,@(if (version>=? version "10")
334 `((add-after 'install 'adjust-cmake-file
335 (lambda* (#:key outputs #:allow-other-keys)
336 (let ((out (assoc-ref outputs "out")))
337 ;; Clang generates a CMake file with "targets"
338 ;; for each installed library file. Downstream
339 ;; consumers of the CMake interface can use this
340 ;; to get absolute library locations. Including
341 ;; this file will needlessly assert that _all_
342 ;; libraries are available, which causes problems
343 ;; in Guix because some are removed (see the
344 ;; move-extra-tools phase). Thus, remove the
345 ;; asserts so that the main functionality works.
349 "/lib/cmake/clang/ClangTargets-release.cmake")
350 (("list\\(APPEND _IMPORT_CHECK_TARGETS.*" all)
351 (string-append "# Disabled by Guix.\n#" all)))
354 ,@(if (version>? version "3.8")
355 `((add-after 'install 'symlink-cfi_blacklist
356 (lambda* (#:key inputs outputs #:allow-other-keys)
357 (let* ((out (assoc-ref outputs "out"))
358 (lib-share (string-append out "/lib/clang/"
360 (compiler-rt (assoc-ref inputs "clang-runtime"))
361 ;; The location varies between Clang versions.
365 (string-append compiler-rt "/cfi_blacklist.txt"))
366 (string-append compiler-rt "/cfi_blacklist.txt"))
367 (else (string-append compiler-rt
368 "/share/cfi_blacklist.txt")))))
370 ;; Symlink cfi_blacklist.txt to where Clang expects
372 (symlink cfi-blacklist
373 (string-append lib-share "/cfi_blacklist.txt"))
376 (add-after 'install 'install-clean-up-/share/clang
377 (lambda* (#:key outputs #:allow-other-keys)
378 (let* ((out (assoc-ref outputs "out"))
379 (compl-dir (string-append
380 out "/etc/bash_completion.d")))
381 (with-directory-excursion (string-append out
385 (when (file-exists? file)
387 ;; Delete extensions for proprietary text editors.
388 '("clang-format-bbedit.applescript"
389 "clang-format-sublime.py"
390 ;; Delete Emacs extensions: see their respective Emacs
391 ;; Guix package instead.
392 "clang-rename.el" "clang-format.el"))
393 ;; Install bash completion.
394 (when (file-exists? "bash-autocomplete.sh")
396 (rename-file "bash-autocomplete.sh"
397 (string-append compl-dir "/clang")))))
400 ;; Clang supports the same environment variables as GCC.
402 (list (search-path-specification
403 (variable "C_INCLUDE_PATH")
404 (files '("include")))
405 (search-path-specification
406 (variable "CPLUS_INCLUDE_PATH")
407 (files '("include/c++" "include")))
408 (search-path-specification
409 (variable "LIBRARY_PATH")
410 (files '("lib" "lib64")))))
412 (home-page "https://clang.llvm.org")
413 (synopsis "C language family frontend for LLVM")
415 "Clang is a compiler front end for the C, C++, Objective-C and
416 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
417 project includes the Clang front end, the Clang static analyzer, and several
418 code analysis tools.")
419 (license (if (version>=? version "9.0")
420 license:asl2.0 ;with LLVM exceptions
423 (define (make-clang-toolchain clang)
425 (name (string-append (package-name clang) "-toolchain"))
426 (version (package-version clang))
428 (build-system trivial-build-system)
430 '(#:modules ((guix build union))
432 (use-modules (ice-9 match)
436 (let ((out (assoc-ref %outputs "out")))
439 (((names . directories) ...)
440 (union-build out directories)))
442 ;; Create 'cc' and 'c++' so that one can use it as a
443 ;; drop-in replacement for the default tool chain and
444 ;; have configure scripts find the compiler.
445 (symlink "clang" (string-append out "/bin/cc"))
446 (symlink "clang++" (string-append out "/bin/c++"))
448 (union-build (assoc-ref %outputs "debug")
449 (list (assoc-ref %build-inputs
451 (union-build (assoc-ref %outputs "static")
452 (list (assoc-ref %build-inputs
457 (append (package-native-search-paths clang)
458 (list (search-path-specification ;copied from glibc
459 (variable "GUIX_LOCPATH")
460 (files '("lib/locale"))))))
461 (search-paths (package-search-paths clang))
463 (license (package-license clang))
464 (home-page "https://clang.llvm.org")
465 (synopsis "Complete Clang toolchain for C/C++ development")
466 (description "This package provides a complete Clang toolchain for C/C++
467 development to be installed in user profiles. This includes Clang, as well as
468 libc (headers and binaries, plus debugging symbols in the @code{debug}
469 output), and Binutils.")
470 (outputs '("out" "debug" "static"))
471 (inputs `(("clang" ,clang)
472 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
473 ("binutils" ,binutils)
475 ("libc-debug" ,glibc "debug")
476 ("libc-static" ,glibc "static")))))
478 (define-public llvm-11
485 (uri (llvm-uri "llvm" version))
488 "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))
489 (build-system cmake-build-system)
490 (outputs '("out" "opt-viewer"))
492 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
495 `(("libffi" ,libffi)))
497 `(("zlib" ,zlib))) ;to use output from llvm-config
499 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
500 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
501 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
502 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
503 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
504 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
506 ;; Don't use '-g' during the build, to save space.
507 #:build-type "Release"
509 (modify-phases %standard-phases
510 (add-before 'build 'shared-lib-workaround
511 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
512 ;; doesn't seem to get the correct rpath to be able to run
513 ;; from the build directory. Set LD_LIBRARY_PATH as a
516 (setenv "LD_LIBRARY_PATH"
517 (string-append (getcwd) "/lib"))
519 (add-after 'install 'install-opt-viewer
520 (lambda* (#:key outputs #:allow-other-keys)
521 (let* ((out (assoc-ref outputs "out"))
522 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
523 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
524 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
525 (mkdir-p opt-viewer-share-dir)
526 (rename-file (string-append out "/share/opt-viewer")
529 (home-page "https://www.llvm.org")
530 (synopsis "Optimizing compiler infrastructure")
532 "LLVM is a compiler infrastructure designed for compile-time, link-time,
533 runtime, and idle-time optimization of programs from arbitrary programming
534 languages. It currently supports compilation of C and C++ programs, using
535 front-ends derived from GCC 4.0.1. A new front-end for the C family of
536 languages is in development. The compiler infrastructure includes mirror sets
537 of programming tools as well as libraries with equivalent functionality.")
538 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
540 (define-public clang-runtime-11
541 (clang-runtime-from-llvm
543 "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip"))
545 (define-public clang-11
546 (clang-from-llvm llvm-11 clang-runtime-11
547 "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg"
548 #:patches '("clang-11.0-libc-search-path.patch")
552 (uri (llvm-uri "clang-tools-extra"
553 (package-version llvm-11)))
556 "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy")))))
558 (define-public clang-toolchain-11
559 (make-clang-toolchain clang-11))
561 (define-public llvm-10
568 (uri (llvm-uri "llvm" version))
571 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))))
573 (define-public clang-runtime-10
574 (clang-runtime-from-llvm
576 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
578 (define-public clang-10
579 (clang-from-llvm llvm-10 clang-runtime-10
580 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
581 #:patches '("clang-10.0-libc-search-path.patch")
585 (uri (llvm-uri "clang-tools-extra"
586 (package-version llvm-10)))
589 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
591 (define-public clang-toolchain-10
592 (make-clang-toolchain clang-10))
594 (define-public llvm-9
601 (uri (llvm-uri "llvm" version))
604 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
605 (patch-flags '("-p2"))
606 (patches (search-patches
607 "llvm-9-fix-bitcast-miscompilation.patch"
608 "llvm-9-fix-scev-miscompilation.patch"
609 "llvm-9-fix-lpad-miscompilation.patch"))))))
611 (define-public clang-runtime-9
612 (clang-runtime-from-llvm
614 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
615 '("clang-runtime-9-libsanitizer-mode-field.patch")))
617 (define-public clang-9
618 (clang-from-llvm llvm-9 clang-runtime-9
619 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
620 #:patches '("clang-9.0-libc-search-path.patch")))
622 (define-public clang-toolchain-9
623 (make-clang-toolchain clang-9))
625 (define-public llvm-8
631 (uri (llvm-uri "llvm" version))
634 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
635 (license license:ncsa)))
637 (define-public clang-runtime-8
638 (clang-runtime-from-llvm
640 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
641 '("clang-runtime-9-libsanitizer-mode-field.patch")))
643 (define-public clang-8
644 (clang-from-llvm llvm-8 clang-runtime-8
645 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
646 #:patches '("clang-7.0-libc-search-path.patch")))
648 (define-public clang-toolchain-8
649 (make-clang-toolchain clang-8))
651 (define-public llvm-7
657 (uri (llvm-uri "llvm" version))
660 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
662 (define-public clang-runtime-7
663 (clang-runtime-from-llvm
665 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
666 '("clang-runtime-9-libsanitizer-mode-field.patch")))
668 (define-public clang-7
669 (clang-from-llvm llvm-7 clang-runtime-7
670 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
671 #:patches '("clang-7.0-libc-search-path.patch")))
673 (define-public clang-toolchain-7
674 (make-clang-toolchain clang-7))
676 (define-public llvm-6
682 (uri (llvm-uri "llvm" version))
685 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
687 (define-public clang-runtime-6
688 (clang-runtime-from-llvm
690 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
691 '("clang-runtime-9-libsanitizer-mode-field.patch")))
693 (define-public clang-6
694 (clang-from-llvm llvm-6 clang-runtime-6
695 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
696 #:patches '("clang-6.0-libc-search-path.patch")))
698 (define-public clang-toolchain-6
699 (make-clang-toolchain clang-6))
701 (define-public llvm-3.9.1
702 (package (inherit llvm-6)
708 (uri (llvm-uri "llvm" version))
711 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
714 (substitute-keyword-arguments (package-arguments llvm)
716 `(modify-phases ,phases
717 (delete 'install-opt-viewer)))))))
719 (define-public clang-runtime-3.9.1
720 (clang-runtime-from-llvm
722 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
723 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
724 "clang-runtime-asan-build-fixes.patch"
725 "clang-runtime-esan-build-fixes.patch"
726 "clang-3.5-libsanitizer-ustat-fix.patch")))
728 (define-public clang-3.9.1
729 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
730 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
731 #:patches '("clang-3.8-libc-search-path.patch")))
733 (define-public llvm-3.8
734 (package (inherit llvm-3.9.1)
740 (uri (llvm-uri "llvm" version))
743 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
745 (define-public clang-runtime-3.8
746 (clang-runtime-from-llvm
748 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
749 '("clang-runtime-asan-build-fixes.patch"
750 "clang-runtime-3.8-libsanitizer-mode-field.patch"
751 "clang-3.5-libsanitizer-ustat-fix.patch")))
753 (define-public clang-3.8
754 (clang-from-llvm llvm-3.8 clang-runtime-3.8
755 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
756 #:patches '("clang-3.8-libc-search-path.patch")))
758 (define-public llvm-3.7
759 (package (inherit llvm-3.8)
764 (uri (llvm-uri "llvm" version))
767 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
769 (define-public clang-runtime-3.7
770 (clang-runtime-from-llvm
772 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
773 '("clang-runtime-asan-build-fixes.patch"
774 "clang-runtime-3.8-libsanitizer-mode-field.patch"
775 "clang-3.5-libsanitizer-ustat-fix.patch")))
777 (define-public clang-3.7
778 (clang-from-llvm llvm-3.7 clang-runtime-3.7
779 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
780 #:patches '("clang-3.5-libc-search-path.patch")))
782 (define-public llvm-3.6
783 (package (inherit llvm-3.7)
788 (uri (llvm-uri "llvm" version))
791 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
793 (define-public clang-runtime-3.6
794 (clang-runtime-from-llvm
796 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
797 '("clang-runtime-asan-build-fixes.patch")))
799 (define-public clang-3.6
800 (clang-from-llvm llvm-3.6 clang-runtime-3.6
801 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
802 #:patches '("clang-3.5-libc-search-path.patch")))
804 (define-public llvm-3.5
805 (package (inherit llvm-3.6)
810 (uri (llvm-uri "llvm" version))
812 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
815 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
817 (define-public clang-runtime-3.5
818 (let ((runtime (clang-runtime-from-llvm
820 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
821 '("clang-runtime-asan-build-fixes.patch"
822 "clang-runtime-3.5-libsanitizer-mode-field.patch"
823 "clang-3.5-libsanitizer-ustat-fix.patch"))))
827 (substitute-keyword-arguments (package-arguments runtime)
828 ((#:phases phases '%standard-phases)
829 `(modify-phases ,phases
830 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
832 (add-after 'unpack 'find-rpc-includes
833 (lambda* (#:key inputs #:allow-other-keys)
835 (string-append (assoc-ref inputs "libtirpc")
837 (or (getenv "CPATH") "")))
838 (setenv "CPLUS_INCLUDE_PATH"
839 (string-append (assoc-ref inputs "libtirpc")
841 (or (getenv "CPLUS_INCLUDE_PATH") "")))
844 `(("libtirpc" ,libtirpc)
845 ("llvm" ,llvm-3.5))))))
847 (define-public clang-3.5
848 (clang-from-llvm llvm-3.5 clang-runtime-3.5
849 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
850 #:patches '("clang-3.5-libc-search-path.patch")))
852 ;; Default LLVM and Clang version.
853 (define-public llvm llvm-9)
854 (define-public clang-runtime clang-runtime-9)
855 (define-public clang clang-9)
856 (define-public clang-toolchain clang-toolchain-9)
864 (uri (llvm-uri "lld" version))
867 "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg"))))
868 (build-system cmake-build-system)
870 `(("llvm" ,llvm-11)))
872 `(#:build-type "Release"
873 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
876 (home-page "https://lld.llvm.org/")
877 (synopsis "Linker from the LLVM project")
878 (description "LLD is a high-performance linker, built as a set of reusable
879 components which highly leverage existing libraries in the larger LLVM Project.")
880 (license license:asl2.0))) ; With LLVM exception
888 (uri (llvm-uri "lldb" version))
891 "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45"))))
892 (build-system cmake-build-system)
894 `(#:configure-flags '("-DCMAKE_CXX_COMPILER=clang++")))
896 `(("pkg-config" ,pkg-config)
899 `(("clang" ,clang-11)
902 ;; Optional (but recommended) inputs.
904 ("editline" ,libedit)
909 (home-page "https://lldb.llvm.org/")
910 (synopsis "Low level debugger")
912 "LLDB is a high performance debugger built as a set of reusable components
913 which highly leverage existing libraries in the larger LLVM project.")
914 (license license:asl2.0))) ;with LLVM exceptions
916 (define-public libcxx
923 (uri (llvm-uri "libcxx" version))
926 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
927 (build-system cmake-build-system)
930 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
931 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
932 (lambda* (#:key inputs #:allow-other-keys)
933 (let ((gcc (assoc-ref inputs "gcc")))
934 ;; Hide GCC's C++ headers so that they do not interfere with
935 ;; the ones we are attempting to build.
936 (setenv "CPLUS_INCLUDE_PATH"
937 (string-join (delete (string-append gcc "/include/c++")
938 (string-split (getenv "CPLUS_INCLUDE_PATH")
942 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
943 (getenv "CPLUS_INCLUDE_PATH"))
948 (home-page "https://libcxx.llvm.org")
949 (synopsis "C++ standard library")
951 "This package provides an implementation of the C++ standard library for
952 use with Clang, targeting C++11, C++14 and above.")
953 (license license:expat)))
955 ;; Libcxx files specifically used by PySide2.
956 (define-public libcxx-6
959 (version (package-version llvm-6))
962 (inherit (package-source libcxx))
963 (uri (llvm-uri "libcxx" version))
966 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
971 (define-public libclc
979 (url "https://github.com/llvm/llvm-project")
980 (commit (string-append "llvmorg-" version))))
981 (file-name (git-file-name name version))
984 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
985 (build-system cmake-build-system)
988 (list (string-append "-DLLVM_CLANG="
989 (assoc-ref %build-inputs "clang")
991 (string-append "-DPYTHON="
992 (assoc-ref %build-inputs "python")
995 (modify-phases %standard-phases
996 (add-after 'unpack 'chdir
997 (lambda _ (chdir "libclc") #t)))))
1001 ("python" ,python)))
1002 (home-page "https://libclc.llvm.org")
1003 (synopsis "Libraries for the OpenCL programming language")
1005 "This package provides an implementation of the OpenCL library
1006 requirements according to version 1.1 of the OpenCL specification.")
1007 ;; Apache license 2.0 with LLVM exception
1008 (license license:asl2.0)))
1010 (define-public libomp
1016 (uri (llvm-uri "openmp" version))
1019 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
1020 (file-name (string-append "libomp-" version ".tar.xz"))))
1021 (build-system cmake-build-system)
1022 ;; XXX: Note this gets built with GCC because building with Clang itself
1023 ;; fails (missing <atomic>, even when libcxx is added as an input.)
1025 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
1026 "-DOPENMP_TEST_C_COMPILER=clang"
1027 "-DOPENMP_TEST_CXX_COMPILER=clang++")
1028 #:test-target "check-libomp"))
1033 ("pkg-config" ,pkg-config)))
1035 `(("hwloc" ,hwloc "lib")))
1036 (home-page "https://openmp.llvm.org")
1037 (synopsis "OpenMP run-time support library")
1039 "This package provides the run-time support library developed by the LLVM
1040 project for the OpenMP multi-theaded programming extension. This package
1041 notably provides @file{libgomp.so}, which is has a binary interface compatible
1042 with that of libgomp, the GNU Offloading and Multi Processing Library.")
1043 (license license:expat)))
1045 (define-public python-llvmlite
1047 (name "python-llvmlite")
1052 (uri (pypi-uri "llvmlite" version))
1055 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
1056 (build-system python-build-system)
1058 ;; FIXME: One test fails unable to find libm.so
1059 ;; https://github.com/numba/llvmlite/issues/537
1063 ,(let ((patches-commit "486edd5fb2a6667feb5c865f300c0da73785434a"))
1068 (inherit (package-source llvm-7))
1074 "https://raw.githubusercontent.com/numba/"
1075 "llvmlite/" patches-commit "/conda-recipes/"
1076 "D47188-svml-VF.patch"))
1079 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
1083 "https://raw.githubusercontent.com/numba/"
1084 "llvmlite/" patches-commit "/conda-recipes/"
1085 "twine_cfg_undefined_behavior.patch"))
1088 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp"))))))))))))
1089 (home-page "http://llvmlite.pydata.org")
1090 (synopsis "Wrapper around basic LLVM functionality")
1092 "This package provides a Python binding to LLVM for use in Numba.")
1093 (license license:bsd-3)))
1095 (define-public emacs-clang-format
1098 (name "emacs-clang-format")
1099 (build-system emacs-build-system)
1101 `(("clang" ,clang)))
1104 (modify-phases %standard-phases
1105 (add-after 'unpack 'configure
1106 (lambda* (#:key inputs #:allow-other-keys)
1107 (let ((clang (assoc-ref inputs "clang")))
1108 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
1109 (emacs-substitute-variables "clang-format.el"
1110 ("clang-format-executable"
1111 (string-append clang "/bin/clang-format"))))
1113 (synopsis "Format code using clang-format")
1114 (description "This package filters code through @code{clang-format}
1115 to fix its formatting. @code{clang-format} is a tool that formats
1116 C/C++/Obj-C code according to a set of style options, see
1117 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
1119 (define-public emacs-clang-rename
1122 (name "emacs-clang-rename")
1123 (build-system emacs-build-system)
1125 `(("clang" ,clang)))
1128 (modify-phases %standard-phases
1129 (add-after 'unpack 'configure
1130 (lambda* (#:key inputs #:allow-other-keys)
1131 (let ((clang (assoc-ref inputs "clang")))
1132 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1133 (emacs-substitute-variables "clang-rename.el"
1134 ("clang-rename-binary"
1135 (string-append clang "/bin/clang-rename"))))
1137 (synopsis "Rename every occurrence of a symbol using clang-rename")
1138 (description "This package renames every occurrence of a symbol at point
1139 using @code{clang-rename}.")))