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 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))
60 (define* (system->llvm-target #:optional
61 (system (or (and=> (%current-target-system)
62 gnu-triplet->nix-system)
64 "Return the LLVM target name that corresponds to SYSTEM, a system type such
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)
73 (error "LLVM target for system is unknown" system)))))
74 (matches ("aarch64" => "AArch64")
76 ("mips64el" => "Mips")
77 ("powerpc" => "PowerPC")
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")))
90 (define-public llvm-10
97 (uri (llvm-download-uri "llvm" version))
100 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))
101 (build-system cmake-build-system)
102 (outputs '("out" "opt-viewer"))
104 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
107 `(("libffi" ,libffi)))
109 `(("zlib" ,zlib))) ;to use output from llvm-config
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.
118 ;; Don't use '-g' during the build, to save space.
119 #:build-type "Release"
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
128 (setenv "LD_LIBRARY_PATH"
129 (string-append (getcwd) "/lib"))
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")
141 (home-page "https://www.llvm.org")
142 (synopsis "Optimizing compiler infrastructure")
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
152 (define* (clang-runtime-from-llvm llvm hash
153 #:optional (patches '()))
155 (name "clang-runtime")
156 (version (package-version llvm))
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))
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)
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"))
182 (filter-map (lambda (input)
185 (and (not (member name filters))
188 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
192 (home-page "https://compiler-rt.llvm.org")
193 (synopsis "Runtime library for Clang/LLVM")
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))
201 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
202 (supported-systems (delete "mips64el-linux" %supported-systems))))
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."
212 (version (package-version llvm))
216 (uri (llvm-download-uri (if (version>=? version "9.0.1")
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
225 (build-system cmake-build-system)
226 (outputs (if tools-extra '("out" "extra") '("out")))
227 (native-inputs (package-native-inputs llvm))
229 `(("libxml2" ,libxml2)
230 ("gcc-lib" ,gcc "lib")
231 ,@(package-inputs llvm)
233 `(("clang-tools-extra" ,tools-extra))
237 ("clang-runtime" ,clang-runtime)))
240 (list "-DCLANG_INCLUDE_TESTS=True"
242 ;; Find libgcc_s, crtbegin.o, and crtend.o.
243 (string-append "-DGCC_INSTALL_PREFIX="
244 (assoc-ref %build-inputs "gcc-lib"))
246 ;; Use a sane default include directory.
247 (string-append "-DC_INCLUDE_DIRS="
248 (assoc-ref %build-inputs "libc")
251 ;; Don't use '-g' during the build to save space.
252 #:build-type "Release"
254 #:phases (modify-phases %standard-phases
256 `((add-after 'unpack 'add-tools-extra
257 (lambda* (#:key inputs #:allow-other-keys)
258 ;; Unpack the 'clang-tools-extra' tarball under
260 (let ((extra (assoc-ref inputs
261 "clang-tools-extra")))
262 (invoke "tar" "xf" extra)
263 (rename-file ,(string-append
265 (package-version llvm)
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
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* "/"
287 '("clang-apply-replacements"
288 "clang-change-namespace"
291 "clang-include-fixer"
294 "clang-reorder-fields"
300 ;; Remove MiBs of .a files coming from
301 ;; 'clang-tools-extra'.
302 (for-each (lambda (component)
304 (string-append lib "/libclang"
306 '("ApplyReplacements"
314 (for-each delete-file
317 "^(libfindAllSymbols|libclangTidy)"))
320 (add-after 'unpack 'add-missing-triplets
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\", "
331 (("\"arm-linux-gnueabihf\"," all)
333 " \"arm-unknown-linux-gnueabihf\","))
334 (("\"i686-pc-linux-gnu\"," all)
335 (string-append "\"i686-unknown-linux-gnu\", "
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")))
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 "\"")))
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"))
356 ;; Make clang look for libstdc++ in the right
358 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
360 "LibStdCXXIncludePathCandidates[] = { \"" gcc
363 ;; Make sure libc's libdir is on the search path, to
364 ;; allow crt1.o & co. to be found.
366 (string-append libc "/lib")))))
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")
373 ,(glibc-dynamic-linker))))
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 "\"")))))
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"
389 (string-append libc "/lib"))))))
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/"
397 (compiler-rt (assoc-ref inputs "clang-runtime"))
398 ;; The location varies between Clang versions.
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")))))
407 ;; Symlink cfi_blacklist.txt to where Clang expects
409 (symlink cfi-blacklist
410 (string-append lib-share "/cfi_blacklist.txt"))
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
422 (when (file-exists? 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")
433 (rename-file "bash-autocomplete.sh"
434 (string-append compl-dir "/clang")))))
437 ;; Clang supports the same environment variables as GCC.
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")))))
449 (home-page "https://clang.llvm.org")
450 (synopsis "C language family frontend for LLVM")
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
460 (define (make-clang-toolchain clang)
462 (name (string-append (package-name clang) "-toolchain"))
463 (version (package-version clang))
465 (build-system trivial-build-system)
467 '(#:modules ((guix build union))
469 (use-modules (ice-9 match)
473 (let ((out (assoc-ref %outputs "out")))
476 (((names . directories) ...)
477 (union-build out directories)))
479 (union-build (assoc-ref %outputs "debug")
480 (list (assoc-ref %build-inputs
482 (union-build (assoc-ref %outputs "static")
483 (list (assoc-ref %build-inputs
487 (native-search-paths (package-native-search-paths clang))
488 (search-paths (package-search-paths clang))
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)
502 ("libc-debug" ,glibc "debug")
503 ("libc-static" ,glibc "static")))))
505 (define-public clang-runtime-10
506 (clang-runtime-from-llvm
508 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
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")
517 (uri (llvm-download-uri "clang-tools-extra"
518 (package-version llvm-10)))
521 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
523 (define-public clang-toolchain-10
524 (make-clang-toolchain clang-10))
526 (define-public llvm-9
533 (uri (llvm-download-uri "llvm" version))
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"))))))
543 (define-public clang-runtime-9
544 (clang-runtime-from-llvm
546 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
547 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
554 (define-public clang-toolchain-9
555 (make-clang-toolchain clang-9))
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)
566 (version (package-version llvm-10))
569 (uri (llvm-download-uri "lld" version))
572 "026pwcbczcg0j5c9h7hxxrn3ki81ia9m9sfn0sy0bvzffv2xg85r"))))
573 (build-system cmake-build-system)
575 `(("llvm" ,llvm-10)))
577 `(#:build-type "Release"
578 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
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
587 (define-public llvm-8
593 (uri (llvm-download-uri "llvm" version))
596 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
597 (license license:ncsa)))
599 (define-public clang-runtime-8
600 (clang-runtime-from-llvm
602 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
603 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
610 (define-public clang-toolchain-8
611 (make-clang-toolchain clang-8))
613 (define-public llvm-7
619 (uri (llvm-download-uri "llvm" version))
622 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
624 (define-public clang-runtime-7
625 (clang-runtime-from-llvm
627 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
628 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
635 (define-public clang-toolchain-7
636 (make-clang-toolchain clang-7))
638 (define-public llvm-6
644 (uri (llvm-download-uri "llvm" version))
647 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
649 (define-public clang-runtime-6
650 (clang-runtime-from-llvm
652 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
653 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
660 (define-public clang-toolchain-6
661 (make-clang-toolchain clang-6))
663 (define-public llvm-3.9.1
664 (package (inherit llvm-6)
670 (uri (llvm-download-uri "llvm" version))
673 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
676 (substitute-keyword-arguments (package-arguments llvm)
678 `(modify-phases ,phases
679 (delete 'install-opt-viewer)))))))
681 (define-public clang-runtime-3.9.1
682 (clang-runtime-from-llvm
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")))
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")))
695 (define-public llvm-3.8
696 (package (inherit llvm-3.9.1)
702 (uri (llvm-download-uri "llvm" version))
705 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
707 (define-public clang-runtime-3.8
708 (clang-runtime-from-llvm
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")))
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")))
720 (define-public llvm-3.7
721 (package (inherit llvm-3.8)
726 (uri (llvm-download-uri "llvm" version))
729 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
731 (define-public clang-runtime-3.7
732 (clang-runtime-from-llvm
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")))
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")))
744 (define-public llvm-3.6
745 (package (inherit llvm-3.7)
750 (uri (llvm-download-uri "llvm" version))
753 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
755 (define-public clang-runtime-3.6
756 (clang-runtime-from-llvm
758 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
759 '("clang-runtime-asan-build-fixes.patch")))
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")))
766 (define-public llvm-3.5
767 (package (inherit llvm-3.6)
772 (uri (llvm-download-uri "llvm" version))
774 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
777 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
779 (define-public clang-runtime-3.5
780 (let ((runtime (clang-runtime-from-llvm
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"))))
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
794 (add-after 'unpack 'find-rpc-includes
795 (lambda* (#:key inputs #:allow-other-keys)
797 (string-append (assoc-ref inputs "libtirpc")
799 (or (getenv "CPATH") "")))
800 (setenv "CPLUS_INCLUDE_PATH"
801 (string-append (assoc-ref inputs "libtirpc")
803 (or (getenv "CPLUS_INCLUDE_PATH") "")))
806 `(("libtirpc" ,libtirpc)
807 ("llvm" ,llvm-3.5))))))
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")))
814 (define-public llvm-for-extempore
815 (package (inherit llvm-3.8)
816 (name "llvm-for-extempore")
820 (uri (string-append "http://extempore.moso.com.au/extras/"
821 "llvm-3.8.0.src-patched-for-extempore.tar.xz"))
824 "1svdl6fxn8l01ni8mpm0bd5h856ahv3h9sdzgmymr6fayckjvqzs"))))
825 ;; Extempore refuses to build on architectures other than x86_64
826 (supported-systems '("x86_64-linux"))))
828 (define-public libcxx
835 (uri (llvm-download-uri "libcxx" version))
838 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
839 (build-system cmake-build-system)
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")
854 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
855 (getenv "CPLUS_INCLUDE_PATH"))
860 (home-page "https://libcxx.llvm.org")
861 (synopsis "C++ standard library")
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)))
867 ;; Libcxx files specifically used by PySide2.
868 (define-public libcxx-6
871 (version (package-version llvm-6))
874 (inherit (package-source libcxx))
875 (uri (llvm-download-uri "libcxx" version))
878 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
883 (define-public libclc
891 (url "https://github.com/llvm/llvm-project")
892 (commit (string-append "llvmorg-" version))))
893 (file-name (git-file-name name version))
896 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
897 (build-system cmake-build-system)
900 (list (string-append "-DLLVM_CLANG="
901 (assoc-ref %build-inputs "clang")
903 (string-append "-DPYTHON="
904 (assoc-ref %build-inputs "python")
907 (modify-phases %standard-phases
908 (add-after 'unpack 'chdir
909 (lambda _ (chdir "libclc") #t)))))
914 (home-page "https://libclc.llvm.org")
915 (synopsis "Libraries for the OpenCL programming language")
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)))
922 (define-public libomp
928 (uri (llvm-download-uri "openmp" version))
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.)
937 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
938 "-DOPENMP_TEST_C_COMPILER=clang"
939 "-DOPENMP_TEST_CXX_COMPILER=clang++")
940 #:test-target "check-libomp"))
945 ("pkg-config" ,pkg-config)))
947 `(("hwloc" ,hwloc "lib")))
948 (home-page "https://openmp.llvm.org")
949 (synopsis "OpenMP run-time support library")
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)))
957 (define-public python-llvmlite
959 (name "python-llvmlite")
964 (uri (pypi-uri "llvmlite" version))
967 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
968 (build-system python-build-system)
970 ;; FIXME: One test fails unable to find libm.so
971 ;; https://github.com/numba/llvmlite/issues/537
975 ,(let ((patches-commit "486edd5fb2a6667feb5c865f300c0da73785434a"))
980 (inherit (package-source llvm-7))
986 "https://raw.githubusercontent.com/numba/"
987 "llvmlite/" patches-commit "/conda-recipes/"
988 "D47188-svml-VF.patch"))
991 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
995 "https://raw.githubusercontent.com/numba/"
996 "llvmlite/" patches-commit "/conda-recipes/"
997 "twine_cfg_undefined_behavior.patch"))
1000 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp"))))))))))))
1001 (home-page "http://llvmlite.pydata.org")
1002 (synopsis "Wrapper around basic LLVM functionality")
1004 "This package provides a Python binding to LLVM for use in Numba.")
1005 (license license:bsd-3)))
1007 (define-public emacs-clang-format
1010 (name "emacs-clang-format")
1011 (build-system emacs-build-system)
1013 `(("clang" ,clang)))
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"))))
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}.")))
1031 (define-public emacs-clang-rename
1034 (name "emacs-clang-rename")
1035 (build-system emacs-build-system)
1037 `(("clang" ,clang)))
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"))))
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}.")))