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 (add-after 'install 'install-clean-up-/share/clang
392 (lambda* (#:key outputs #:allow-other-keys)
393 (let* ((out (assoc-ref outputs "out"))
394 (compl-dir (string-append
395 out "/etc/bash_completion.d")))
396 (with-directory-excursion (string-append out
400 (when (file-exists? file)
402 ;; Delete extensions for proprietary text editors.
403 '("clang-format-bbedit.applescript"
404 "clang-format-sublime.py"
405 ;; Delete Emacs extensions: see their respective Emacs
406 ;; Guix package instead.
407 "clang-rename.el" "clang-format.el"))
408 ;; Install bash completion.
409 (when (file-exists? "bash-autocomplete.sh")
411 (rename-file "bash-autocomplete.sh"
412 (string-append compl-dir "/clang")))))
415 ;; Clang supports the same environment variables as GCC.
417 (list (search-path-specification
418 (variable "C_INCLUDE_PATH")
419 (files '("include")))
420 (search-path-specification
421 (variable "CPLUS_INCLUDE_PATH")
422 (files '("include/c++" "include")))
423 (search-path-specification
424 (variable "LIBRARY_PATH")
425 (files '("lib" "lib64")))))
427 (home-page "https://clang.llvm.org")
428 (synopsis "C language family frontend for LLVM")
430 "Clang is a compiler front end for the C, C++, Objective-C and
431 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
432 project includes the Clang front end, the Clang static analyzer, and several
433 code analysis tools.")
434 (license (if (version>=? version "9.0")
435 license:asl2.0 ;with LLVM exceptions
438 (define (make-clang-toolchain clang)
440 (name (string-append (package-name clang) "-toolchain"))
441 (version (package-version clang))
443 (build-system trivial-build-system)
445 '(#:modules ((guix build union))
447 (use-modules (ice-9 match)
451 (let ((out (assoc-ref %outputs "out")))
454 (((names . directories) ...)
455 (union-build out directories)))
457 (union-build (assoc-ref %outputs "debug")
458 (list (assoc-ref %build-inputs
460 (union-build (assoc-ref %outputs "static")
461 (list (assoc-ref %build-inputs
465 (native-search-paths (package-native-search-paths clang))
466 (search-paths (package-search-paths clang))
468 (license (package-license clang))
469 (home-page "https://clang.llvm.org")
470 (synopsis "Complete Clang toolchain for C/C++ development")
471 (description "This package provides a complete Clang toolchain for C/C++
472 development to be installed in user profiles. This includes Clang, as well as
473 libc (headers and binaries, plus debugging symbols in the @code{debug}
474 output), and Binutils.")
475 (outputs '("out" "debug" "static"))
476 (inputs `(("clang" ,clang)
477 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
478 ("binutils" ,binutils)
480 ("libc-debug" ,glibc "debug")
481 ("libc-static" ,glibc "static")))))
483 (define-public clang-runtime-10
484 (clang-runtime-from-llvm
486 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
488 (define-public clang-10
489 (clang-from-llvm llvm-10 clang-runtime-10
490 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
491 #:patches '("clang-10.0-libc-search-path.patch")
495 (uri (llvm-download-uri "clang-tools-extra"
496 (package-version llvm-10)))
499 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
501 (define-public clang-toolchain-10
502 (make-clang-toolchain clang-10))
504 (define-public llvm-9
511 (uri (llvm-download-uri "llvm" version))
514 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
515 (patch-flags '("-p2"))
516 (patches (search-patches
517 "llvm-9-fix-bitcast-miscompilation.patch"
518 "llvm-9-fix-scev-miscompilation.patch"
519 "llvm-9-fix-lpad-miscompilation.patch"))))))
521 (define-public clang-runtime-9
522 (clang-runtime-from-llvm
524 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
525 '("clang-runtime-9-libsanitizer-mode-field.patch")))
527 (define-public clang-9
528 (clang-from-llvm llvm-9 clang-runtime-9
529 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
530 #:patches '("clang-9.0-libc-search-path.patch")))
532 (define-public clang-toolchain-9
533 (make-clang-toolchain clang-9))
535 ;; Default LLVM and Clang version.
536 (define-public llvm llvm-9)
537 (define-public clang-runtime clang-runtime-9)
538 (define-public clang clang-9)
539 (define-public clang-toolchain clang-toolchain-9)
544 (version (package-version llvm-10))
547 (uri (llvm-download-uri "lld" version))
550 "026pwcbczcg0j5c9h7hxxrn3ki81ia9m9sfn0sy0bvzffv2xg85r"))))
551 (build-system cmake-build-system)
553 `(("llvm" ,llvm-10)))
555 `(#:build-type "Release"
556 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
559 (home-page "https://lld.llvm.org/")
560 (synopsis "Linker from the LLVM project")
561 (description "LLD is a high-performance linker, built as a set of reusable
562 components which highly leverage existing libraries in the larger LLVM Project.")
563 (license license:asl2.0))) ; With LLVM exception
565 (define-public llvm-8
571 (uri (llvm-download-uri "llvm" version))
574 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
575 (license license:ncsa)))
577 (define-public clang-runtime-8
578 (clang-runtime-from-llvm
580 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
581 '("clang-runtime-9-libsanitizer-mode-field.patch")))
583 (define-public clang-8
584 (clang-from-llvm llvm-8 clang-runtime-8
585 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
586 #:patches '("clang-7.0-libc-search-path.patch")))
588 (define-public clang-toolchain-8
589 (make-clang-toolchain clang-8))
591 (define-public llvm-7
597 (uri (llvm-download-uri "llvm" version))
600 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
602 (define-public clang-runtime-7
603 (clang-runtime-from-llvm
605 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
606 '("clang-runtime-9-libsanitizer-mode-field.patch")))
608 (define-public clang-7
609 (clang-from-llvm llvm-7 clang-runtime-7
610 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
611 #:patches '("clang-7.0-libc-search-path.patch")))
613 (define-public clang-toolchain-7
614 (make-clang-toolchain clang-7))
616 (define-public llvm-6
622 (uri (llvm-download-uri "llvm" version))
625 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
627 (define-public clang-runtime-6
628 (clang-runtime-from-llvm
630 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
631 '("clang-runtime-9-libsanitizer-mode-field.patch")))
633 (define-public clang-6
634 (clang-from-llvm llvm-6 clang-runtime-6
635 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
636 #:patches '("clang-6.0-libc-search-path.patch")))
638 (define-public clang-toolchain-6
639 (make-clang-toolchain clang-6))
641 (define-public llvm-3.9.1
642 (package (inherit llvm-6)
648 (uri (llvm-download-uri "llvm" version))
651 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
654 (substitute-keyword-arguments (package-arguments llvm)
656 `(modify-phases ,phases
657 (delete 'install-opt-viewer)))))))
659 (define-public clang-runtime-3.9.1
660 (clang-runtime-from-llvm
662 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
663 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
664 "clang-runtime-asan-build-fixes.patch"
665 "clang-runtime-esan-build-fixes.patch"
666 "clang-3.5-libsanitizer-ustat-fix.patch")))
668 (define-public clang-3.9.1
669 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
670 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
671 #:patches '("clang-3.8-libc-search-path.patch")))
673 (define-public llvm-3.8
674 (package (inherit llvm-3.9.1)
680 (uri (llvm-download-uri "llvm" version))
683 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
685 (define-public clang-runtime-3.8
686 (clang-runtime-from-llvm
688 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
689 '("clang-runtime-asan-build-fixes.patch"
690 "clang-runtime-3.8-libsanitizer-mode-field.patch"
691 "clang-3.5-libsanitizer-ustat-fix.patch")))
693 (define-public clang-3.8
694 (clang-from-llvm llvm-3.8 clang-runtime-3.8
695 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
696 #:patches '("clang-3.8-libc-search-path.patch")))
698 (define-public llvm-3.7
699 (package (inherit llvm-3.8)
704 (uri (llvm-download-uri "llvm" version))
707 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
709 (define-public clang-runtime-3.7
710 (clang-runtime-from-llvm
712 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
713 '("clang-runtime-asan-build-fixes.patch"
714 "clang-runtime-3.8-libsanitizer-mode-field.patch"
715 "clang-3.5-libsanitizer-ustat-fix.patch")))
717 (define-public clang-3.7
718 (clang-from-llvm llvm-3.7 clang-runtime-3.7
719 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
720 #:patches '("clang-3.5-libc-search-path.patch")))
722 (define-public llvm-3.6
723 (package (inherit llvm-3.7)
728 (uri (llvm-download-uri "llvm" version))
731 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
733 (define-public clang-runtime-3.6
734 (clang-runtime-from-llvm
736 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
737 '("clang-runtime-asan-build-fixes.patch")))
739 (define-public clang-3.6
740 (clang-from-llvm llvm-3.6 clang-runtime-3.6
741 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
742 #:patches '("clang-3.5-libc-search-path.patch")))
744 (define-public llvm-3.5
745 (package (inherit llvm-3.6)
750 (uri (llvm-download-uri "llvm" version))
752 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
755 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
757 (define-public clang-runtime-3.5
758 (let ((runtime (clang-runtime-from-llvm
760 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
761 '("clang-runtime-asan-build-fixes.patch"
762 "clang-3.5-libsanitizer-ustat-fix.patch"))))
766 (substitute-keyword-arguments (package-arguments runtime)
767 ((#:phases phases '%standard-phases)
768 `(modify-phases ,phases
769 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
771 (add-after 'unpack 'find-rpc-includes
772 (lambda* (#:key inputs #:allow-other-keys)
774 (string-append (assoc-ref inputs "libtirpc")
776 (or (getenv "CPATH") "")))
777 (setenv "CPLUS_INCLUDE_PATH"
778 (string-append (assoc-ref inputs "libtirpc")
780 (or (getenv "CPLUS_INCLUDE_PATH") "")))
783 `(("libtirpc" ,libtirpc)
784 ("llvm" ,llvm-3.5))))))
786 (define-public clang-3.5
787 (clang-from-llvm llvm-3.5 clang-runtime-3.5
788 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
789 #:patches '("clang-3.5-libc-search-path.patch")))
791 (define-public llvm-for-extempore
792 (package (inherit llvm-3.8)
793 (name "llvm-for-extempore")
797 (uri (string-append "http://extempore.moso.com.au/extras/"
798 "llvm-3.8.0.src-patched-for-extempore.tar.xz"))
801 "1svdl6fxn8l01ni8mpm0bd5h856ahv3h9sdzgmymr6fayckjvqzs"))))
802 ;; Extempore refuses to build on architectures other than x86_64
803 (supported-systems '("x86_64-linux"))))
805 (define-public libcxx
812 (uri (llvm-download-uri "libcxx" version))
815 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
816 (build-system cmake-build-system)
819 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
820 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
821 (lambda* (#:key inputs #:allow-other-keys)
822 (let ((gcc (assoc-ref inputs "gcc")))
823 ;; Hide GCC's C++ headers so that they do not interfere with
824 ;; the ones we are attempting to build.
825 (setenv "CPLUS_INCLUDE_PATH"
826 (string-join (delete (string-append gcc "/include/c++")
827 (string-split (getenv "CPLUS_INCLUDE_PATH")
831 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
832 (getenv "CPLUS_INCLUDE_PATH"))
837 (home-page "https://libcxx.llvm.org")
838 (synopsis "C++ standard library")
840 "This package provides an implementation of the C++ standard library for
841 use with Clang, targeting C++11, C++14 and above.")
842 (license license:expat)))
844 ;; Libcxx files specifically used by PySide2.
845 (define-public libcxx-6
848 (version (package-version llvm-6))
851 (inherit (package-source libcxx))
852 (uri (llvm-download-uri "libcxx" version))
855 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
860 (define-public libclc
868 (url "https://github.com/llvm/llvm-project")
869 (commit (string-append "llvmorg-" version))))
870 (file-name (git-file-name name version))
873 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
874 (build-system cmake-build-system)
877 (list (string-append "-DLLVM_CLANG="
878 (assoc-ref %build-inputs "clang")
880 (string-append "-DPYTHON="
881 (assoc-ref %build-inputs "python")
884 (modify-phases %standard-phases
885 (add-after 'unpack 'chdir
886 (lambda _ (chdir "libclc") #t)))))
891 (home-page "https://libclc.llvm.org")
892 (synopsis "Libraries for the OpenCL programming language")
894 "This package provides an implementation of the OpenCL library
895 requirements according to version 1.1 of the OpenCL specification.")
896 ;; Apache license 2.0 with LLVM exception
897 (license license:asl2.0)))
899 (define-public libomp
905 (uri (llvm-download-uri "openmp" version))
908 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
909 (file-name (string-append "libomp-" version ".tar.xz"))))
910 (build-system cmake-build-system)
911 ;; XXX: Note this gets built with GCC because building with Clang itself
912 ;; fails (missing <atomic>, even when libcxx is added as an input.)
914 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
915 "-DOPENMP_TEST_C_COMPILER=clang"
916 "-DOPENMP_TEST_CXX_COMPILER=clang++")
917 #:test-target "check-libomp"))
922 ("pkg-config" ,pkg-config)))
924 `(("hwloc" ,hwloc "lib")))
925 (home-page "https://openmp.llvm.org")
926 (synopsis "OpenMP run-time support library")
928 "This package provides the run-time support library developed by the LLVM
929 project for the OpenMP multi-theaded programming extension. This package
930 notably provides @file{libgomp.so}, which is has a binary interface compatible
931 with that of libgomp, the GNU Offloading and Multi Processing Library.")
932 (license license:expat)))
934 (define-public python-llvmlite
936 (name "python-llvmlite")
941 (uri (pypi-uri "llvmlite" version))
944 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
945 (build-system python-build-system)
947 ;; FIXME: One test fails unable to find libm.so
948 ;; https://github.com/numba/llvmlite/issues/537
952 ,(let ((patches-commit "486edd5fb2a6667feb5c865f300c0da73785434a"))
957 (inherit (package-source llvm-7))
963 "https://raw.githubusercontent.com/numba/"
964 "llvmlite/" patches-commit "/conda-recipes/"
965 "D47188-svml-VF.patch"))
968 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
972 "https://raw.githubusercontent.com/numba/"
973 "llvmlite/" patches-commit "/conda-recipes/"
974 "twine_cfg_undefined_behavior.patch"))
977 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp"))))))))))))
978 (home-page "http://llvmlite.pydata.org")
979 (synopsis "Wrapper around basic LLVM functionality")
981 "This package provides a Python binding to LLVM for use in Numba.")
982 (license license:bsd-3)))
984 (define-public emacs-clang-format
987 (name "emacs-clang-format")
988 (build-system emacs-build-system)
993 (modify-phases %standard-phases
994 (add-after 'unpack 'configure
995 (lambda* (#:key inputs #:allow-other-keys)
996 (let ((clang (assoc-ref inputs "clang")))
997 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
998 (emacs-substitute-variables "clang-format.el"
999 ("clang-format-executable"
1000 (string-append clang "/bin/clang-format"))))
1002 (synopsis "Format code using clang-format")
1003 (description "This package filters code through @code{clang-format}
1004 to fix its formatting. @code{clang-format} is a tool that formats
1005 C/C++/Obj-C code according to a set of style options, see
1006 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
1008 (define-public emacs-clang-rename
1011 (name "emacs-clang-rename")
1012 (build-system emacs-build-system)
1014 `(("clang" ,clang)))
1017 (modify-phases %standard-phases
1018 (add-after 'unpack 'configure
1019 (lambda* (#:key inputs #:allow-other-keys)
1020 (let ((clang (assoc-ref inputs "clang")))
1021 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1022 (emacs-substitute-variables "clang-rename.el"
1023 ("clang-rename-binary"
1024 (string-append clang "/bin/clang-rename"))))
1026 (synopsis "Rename every occurrence of a symbol using clang-rename")
1027 (description "This package renames every occurrence of a symbol at point
1028 using @code{clang-rename}.")))