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 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
21 ;;; This file is part of GNU Guix.
23 ;;; GNU Guix is free software; you can redistribute it and/or modify it
24 ;;; under the terms of the GNU General Public License as published by
25 ;;; the Free Software Foundation; either version 3 of the License, or (at
26 ;;; your option) any later version.
28 ;;; GNU Guix is distributed in the hope that it will be useful, but
29 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
30 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 ;;; GNU General Public License for more details.
33 ;;; You should have received a copy of the GNU General Public License
34 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
36 (define-module (gnu packages llvm)
37 #:use-module (guix packages)
38 #:use-module ((guix licenses) #:prefix license:)
39 #:use-module (guix download)
40 #:use-module (guix git-download)
41 #:use-module (guix utils)
42 #:use-module (guix build-system gnu)
43 #:use-module (guix build-system cmake)
44 #:use-module (guix build-system emacs)
45 #:use-module (guix build-system python)
46 #:use-module (guix build-system trivial)
47 #:use-module (gnu packages)
48 #:use-module (gnu packages base)
49 #:use-module (gnu packages gcc)
50 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
51 #:use-module (gnu packages compression)
52 #:use-module (gnu packages libedit)
53 #:use-module (gnu packages libffi)
54 #:use-module (gnu packages lua)
55 #:use-module (gnu packages mpi)
56 #:use-module (gnu packages ncurses)
57 #:use-module (gnu packages onc-rpc)
58 #:use-module (gnu packages perl)
59 #:use-module (gnu packages pkg-config)
60 #:use-module (gnu packages python)
61 #:use-module (gnu packages swig)
62 #:use-module (gnu packages xml)
63 #:export (system->llvm-target))
65 (define* (system->llvm-target #:optional
66 (system (or (and=> (%current-target-system)
67 gnu-triplet->nix-system)
69 "Return the LLVM target name that corresponds to SYSTEM, a system type such
71 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
72 (letrec-syntax ((matches (syntax-rules (=>)
73 ((_ (system-prefix => target) rest ...)
74 (if (string-prefix? system-prefix system)
78 (error "LLVM target for system is unknown" system)))))
79 (matches ("aarch64" => "AArch64")
81 ("mips64el" => "Mips")
82 ("powerpc" => "PowerPC")
88 (define (llvm-uri component version)
89 (string-append "https://github.com/llvm/llvm-project/releases/download"
90 "/llvmorg-" version "/" component "-" version ".src.tar.xz"))
92 (define* (clang-runtime-from-llvm llvm hash
93 #:optional (patches '()))
95 (name "clang-runtime")
96 (version (package-version llvm))
100 (uri (llvm-uri "compiler-rt" version))
101 (sha256 (base32 hash))
102 (patches (map search-patch patches))))
103 (build-system cmake-build-system)
104 (native-inputs (package-native-inputs llvm))
108 `(;; Don't use '-g' during the build to save space.
109 #:build-type "Release"
110 #:tests? #f ; Tests require gtest
111 #:modules ((srfi srfi-1)
113 ,@%cmake-build-system-modules)
114 #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
115 (add-after 'set-paths 'hide-glibc
116 ;; Work around https://issues.guix.info/issue/36882. We need to
117 ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
118 ;; in GCC, at the bottom of GCC include search-path is used.
119 (lambda* (#:key inputs #:allow-other-keys)
120 (let* ((filters '("libc"))
122 (filter-map (lambda (input)
125 (and (not (member name filters))
128 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
132 (home-page "https://compiler-rt.llvm.org")
133 (synopsis "Runtime library for Clang/LLVM")
135 "The \"clang-runtime\" library provides the implementations of run-time
136 functions for C and C++ programs. It also provides header files that allow C
137 and C++ source code to interface with the \"sanitization\" passes of the clang
138 compiler. In LLVM this library is called \"compiler-rt\".")
139 (license (package-license llvm))
141 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
142 (supported-systems (delete "mips64el-linux" %supported-systems))))
144 (define* (clang-from-llvm llvm clang-runtime hash
145 #:key (patches '()) tools-extra)
146 "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
147 given PATCHES. When TOOLS-EXTRA is given, it must point to the
148 'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
149 'modularize', and other tools."
152 (version (package-version llvm))
156 (uri (llvm-uri (if (version>=? version "9.0.1")
160 (sha256 (base32 hash))
161 (patches (map search-patch patches))))
162 ;; Using cmake allows us to treat llvm as an external library. There
163 ;; doesn't seem to be any way to do this with clang's autotools-based
165 (build-system cmake-build-system)
166 (outputs (if tools-extra '("out" "extra") '("out")))
167 (native-inputs (package-native-inputs llvm))
169 `(("libxml2" ,libxml2)
170 ("gcc-lib" ,gcc "lib")
171 ,@(package-inputs llvm)
173 `(("clang-tools-extra" ,tools-extra))
177 ("clang-runtime" ,clang-runtime)))
180 (list "-DCLANG_INCLUDE_TESTS=True"
182 ;; Find libgcc_s, crtbegin.o, and crtend.o.
183 (string-append "-DGCC_INSTALL_PREFIX="
184 (assoc-ref %build-inputs "gcc-lib"))
186 ;; Use a sane default include directory.
187 (string-append "-DC_INCLUDE_DIRS="
188 (assoc-ref %build-inputs "libc")
191 ;; Don't use '-g' during the build to save space.
192 #:build-type "Release"
194 #:phases (modify-phases %standard-phases
196 `((add-after 'unpack 'add-tools-extra
197 (lambda* (#:key inputs #:allow-other-keys)
198 ;; Unpack the 'clang-tools-extra' tarball under
200 (let ((extra (assoc-ref inputs
201 "clang-tools-extra")))
202 (invoke "tar" "xf" extra)
203 (rename-file ,(string-append
205 (package-version llvm)
209 (add-after 'install 'move-extra-tools
210 (lambda* (#:key outputs #:allow-other-keys)
211 ;; Move the extra tools to the "extra" output.
212 ;; These programs alone weigh in at 296 MiB,
213 ;; because they statically-link a whole bunch of
215 (let* ((out (assoc-ref outputs "out"))
216 (extra (assoc-ref outputs "extra"))
217 (bin (string-append out "/bin"))
218 (bin* (string-append extra "/bin"))
219 (lib (string-append out "/lib")))
220 (define (move program)
221 (rename-file (string-append bin "/" program)
222 (string-append bin* "/"
227 '("clang-apply-replacements"
228 "clang-change-namespace"
231 "clang-include-fixer"
234 "clang-reorder-fields"
240 ;; Remove MiBs of .a files coming from
241 ;; 'clang-tools-extra'.
242 (for-each (lambda (component)
244 (string-append lib "/libclang"
246 '("ApplyReplacements"
254 (for-each delete-file
257 "^(libfindAllSymbols|libclangTidy)"))
260 (add-after 'unpack 'add-missing-triplets
262 ;; Clang iterates through known triplets to search for
263 ;; GCC's headers, but does not recognize some of the
264 ;; triplets that are used in Guix.
265 (substitute* ,@(if (version>=? version "6.0")
266 '("lib/Driver/ToolChains/Gnu.cpp")
267 '("lib/Driver/ToolChains.cpp"))
268 (("\"aarch64-linux-gnu\"," all)
269 (string-append "\"aarch64-unknown-linux-gnu\", "
271 (("\"arm-linux-gnueabihf\"," all)
273 " \"arm-unknown-linux-gnueabihf\","))
274 (("\"i686-pc-linux-gnu\"," all)
275 (string-append "\"i686-unknown-linux-gnu\", "
278 (add-after 'unpack 'set-glibc-file-names
279 (lambda* (#:key inputs #:allow-other-keys)
280 (let ((libc (assoc-ref inputs "libc"))
281 (compiler-rt (assoc-ref inputs "clang-runtime"))
282 (gcc (assoc-ref inputs "gcc")))
284 ((version>=? version "6.0")
285 `(;; Link to libclang_rt files from clang-runtime.
286 (substitute* "lib/Driver/ToolChain.cpp"
287 (("getDriver\\(\\)\\.ResourceDir")
288 (string-append "\"" compiler-rt "\"")))
290 ;; Make "LibDir" refer to <glibc>/lib so that it
291 ;; uses the right dynamic linker file name.
292 (substitute* "lib/Driver/ToolChains/Linux.cpp"
293 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
294 (string-append declaration "\"" libc "/lib\";\n"))
296 ;; Make clang look for libstdc++ in the right
298 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
300 "LibStdCXXIncludePathCandidates[] = { \"" gcc
303 ;; Make sure libc's libdir is on the search path, to
304 ;; allow crt1.o & co. to be found.
306 (string-append libc "/lib")))))
308 `((substitute* "lib/Driver/Tools.cpp"
309 ;; Patch the 'getLinuxDynamicLinker' function so that
310 ;; it uses the right dynamic linker file name.
311 (("/lib64/ld-linux-x86-64.so.2")
313 ,(glibc-dynamic-linker))))
315 ;; Link to libclang_rt files from clang-runtime.
316 ;; This substitution needed slight adjustment in 3.8.
317 ,@(if (version>=? version "3.8")
318 '((substitute* "lib/Driver/Tools.cpp"
319 (("TC\\.getDriver\\(\\)\\.ResourceDir")
320 (string-append "\"" compiler-rt "\""))))
321 '((substitute* "lib/Driver/ToolChain.cpp"
322 (("getDriver\\(\\)\\.ResourceDir")
323 (string-append "\"" compiler-rt "\"")))))
325 ;; Make sure libc's libdir is on the search path, to
326 ;; allow crt1.o & co. to be found.
327 (substitute* "lib/Driver/ToolChains.cpp"
329 (string-append libc "/lib"))))))
331 ,@(if (version>=? version "10")
332 `((add-after 'install 'adjust-cmake-file
333 (lambda* (#:key outputs #:allow-other-keys)
334 (let ((out (assoc-ref outputs "out")))
335 ;; Clang generates a CMake file with "targets"
336 ;; for each installed library file. Downstream
337 ;; consumers of the CMake interface can use this
338 ;; to get absolute library locations. Including
339 ;; this file will needlessly assert that _all_
340 ;; libraries are available, which causes problems
341 ;; in Guix because some are removed (see the
342 ;; move-extra-tools phase). Thus, remove the
343 ;; asserts so that the main functionality works.
347 "/lib/cmake/clang/ClangTargets-release.cmake")
348 (("list\\(APPEND _IMPORT_CHECK_TARGETS.*" all)
349 (string-append "# Disabled by Guix.\n#" all)))
352 ,@(if (version>? version "3.8")
353 `((add-after 'install 'symlink-cfi_blacklist
354 (lambda* (#:key inputs outputs #:allow-other-keys)
355 (let* ((out (assoc-ref outputs "out"))
356 (lib-share (string-append out "/lib/clang/"
358 (compiler-rt (assoc-ref inputs "clang-runtime"))
359 ;; The location varies between Clang versions.
363 (string-append compiler-rt "/cfi_blacklist.txt"))
364 (string-append compiler-rt "/cfi_blacklist.txt"))
365 (else (string-append compiler-rt
366 "/share/cfi_blacklist.txt")))))
368 ;; Symlink cfi_blacklist.txt to where Clang expects
370 (symlink cfi-blacklist
371 (string-append lib-share "/cfi_blacklist.txt"))
374 (add-after 'install 'install-clean-up-/share/clang
375 (lambda* (#:key outputs #:allow-other-keys)
376 (let* ((out (assoc-ref outputs "out"))
377 (compl-dir (string-append
378 out "/etc/bash_completion.d")))
379 (with-directory-excursion (string-append out
383 (when (file-exists? file)
385 ;; Delete extensions for proprietary text editors.
386 '("clang-format-bbedit.applescript"
387 "clang-format-sublime.py"
388 ;; Delete Emacs extensions: see their respective Emacs
389 ;; Guix package instead.
390 "clang-rename.el" "clang-format.el"))
391 ;; Install bash completion.
392 (when (file-exists? "bash-autocomplete.sh")
394 (rename-file "bash-autocomplete.sh"
395 (string-append compl-dir "/clang")))))
398 ;; Clang supports the same environment variables as GCC.
400 (list (search-path-specification
401 (variable "C_INCLUDE_PATH")
402 (files '("include")))
403 (search-path-specification
404 (variable "CPLUS_INCLUDE_PATH")
405 (files '("include/c++" "include")))
406 (search-path-specification
407 (variable "LIBRARY_PATH")
408 (files '("lib" "lib64")))))
410 (home-page "https://clang.llvm.org")
411 (synopsis "C language family frontend for LLVM")
413 "Clang is a compiler front end for the C, C++, Objective-C and
414 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
415 project includes the Clang front end, the Clang static analyzer, and several
416 code analysis tools.")
417 (license (if (version>=? version "9.0")
418 license:asl2.0 ;with LLVM exceptions
421 (define (make-clang-toolchain clang)
423 (name (string-append (package-name clang) "-toolchain"))
424 (version (package-version clang))
426 (build-system trivial-build-system)
428 '(#:modules ((guix build union))
430 (use-modules (ice-9 match)
434 (let ((out (assoc-ref %outputs "out")))
437 (((names . directories) ...)
438 (union-build out directories)))
440 ;; Create 'cc' and 'c++' so that one can use it as a
441 ;; drop-in replacement for the default tool chain and
442 ;; have configure scripts find the compiler.
443 (symlink "clang" (string-append out "/bin/cc"))
444 (symlink "clang++" (string-append out "/bin/c++"))
446 (union-build (assoc-ref %outputs "debug")
447 (list (assoc-ref %build-inputs
449 (union-build (assoc-ref %outputs "static")
450 (list (assoc-ref %build-inputs
455 (append (package-native-search-paths clang)
456 (list (search-path-specification ;copied from glibc
457 (variable "GUIX_LOCPATH")
458 (files '("lib/locale"))))))
459 (search-paths (package-search-paths clang))
461 (license (package-license clang))
462 (home-page "https://clang.llvm.org")
463 (synopsis "Complete Clang toolchain for C/C++ development")
464 (description "This package provides a complete Clang toolchain for C/C++
465 development to be installed in user profiles. This includes Clang, as well as
466 libc (headers and binaries, plus debugging symbols in the @code{debug}
467 output), and Binutils.")
468 (outputs '("out" "debug" "static"))
469 (inputs `(("clang" ,clang)
470 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
471 ("binutils" ,binutils)
473 ("libc-debug" ,glibc "debug")
474 ("libc-static" ,glibc "static")))))
476 (define-public llvm-11
483 (uri (llvm-uri "llvm" version))
486 "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))
487 (build-system cmake-build-system)
488 (outputs '("out" "opt-viewer"))
490 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
493 `(("libffi" ,libffi)))
495 `(("zlib" ,zlib))) ;to use output from llvm-config
497 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
498 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
499 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
500 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
501 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
502 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
504 ;; Don't use '-g' during the build, to save space.
505 #:build-type "Release"
507 (modify-phases %standard-phases
508 (add-before 'build 'shared-lib-workaround
509 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
510 ;; doesn't seem to get the correct rpath to be able to run
511 ;; from the build directory. Set LD_LIBRARY_PATH as a
514 (setenv "LD_LIBRARY_PATH"
515 (string-append (getcwd) "/lib"))
517 (add-after 'install 'install-opt-viewer
518 (lambda* (#:key outputs #:allow-other-keys)
519 (let* ((out (assoc-ref outputs "out"))
520 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
521 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
522 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
523 (mkdir-p opt-viewer-share-dir)
524 (rename-file (string-append out "/share/opt-viewer")
527 (home-page "https://www.llvm.org")
528 (synopsis "Optimizing compiler infrastructure")
530 "LLVM is a compiler infrastructure designed for compile-time, link-time,
531 runtime, and idle-time optimization of programs from arbitrary programming
532 languages. It currently supports compilation of C and C++ programs, using
533 front-ends derived from GCC 4.0.1. A new front-end for the C family of
534 languages is in development. The compiler infrastructure includes mirror sets
535 of programming tools as well as libraries with equivalent functionality.")
536 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
538 (define-public clang-runtime-11
539 (clang-runtime-from-llvm
541 "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip"))
543 (define-public clang-11
544 (clang-from-llvm llvm-11 clang-runtime-11
545 "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg"
546 #:patches '("clang-11.0-libc-search-path.patch")
550 (uri (llvm-uri "clang-tools-extra"
551 (package-version llvm-11)))
554 "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy")))))
556 (define-public clang-toolchain-11
557 (make-clang-toolchain clang-11))
559 (define-public llvm-10
566 (uri (llvm-uri "llvm" version))
569 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))))
571 (define-public clang-runtime-10
572 (clang-runtime-from-llvm
574 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
576 (define-public clang-10
577 (clang-from-llvm llvm-10 clang-runtime-10
578 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
579 #:patches '("clang-10.0-libc-search-path.patch")
583 (uri (llvm-uri "clang-tools-extra"
584 (package-version llvm-10)))
587 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
589 (define-public clang-toolchain-10
590 (make-clang-toolchain clang-10))
592 (define-public llvm-9
599 (uri (llvm-uri "llvm" version))
602 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
603 (patches (search-patches
604 "llvm-9-fix-bitcast-miscompilation.patch"
605 "llvm-9-fix-scev-miscompilation.patch"
606 "llvm-9-fix-lpad-miscompilation.patch"))))))
608 (define-public clang-runtime-9
609 (clang-runtime-from-llvm
611 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
612 '("clang-runtime-9-libsanitizer-mode-field.patch")))
614 (define-public clang-9
615 (clang-from-llvm llvm-9 clang-runtime-9
616 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
617 #:patches '("clang-9.0-libc-search-path.patch")))
619 (define-public clang-toolchain-9
620 (make-clang-toolchain clang-9))
622 (define-public llvm-8
628 (uri (llvm-uri "llvm" version))
631 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
632 (license license:ncsa)))
634 (define-public clang-runtime-8
635 (clang-runtime-from-llvm
637 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
638 '("clang-runtime-9-libsanitizer-mode-field.patch")))
640 (define-public clang-8
641 (clang-from-llvm llvm-8 clang-runtime-8
642 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
643 #:patches '("clang-7.0-libc-search-path.patch")))
645 (define-public clang-toolchain-8
646 (make-clang-toolchain clang-8))
648 (define-public llvm-7
654 (uri (llvm-uri "llvm" version))
657 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
659 (define-public clang-runtime-7
660 (clang-runtime-from-llvm
662 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
663 '("clang-runtime-9-libsanitizer-mode-field.patch")))
665 (define-public clang-7
666 (clang-from-llvm llvm-7 clang-runtime-7
667 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
668 #:patches '("clang-7.0-libc-search-path.patch")))
670 (define-public clang-toolchain-7
671 (make-clang-toolchain clang-7))
673 (define-public llvm-6
679 (uri (llvm-uri "llvm" version))
682 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
684 (define-public clang-runtime-6
685 (clang-runtime-from-llvm
687 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
688 '("clang-runtime-9-libsanitizer-mode-field.patch")))
690 (define-public clang-6
691 (clang-from-llvm llvm-6 clang-runtime-6
692 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
693 #:patches '("clang-6.0-libc-search-path.patch")))
695 (define-public clang-toolchain-6
696 (make-clang-toolchain clang-6))
698 (define-public llvm-3.9.1
699 (package (inherit llvm-6)
705 (uri (llvm-uri "llvm" version))
708 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
711 (substitute-keyword-arguments (package-arguments llvm)
713 `(modify-phases ,phases
714 (delete 'install-opt-viewer)))))))
716 (define-public clang-runtime-3.9.1
717 (clang-runtime-from-llvm
719 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
720 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
721 "clang-runtime-asan-build-fixes.patch"
722 "clang-runtime-esan-build-fixes.patch"
723 "clang-3.5-libsanitizer-ustat-fix.patch")))
725 (define-public clang-3.9.1
726 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
727 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
728 #:patches '("clang-3.8-libc-search-path.patch")))
730 (define-public llvm-3.8
731 (package (inherit llvm-3.9.1)
737 (uri (llvm-uri "llvm" version))
740 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
742 (define-public clang-runtime-3.8
743 (clang-runtime-from-llvm
745 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
746 '("clang-runtime-asan-build-fixes.patch"
747 "clang-runtime-3.8-libsanitizer-mode-field.patch"
748 "clang-3.5-libsanitizer-ustat-fix.patch")))
750 (define-public clang-3.8
751 (clang-from-llvm llvm-3.8 clang-runtime-3.8
752 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
753 #:patches '("clang-3.8-libc-search-path.patch")))
755 (define-public llvm-3.7
756 (package (inherit llvm-3.8)
761 (uri (llvm-uri "llvm" version))
764 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
766 (define-public clang-runtime-3.7
767 (clang-runtime-from-llvm
769 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
770 '("clang-runtime-asan-build-fixes.patch"
771 "clang-runtime-3.8-libsanitizer-mode-field.patch"
772 "clang-3.5-libsanitizer-ustat-fix.patch")))
774 (define-public clang-3.7
775 (clang-from-llvm llvm-3.7 clang-runtime-3.7
776 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
777 #:patches '("clang-3.5-libc-search-path.patch")))
779 (define-public llvm-3.6
780 (package (inherit llvm-3.7)
785 (uri (llvm-uri "llvm" version))
788 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
790 (define-public clang-runtime-3.6
791 (clang-runtime-from-llvm
793 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
794 '("clang-runtime-asan-build-fixes.patch")))
796 (define-public clang-3.6
797 (clang-from-llvm llvm-3.6 clang-runtime-3.6
798 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
799 #:patches '("clang-3.5-libc-search-path.patch")))
801 (define-public llvm-3.5
802 (package (inherit llvm-3.6)
807 (uri (llvm-uri "llvm" version))
809 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
812 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
814 (define-public clang-runtime-3.5
815 (let ((runtime (clang-runtime-from-llvm
817 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
818 '("clang-runtime-asan-build-fixes.patch"
819 "clang-runtime-3.5-libsanitizer-mode-field.patch"
820 "clang-3.5-libsanitizer-ustat-fix.patch"))))
824 (substitute-keyword-arguments (package-arguments runtime)
825 ((#:phases phases '%standard-phases)
826 `(modify-phases ,phases
827 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
829 (add-after 'unpack 'find-rpc-includes
830 (lambda* (#:key inputs #:allow-other-keys)
832 (string-append (assoc-ref inputs "libtirpc")
834 (or (getenv "CPATH") "")))
835 (setenv "CPLUS_INCLUDE_PATH"
836 (string-append (assoc-ref inputs "libtirpc")
838 (or (getenv "CPLUS_INCLUDE_PATH") "")))
841 `(("libtirpc" ,libtirpc)
842 ("llvm" ,llvm-3.5))))))
844 (define-public clang-3.5
845 (clang-from-llvm llvm-3.5 clang-runtime-3.5
846 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
847 #:patches '("clang-3.5-libc-search-path.patch")))
849 ;; Default LLVM and Clang version.
850 (define-public llvm llvm-9)
851 (define-public clang-runtime clang-runtime-9)
852 (define-public clang clang-9)
853 (define-public clang-toolchain clang-toolchain-9)
861 (uri (llvm-uri "lld" version))
864 "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg"))))
865 (build-system cmake-build-system)
867 `(("llvm" ,llvm-11)))
869 `(#:build-type "Release"
870 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
873 (home-page "https://lld.llvm.org/")
874 (synopsis "Linker from the LLVM project")
875 (description "LLD is a high-performance linker, built as a set of reusable
876 components which highly leverage existing libraries in the larger LLVM Project.")
877 (license license:asl2.0))) ; With LLVM exception
885 (uri (llvm-uri "lldb" version))
888 "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45"))))
889 (build-system cmake-build-system)
891 `(#:configure-flags '("-DCMAKE_CXX_COMPILER=clang++")))
893 `(("pkg-config" ,pkg-config)
896 `(("clang" ,clang-11)
899 ;; Optional (but recommended) inputs.
901 ("editline" ,libedit)
906 (home-page "https://lldb.llvm.org/")
907 (synopsis "Low level debugger")
909 "LLDB is a high performance debugger built as a set of reusable components
910 which highly leverage existing libraries in the larger LLVM project.")
911 (license license:asl2.0))) ;with LLVM exceptions
913 (define-public libcxx
920 (uri (llvm-uri "libcxx" version))
923 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
924 (build-system cmake-build-system)
927 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
928 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
929 (lambda* (#:key inputs #:allow-other-keys)
930 (let ((gcc (assoc-ref inputs "gcc")))
931 ;; Hide GCC's C++ headers so that they do not interfere with
932 ;; the ones we are attempting to build.
933 (setenv "CPLUS_INCLUDE_PATH"
934 (string-join (delete (string-append gcc "/include/c++")
935 (string-split (getenv "CPLUS_INCLUDE_PATH")
939 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
940 (getenv "CPLUS_INCLUDE_PATH"))
945 (home-page "https://libcxx.llvm.org")
946 (synopsis "C++ standard library")
948 "This package provides an implementation of the C++ standard library for
949 use with Clang, targeting C++11, C++14 and above.")
950 (license license:expat)))
952 ;; Libcxx files specifically used by PySide2.
953 (define-public libcxx-6
956 (version (package-version llvm-6))
959 (inherit (package-source libcxx))
960 (uri (llvm-uri "libcxx" version))
963 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
968 (define-public libclc
976 (url "https://github.com/llvm/llvm-project")
977 (commit (string-append "llvmorg-" version))))
978 (file-name (git-file-name name version))
981 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
982 (build-system cmake-build-system)
985 (list (string-append "-DLLVM_CLANG="
986 (assoc-ref %build-inputs "clang")
988 (string-append "-DPYTHON="
989 (assoc-ref %build-inputs "python")
992 (modify-phases %standard-phases
993 (add-after 'unpack 'chdir
994 (lambda _ (chdir "libclc") #t)))))
999 (home-page "https://libclc.llvm.org")
1000 (synopsis "Libraries for the OpenCL programming language")
1002 "This package provides an implementation of the OpenCL library
1003 requirements according to version 1.1 of the OpenCL specification.")
1004 ;; Apache license 2.0 with LLVM exception
1005 (license license:asl2.0)))
1007 (define-public libomp
1013 (uri (llvm-uri "openmp" version))
1016 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
1017 (file-name (string-append "libomp-" version ".tar.xz"))))
1018 (build-system cmake-build-system)
1019 ;; XXX: Note this gets built with GCC because building with Clang itself
1020 ;; fails (missing <atomic>, even when libcxx is added as an input.)
1022 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
1023 "-DOPENMP_TEST_C_COMPILER=clang"
1024 "-DOPENMP_TEST_CXX_COMPILER=clang++")
1025 #:test-target "check-libomp"))
1030 ("pkg-config" ,pkg-config)))
1032 `(("hwloc" ,hwloc "lib")))
1033 (home-page "https://openmp.llvm.org")
1034 (synopsis "OpenMP run-time support library")
1036 "This package provides the run-time support library developed by the LLVM
1037 project for the OpenMP multi-theaded programming extension. This package
1038 notably provides @file{libgomp.so}, which is has a binary interface compatible
1039 with that of libgomp, the GNU Offloading and Multi Processing Library.")
1040 (license license:expat)))
1042 (define-public python-llvmlite
1044 (name "python-llvmlite")
1049 (uri (pypi-uri "llvmlite" version))
1052 "0qqzs6h34002ig2jn31vk08q9hh5kn84lhmv4bljz3yakg8y0gph"))))
1053 (build-system python-build-system)
1056 (modify-phases %standard-phases
1057 (add-after 'unpack 'patch-reference-to-llvmlite.so
1058 ;; ctypes.CDLL uses dlopen to load libllvmlite.so, which
1059 ;; fails, so locate it by its absolute path. Change it in
1060 ;; ffi.py, not utils.py, because setup.py relies on the
1061 ;; output of get_library_name for proper installation.
1062 (lambda* (#:key outputs #:allow-other-keys)
1063 (let* ((out (assoc-ref outputs "out"))
1064 (libllvmlite.so (string-append out "/lib/python"
1065 ,(version-major+minor
1066 (package-version python))
1067 "/site-packages/llvmlite/"
1068 "binding/libllvmlite.so")))
1069 (substitute* "llvmlite/binding/ffi.py"
1070 (("_lib_name = get_library_name\\(\\)")
1071 (format #f "_lib_name = ~s" libllvmlite.so)))
1073 (add-after 'unpack 'skip-failing-tests
1075 (substitute* "llvmlite/tests/test_binding.py"
1076 ((" def test_libm\\(self\\).*" all)
1077 (string-append " @unittest.skip('Fails on Guix')\n" all)))
1079 (add-before 'build 'set-compiler/linker-flags
1080 (lambda* (#:key inputs #:allow-other-keys)
1081 (let ((llvm (assoc-ref inputs "llvm")))
1082 ;; Refer to ffi/Makefile.linux.
1083 (setenv "CPPFLAGS" "-fPIC")
1084 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
1089 ,(let* ((patches-commit "061ab39e1d4591f3aa842458252a19ad01858167")
1090 (patch-uri (lambda (name)
1092 "https://raw.githubusercontent.com/numba/"
1093 "llvmlite/" patches-commit "/conda-recipes/"
1095 (patch-origin (lambda (name hash)
1098 (uri (patch-uri name))
1099 (sha256 (base32 hash)))))
1100 (arch-independent-patches
1103 "partial-testing.patch"
1104 "1cwy4jsmijd838q0bylxl77vrwrb7ksijfly5062ay32303jmj86")
1106 "0001-Revert-Limit-size-of-non-GlobalValue-name.patch"
1107 "0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295"))))
1108 (if (string=? "aarch64-linux" (%current-system))
1113 (inherit (package-source llvm-9))
1116 "intel-D47188-svml-VF_LLVM9.patch"
1117 "1f9ld7wc8bn4gbvdsmk07w1rq371h42vy05rxsq9a22f57rljqbd")
1118 ,@arch-independent-patches
1119 ,@(origin-patches (package-source llvm-9)))))))
1124 (inherit (package-source llvm-10))
1127 "intel-D47188-svml-VF.patch"
1128 "0n46qjwfl7i12bl7wp0cyxl277axfvaaz5lxx5kdlgwjcpa582dg")
1130 "expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch"
1131 "0jxhjkkwwi1cy898l2n57l73ckpw0v73lqnrifp7r1mwpsh624nv")
1132 ,@arch-independent-patches
1133 ,@(origin-patches (package-source llvm-10))))))))))))
1134 (home-page "https://llvmlite.pydata.org")
1135 (synopsis "Wrapper around basic LLVM functionality")
1137 "This package provides a Python binding to LLVM for use in Numba.")
1138 (license license:bsd-3)))
1140 (define-public emacs-clang-format
1143 (name "emacs-clang-format")
1144 (build-system emacs-build-system)
1146 `(("clang" ,clang)))
1149 (modify-phases %standard-phases
1150 (add-after 'unpack 'configure
1151 (lambda* (#:key inputs #:allow-other-keys)
1152 (let ((clang (assoc-ref inputs "clang")))
1153 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
1154 (emacs-substitute-variables "clang-format.el"
1155 ("clang-format-executable"
1156 (string-append clang "/bin/clang-format"))))
1158 (synopsis "Format code using clang-format")
1159 (description "This package filters code through @code{clang-format}
1160 to fix its formatting. @code{clang-format} is a tool that formats
1161 C/C++/Obj-C code according to a set of style options, see
1162 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
1164 (define-public emacs-clang-rename
1167 (name "emacs-clang-rename")
1168 (build-system emacs-build-system)
1170 `(("clang" ,clang)))
1173 (modify-phases %standard-phases
1174 (add-after 'unpack 'configure
1175 (lambda* (#:key inputs #:allow-other-keys)
1176 (let ((clang (assoc-ref inputs "clang")))
1177 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1178 (emacs-substitute-variables "clang-rename.el"
1179 ("clang-rename-binary"
1180 (string-append clang "/bin/clang-rename"))))
1182 (synopsis "Rename every occurrence of a symbol using clang-rename")
1183 (description "This package renames every occurrence of a symbol at point
1184 using @code{clang-rename}.")))