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>
19 ;;; This file is part of GNU Guix.
21 ;;; GNU Guix is free software; you can redistribute it and/or modify it
22 ;;; under the terms of the GNU General Public License as published by
23 ;;; the Free Software Foundation; either version 3 of the License, or (at
24 ;;; your option) any later version.
26 ;;; GNU Guix is distributed in the hope that it will be useful, but
27 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 ;;; GNU General Public License for more details.
31 ;;; You should have received a copy of the GNU General Public License
32 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
34 (define-module (gnu packages llvm)
35 #:use-module (guix packages)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (guix download)
38 #:use-module (guix git-download)
39 #:use-module (guix utils)
40 #:use-module (guix build-system gnu)
41 #:use-module (guix build-system cmake)
42 #:use-module (guix build-system emacs)
43 #:use-module (guix build-system python)
44 #:use-module (guix build-system trivial)
45 #:use-module (gnu packages)
46 #:use-module (gnu packages base)
47 #:use-module (gnu packages gcc)
48 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
49 #:use-module (gnu packages compression)
50 #:use-module (gnu packages libffi)
51 #:use-module (gnu packages mpi)
52 #:use-module (gnu packages onc-rpc)
53 #:use-module (gnu packages perl)
54 #:use-module (gnu packages pkg-config)
55 #:use-module (gnu packages python)
56 #:use-module (gnu packages xml)
57 #:export (system->llvm-target))
59 (define* (system->llvm-target #:optional
60 (system (or (and=> (%current-target-system)
61 gnu-triplet->nix-system)
63 "Return the LLVM target name that corresponds to SYSTEM, a system type such
65 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
66 (letrec-syntax ((matches (syntax-rules (=>)
67 ((_ (system-prefix => target) rest ...)
68 (if (string-prefix? system-prefix system)
72 (error "LLVM target for system is unknown" system)))))
73 (matches ("aarch64" => "AArch64")
75 ("mips64el" => "Mips")
76 ("powerpc" => "PowerPC")
82 (define (llvm-download-uri component version)
83 (if (version>=? version "9.0.1")
84 (string-append "https://github.com/llvm/llvm-project/releases/download"
85 "/llvmorg-" version "/" component "-" version ".src.tar.xz")
86 (string-append "https://releases.llvm.org/" version "/" component "-"
87 version ".src.tar.xz")))
89 (define-public llvm-10
96 (uri (llvm-download-uri "llvm" version))
99 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))
100 (build-system cmake-build-system)
101 (outputs '("out" "opt-viewer"))
103 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
106 `(("libffi" ,libffi)))
108 `(("zlib" ,zlib))) ;to use output from llvm-config
110 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
111 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
112 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
113 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
114 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
115 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
117 ;; Don't use '-g' during the build, to save space.
118 #:build-type "Release"
120 (modify-phases %standard-phases
121 (add-before 'build 'shared-lib-workaround
122 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
123 ;; doesn't seem to get the correct rpath to be able to run
124 ;; from the build directory. Set LD_LIBRARY_PATH as a
127 (setenv "LD_LIBRARY_PATH"
128 (string-append (getcwd) "/lib"))
130 (add-after 'install 'install-opt-viewer
131 (lambda* (#:key outputs #:allow-other-keys)
132 (let* ((out (assoc-ref outputs "out"))
133 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
134 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
135 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
136 (mkdir-p opt-viewer-share-dir)
137 (rename-file (string-append out "/share/opt-viewer")
140 (home-page "https://www.llvm.org")
141 (synopsis "Optimizing compiler infrastructure")
143 "LLVM is a compiler infrastructure designed for compile-time, link-time,
144 runtime, and idle-time optimization of programs from arbitrary programming
145 languages. It currently supports compilation of C and C++ programs, using
146 front-ends derived from GCC 4.0.1. A new front-end for the C family of
147 languages is in development. The compiler infrastructure includes mirror sets
148 of programming tools as well as libraries with equivalent functionality.")
149 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
151 (define* (clang-runtime-from-llvm llvm hash
152 #:optional (patches '()))
154 (name "clang-runtime")
155 (version (package-version llvm))
159 (uri (llvm-download-uri "compiler-rt" version))
160 (sha256 (base32 hash))
161 (patches (map search-patch patches))))
162 (build-system cmake-build-system)
163 (native-inputs (package-native-inputs llvm))
167 `(;; Don't use '-g' during the build to save space.
168 #:build-type "Release"
169 #:tests? #f ; Tests require gtest
170 #:modules ((srfi srfi-1)
172 ,@%cmake-build-system-modules)
173 #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
174 (add-after 'set-paths 'hide-glibc
175 ;; Work around https://issues.guix.info/issue/36882. We need to
176 ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
177 ;; in GCC, at the bottom of GCC include search-path is used.
178 (lambda* (#:key inputs #:allow-other-keys)
179 (let* ((filters '("libc"))
181 (filter-map (lambda (input)
184 (and (not (member name filters))
187 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
191 (home-page "https://compiler-rt.llvm.org")
192 (synopsis "Runtime library for Clang/LLVM")
194 "The \"clang-runtime\" library provides the implementations of run-time
195 functions for C and C++ programs. It also provides header files that allow C
196 and C++ source code to interface with the \"sanitization\" passes of the clang
197 compiler. In LLVM this library is called \"compiler-rt\".")
198 (license (package-license llvm))
200 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
201 (supported-systems (delete "mips64el-linux" %supported-systems))))
203 (define* (clang-from-llvm llvm clang-runtime hash
207 (version (package-version llvm))
211 (uri (llvm-download-uri (if (version>=? version "9.0.1")
215 (sha256 (base32 hash))
216 (patches (map search-patch patches))))
217 ;; Using cmake allows us to treat llvm as an external library. There
218 ;; doesn't seem to be any way to do this with clang's autotools-based
220 (build-system cmake-build-system)
221 (native-inputs (package-native-inputs llvm))
223 `(("libxml2" ,libxml2)
224 ("gcc-lib" ,gcc "lib")
225 ,@(package-inputs llvm)))
228 ("clang-runtime" ,clang-runtime)))
231 (list "-DCLANG_INCLUDE_TESTS=True"
233 ;; Find libgcc_s, crtbegin.o, and crtend.o.
234 (string-append "-DGCC_INSTALL_PREFIX="
235 (assoc-ref %build-inputs "gcc-lib"))
237 ;; Use a sane default include directory.
238 (string-append "-DC_INCLUDE_DIRS="
239 (assoc-ref %build-inputs "libc")
242 ;; Don't use '-g' during the build to save space.
243 #:build-type "Release"
245 #:phases (modify-phases %standard-phases
246 (add-after 'unpack 'add-missing-triplets
248 ;; Clang iterates through known triplets to search for
249 ;; GCC's headers, but does not recognize some of the
250 ;; triplets that are used in Guix.
251 (substitute* ,@(if (version>=? version "6.0")
252 '("lib/Driver/ToolChains/Gnu.cpp")
253 '("lib/Driver/ToolChains.cpp"))
254 (("\"aarch64-linux-gnu\"," all)
255 (string-append "\"aarch64-unknown-linux-gnu\", "
257 (("\"arm-linux-gnueabihf\"," all)
259 " \"arm-unknown-linux-gnueabihf\","))
260 (("\"i686-pc-linux-gnu\"," all)
261 (string-append "\"i686-unknown-linux-gnu\", "
264 (add-after 'unpack 'set-glibc-file-names
265 (lambda* (#:key inputs #:allow-other-keys)
266 (let ((libc (assoc-ref inputs "libc"))
267 (compiler-rt (assoc-ref inputs "clang-runtime"))
268 (gcc (assoc-ref inputs "gcc")))
270 ((version>=? version "6.0")
271 `(;; Link to libclang_rt files from clang-runtime.
272 (substitute* "lib/Driver/ToolChain.cpp"
273 (("getDriver\\(\\)\\.ResourceDir")
274 (string-append "\"" compiler-rt "\"")))
276 ;; Make "LibDir" refer to <glibc>/lib so that it
277 ;; uses the right dynamic linker file name.
278 (substitute* "lib/Driver/ToolChains/Linux.cpp"
279 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
280 (string-append declaration "\"" libc "/lib\";\n"))
282 ;; Make clang look for libstdc++ in the right
284 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
286 "LibStdCXXIncludePathCandidates[] = { \"" gcc
289 ;; Make sure libc's libdir is on the search path, to
290 ;; allow crt1.o & co. to be found.
292 (string-append libc "/lib")))))
294 `((substitute* "lib/Driver/Tools.cpp"
295 ;; Patch the 'getLinuxDynamicLinker' function so that
296 ;; it uses the right dynamic linker file name.
297 (("/lib64/ld-linux-x86-64.so.2")
299 ,(glibc-dynamic-linker))))
301 ;; Link to libclang_rt files from clang-runtime.
302 ;; This substitution needed slight adjustment in 3.8.
303 ,@(if (version>=? version "3.8")
304 '((substitute* "lib/Driver/Tools.cpp"
305 (("TC\\.getDriver\\(\\)\\.ResourceDir")
306 (string-append "\"" compiler-rt "\""))))
307 '((substitute* "lib/Driver/ToolChain.cpp"
308 (("getDriver\\(\\)\\.ResourceDir")
309 (string-append "\"" compiler-rt "\"")))))
311 ;; Make sure libc's libdir is on the search path, to
312 ;; allow crt1.o & co. to be found.
313 (substitute* "lib/Driver/ToolChains.cpp"
315 (string-append libc "/lib"))))))
317 (add-after 'install 'install-clean-up-/share/clang
318 (lambda* (#:key outputs #:allow-other-keys)
319 (let* ((out (assoc-ref outputs "out"))
320 (compl-dir (string-append
321 out "/etc/bash_completion.d")))
322 (with-directory-excursion (string-append out
326 (when (file-exists? file)
328 ;; Delete extensions for proprietary text editors.
329 '("clang-format-bbedit.applescript"
330 "clang-format-sublime.py"
331 ;; Delete Emacs extensions: see their respective Emacs
332 ;; Guix package instead.
333 "clang-rename.el" "clang-format.el"))
334 ;; Install bash completion.
335 (when (file-exists? "bash-autocomplete.sh")
337 (rename-file "bash-autocomplete.sh"
338 (string-append compl-dir "/clang")))))
341 ;; Clang supports the same environment variables as GCC.
343 (list (search-path-specification
344 (variable "C_INCLUDE_PATH")
345 (files '("include")))
346 (search-path-specification
347 (variable "CPLUS_INCLUDE_PATH")
348 (files '("include/c++" "include")))
349 (search-path-specification
350 (variable "LIBRARY_PATH")
351 (files '("lib" "lib64")))))
353 (home-page "https://clang.llvm.org")
354 (synopsis "C language family frontend for LLVM")
356 "Clang is a compiler front end for the C, C++, Objective-C and
357 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
358 project includes the Clang front end, the Clang static analyzer, and several
359 code analysis tools.")
360 (license (if (version>=? version "9.0")
361 license:asl2.0 ;with LLVM exceptions
364 (define (make-clang-toolchain clang)
366 (name (string-append (package-name clang) "-toolchain"))
367 (version (package-version clang))
369 (build-system trivial-build-system)
371 '(#:modules ((guix build union))
373 (use-modules (ice-9 match)
377 (let ((out (assoc-ref %outputs "out")))
380 (((names . directories) ...)
381 (union-build out directories)))
383 (union-build (assoc-ref %outputs "debug")
384 (list (assoc-ref %build-inputs
386 (union-build (assoc-ref %outputs "static")
387 (list (assoc-ref %build-inputs
391 (native-search-paths (package-native-search-paths clang))
392 (search-paths (package-search-paths clang))
394 (license (package-license clang))
395 (home-page "https://clang.llvm.org")
396 (synopsis "Complete Clang toolchain for C/C++ development")
397 (description "This package provides a complete Clang toolchain for C/C++
398 development to be installed in user profiles. This includes Clang, as well as
399 libc (headers and binaries, plus debugging symbols in the @code{debug}
400 output), and Binutils.")
401 (outputs '("out" "debug" "static"))
402 (inputs `(("clang" ,clang)
403 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
404 ("binutils" ,binutils)
406 ("libc-debug" ,glibc "debug")
407 ("libc-static" ,glibc "static")))))
409 (define-public clang-runtime-10
410 (clang-runtime-from-llvm
412 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
414 (define-public clang-10
415 (clang-from-llvm llvm-10 clang-runtime-10
416 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
417 #:patches '("clang-10.0-libc-search-path.patch")))
419 (define-public clang-toolchain-10
420 (make-clang-toolchain clang-10))
422 (define-public llvm-9
429 (uri (llvm-download-uri "llvm" version))
432 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))))))
434 (define-public clang-runtime-9
435 (clang-runtime-from-llvm
437 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
438 '("clang-runtime-9-libsanitizer-mode-field.patch")))
440 (define-public clang-9
441 (clang-from-llvm llvm-9 clang-runtime-9
442 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
443 #:patches '("clang-9.0-libc-search-path.patch")))
445 (define-public clang-toolchain-9
446 (make-clang-toolchain clang-9))
448 ;; Default LLVM and Clang version.
449 (define-public llvm llvm-9)
450 (define-public clang-runtime clang-runtime-9)
451 (define-public clang clang-9)
452 (define-public clang-toolchain clang-toolchain-9)
454 (define-public llvm-8
460 (uri (llvm-download-uri "llvm" version))
463 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
464 (license license:ncsa)))
466 (define-public clang-runtime-8
467 (clang-runtime-from-llvm
469 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
470 '("clang-runtime-9-libsanitizer-mode-field.patch")))
472 (define-public clang-8
473 (clang-from-llvm llvm-8 clang-runtime-8
474 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
475 #:patches '("clang-7.0-libc-search-path.patch")))
477 (define-public clang-toolchain-8
478 (make-clang-toolchain clang-8))
480 (define-public llvm-7
486 (uri (llvm-download-uri "llvm" version))
489 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
491 (define-public clang-runtime-7
492 (clang-runtime-from-llvm
494 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
495 '("clang-runtime-9-libsanitizer-mode-field.patch")))
497 (define-public clang-7
498 (clang-from-llvm llvm-7 clang-runtime-7
499 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
500 #:patches '("clang-7.0-libc-search-path.patch")))
502 (define-public clang-toolchain-7
503 (make-clang-toolchain clang-7))
505 (define-public llvm-6
511 (uri (llvm-download-uri "llvm" version))
514 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
516 (define-public clang-runtime-6
517 (clang-runtime-from-llvm
519 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
520 '("clang-runtime-9-libsanitizer-mode-field.patch")))
522 (define-public clang-6
523 (clang-from-llvm llvm-6 clang-runtime-6
524 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
525 #:patches '("clang-6.0-libc-search-path.patch")))
527 (define-public clang-toolchain-6
528 (make-clang-toolchain clang-6))
530 (define-public llvm-3.9.1
531 (package (inherit llvm-6)
537 (uri (llvm-download-uri "llvm" version))
540 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
543 (substitute-keyword-arguments (package-arguments llvm)
545 `(modify-phases ,phases
546 (delete 'install-opt-viewer)))))))
548 (define-public clang-runtime-3.9.1
549 (clang-runtime-from-llvm
551 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
552 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
553 "clang-runtime-asan-build-fixes.patch"
554 "clang-runtime-esan-build-fixes.patch"
555 "clang-3.5-libsanitizer-ustat-fix.patch")))
557 (define-public clang-3.9.1
558 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
559 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
560 #:patches '("clang-3.8-libc-search-path.patch")))
562 (define-public llvm-3.8
563 (package (inherit llvm-3.9.1)
569 (uri (llvm-download-uri "llvm" version))
572 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
574 (define-public clang-runtime-3.8
575 (clang-runtime-from-llvm
577 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
578 '("clang-runtime-asan-build-fixes.patch"
579 "clang-runtime-3.8-libsanitizer-mode-field.patch"
580 "clang-3.5-libsanitizer-ustat-fix.patch")))
582 (define-public clang-3.8
583 (clang-from-llvm llvm-3.8 clang-runtime-3.8
584 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
585 #:patches '("clang-3.8-libc-search-path.patch")))
587 (define-public llvm-3.7
588 (package (inherit llvm-3.8)
593 (uri (llvm-download-uri "llvm" version))
596 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
598 (define-public clang-runtime-3.7
599 (clang-runtime-from-llvm
601 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
602 '("clang-runtime-asan-build-fixes.patch"
603 "clang-runtime-3.8-libsanitizer-mode-field.patch"
604 "clang-3.5-libsanitizer-ustat-fix.patch")))
606 (define-public clang-3.7
607 (clang-from-llvm llvm-3.7 clang-runtime-3.7
608 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
609 #:patches '("clang-3.5-libc-search-path.patch")))
611 (define-public llvm-3.6
612 (package (inherit llvm-3.7)
617 (uri (llvm-download-uri "llvm" version))
620 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
622 (define-public clang-runtime-3.6
623 (clang-runtime-from-llvm
625 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
626 '("clang-runtime-asan-build-fixes.patch")))
628 (define-public clang-3.6
629 (clang-from-llvm llvm-3.6 clang-runtime-3.6
630 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
631 #:patches '("clang-3.5-libc-search-path.patch")))
633 (define-public llvm-3.5
634 (package (inherit llvm-3.6)
639 (uri (llvm-download-uri "llvm" version))
641 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
644 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
646 (define-public clang-runtime-3.5
647 (let ((runtime (clang-runtime-from-llvm
649 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
650 '("clang-runtime-asan-build-fixes.patch"
651 "clang-3.5-libsanitizer-ustat-fix.patch"))))
655 (substitute-keyword-arguments (package-arguments runtime)
656 ((#:phases phases '%standard-phases)
657 `(modify-phases ,phases
658 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
660 (add-after 'unpack 'find-rpc-includes
661 (lambda* (#:key inputs #:allow-other-keys)
663 (string-append (assoc-ref inputs "libtirpc")
665 (or (getenv "CPATH") "")))
666 (setenv "CPLUS_INCLUDE_PATH"
667 (string-append (assoc-ref inputs "libtirpc")
669 (or (getenv "CPLUS_INCLUDE_PATH") "")))
672 `(("libtirpc" ,libtirpc)
673 ("llvm" ,llvm-3.5))))))
675 (define-public clang-3.5
676 (clang-from-llvm llvm-3.5 clang-runtime-3.5
677 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
678 #:patches '("clang-3.5-libc-search-path.patch")))
680 (define-public llvm-for-extempore
681 (package (inherit llvm-3.8)
682 (name "llvm-for-extempore")
686 (uri (string-append "http://extempore.moso.com.au/extras/"
687 "llvm-3.8.0.src-patched-for-extempore.tar.xz"))
690 "1svdl6fxn8l01ni8mpm0bd5h856ahv3h9sdzgmymr6fayckjvqzs"))))
691 ;; Extempore refuses to build on architectures other than x86_64
692 (supported-systems '("x86_64-linux"))))
694 (define-public libcxx
701 (uri (llvm-download-uri "libcxx" version))
704 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
705 (build-system cmake-build-system)
708 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
709 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
710 (lambda* (#:key inputs #:allow-other-keys)
711 (let ((gcc (assoc-ref inputs "gcc")))
712 ;; Hide GCC's C++ headers so that they do not interfere with
713 ;; the ones we are attempting to build.
714 (setenv "CPLUS_INCLUDE_PATH"
715 (string-join (delete (string-append gcc "/include/c++")
716 (string-split (getenv "CPLUS_INCLUDE_PATH")
720 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
721 (getenv "CPLUS_INCLUDE_PATH"))
726 (home-page "https://libcxx.llvm.org")
727 (synopsis "C++ standard library")
729 "This package provides an implementation of the C++ standard library for
730 use with Clang, targeting C++11, C++14 and above.")
731 (license license:expat)))
733 ;; Libcxx files specifically used by PySide2.
734 (define-public libcxx-6
737 (version (package-version llvm-6))
740 (inherit (package-source libcxx))
741 (uri (llvm-download-uri "libcxx" version))
744 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
749 (define-public libclc
757 (url "https://github.com/llvm/llvm-project.git")
758 (commit (string-append "llvmorg-" version))))
759 (file-name (git-file-name name version))
762 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
763 (build-system cmake-build-system)
766 (list (string-append "-DLLVM_CLANG="
767 (assoc-ref %build-inputs "clang")
769 (string-append "-DPYTHON="
770 (assoc-ref %build-inputs "python")
773 (modify-phases %standard-phases
774 (add-after 'unpack 'chdir
775 (lambda _ (chdir "libclc") #t)))))
780 (home-page "https://libclc.llvm.org")
781 (synopsis "Libraries for the OpenCL programming language")
783 "This package provides an implementation of the OpenCL library
784 requirements according to version 1.1 of the OpenCL specification.")
785 ;; Apache license 2.0 with LLVM exception
786 (license license:asl2.0)))
788 (define-public libomp
794 (uri (llvm-download-uri "openmp" version))
797 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
798 (file-name (string-append "libomp-" version ".tar.xz"))))
799 (build-system cmake-build-system)
800 ;; XXX: Note this gets built with GCC because building with Clang itself
801 ;; fails (missing <atomic>, even when libcxx is added as an input.)
803 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
804 "-DOPENMP_TEST_C_COMPILER=clang"
805 "-DOPENMP_TEST_CXX_COMPILER=clang++")
806 #:test-target "check-libomp"))
811 ("pkg-config" ,pkg-config)))
813 `(("hwloc" ,hwloc "lib")))
814 (home-page "https://openmp.llvm.org")
815 (synopsis "OpenMP run-time support library")
817 "This package provides the run-time support library developed by the LLVM
818 project for the OpenMP multi-theaded programming extension. This package
819 notably provides @file{libgomp.so}, which is has a binary interface compatible
820 with that of libgomp, the GNU Offloading and Multi Processing Library.")
821 (license license:expat)))
823 (define-public python-llvmlite
825 (name "python-llvmlite")
830 (uri (pypi-uri "llvmlite" version))
833 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
834 (build-system python-build-system)
836 ;; FIXME: One test fails unable to find libm.so
837 ;; https://github.com/numba/llvmlite/issues/537
844 (inherit (package-source llvm-7))
849 (uri (string-append "https://raw.githubusercontent.com/numba/"
850 "llvmlite/v" version "/conda-recipes/"
851 "D47188-svml-VF.patch"))
854 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
857 (uri (string-append "https://raw.githubusercontent.com/numba/"
858 "llvmlite/v" version "/conda-recipes/"
859 "twine_cfg_undefined_behavior.patch"))
862 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
863 (home-page "http://llvmlite.pydata.org")
864 (synopsis "Wrapper around basic LLVM functionality")
866 "This package provides a Python binding to LLVM for use in Numba.")
867 (license license:bsd-3)))
869 (define (package-elisp-from-package source-package package-name
871 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
872 SOURCE-FILES found in SOURCE-PACKAGE."
873 (let ((orig (package-source source-package)))
875 (inherit source-package)
877 (build-system emacs-build-system)
879 (method (origin-method orig))
880 (uri (origin-uri orig))
881 (sha256 (origin-sha256 orig))
882 (file-name (string-append package-name "-"
883 (package-version source-package)))
884 (modules '((guix build utils)
888 `(let* ((source-files (quote ,source-files))
889 (basenames (map basename source-files)))
891 source-files basenames)
892 (map delete-file-recursively
895 (append '("." "..") basenames)))
898 (define-public emacs-clang-format
901 (name "emacs-clang-format")
902 (build-system emacs-build-system)
907 (modify-phases %standard-phases
908 (add-after 'unpack 'configure
909 (lambda* (#:key inputs #:allow-other-keys)
910 (let ((clang (assoc-ref inputs "clang")))
911 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
912 (emacs-substitute-variables "clang-format.el"
913 ("clang-format-executable"
914 (string-append clang "/bin/clang-format"))))
916 (synopsis "Format code using clang-format")
917 (description "This package filters code through @code{clang-format}
918 to fix its formatting. @code{clang-format} is a tool that formats
919 C/C++/Obj-C code according to a set of style options, see
920 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
922 (define-public emacs-clang-rename
925 (name "emacs-clang-rename")
926 (build-system emacs-build-system)
931 (modify-phases %standard-phases
932 (add-after 'unpack 'configure
933 (lambda* (#:key inputs #:allow-other-keys)
934 (let ((clang (assoc-ref inputs "clang")))
935 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
936 (emacs-substitute-variables "clang-rename.el"
937 ("clang-rename-binary"
938 (string-append clang "/bin/clang-rename"))))
940 (synopsis "Rename every occurrence of a symbol using clang-rename")
941 (description "This package renames every occurrence of a symbol at point
942 using @code{clang-rename}.")))