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")
81 (define (llvm-download-uri component version)
82 (if (version>=? version "9.0.1")
83 (string-append "https://github.com/llvm/llvm-project/releases/download"
84 "/llvmorg-" version "/" component "-" version ".src.tar.xz")
85 (string-append "https://releases.llvm.org/" version "/" component "-"
86 version ".src.tar.xz")))
88 (define-public llvm-10
95 (uri (llvm-download-uri "llvm" version))
98 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))
99 (build-system cmake-build-system)
101 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
104 `(("libffi" ,libffi)))
106 `(("zlib" ,zlib))) ;to use output from llvm-config
108 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
109 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
110 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
111 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
112 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
113 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
115 ;; Don't use '-g' during the build, to save space.
116 #:build-type "Release"
117 #:phases (modify-phases %standard-phases
118 (add-before 'build 'shared-lib-workaround
119 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
120 ;; doesn't seem to get the correct rpath to be able to run
121 ;; from the build directory. Set LD_LIBRARY_PATH as a
124 (setenv "LD_LIBRARY_PATH"
125 (string-append (getcwd) "/lib"))
127 (home-page "https://www.llvm.org")
128 (synopsis "Optimizing compiler infrastructure")
130 "LLVM is a compiler infrastructure designed for compile-time, link-time,
131 runtime, and idle-time optimization of programs from arbitrary programming
132 languages. It currently supports compilation of C and C++ programs, using
133 front-ends derived from GCC 4.0.1. A new front-end for the C family of
134 languages is in development. The compiler infrastructure includes mirror sets
135 of programming tools as well as libraries with equivalent functionality.")
136 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
138 (define* (clang-runtime-from-llvm llvm hash
139 #:optional (patches '()))
141 (name "clang-runtime")
142 (version (package-version llvm))
146 (uri (llvm-download-uri "compiler-rt" version))
147 (sha256 (base32 hash))
148 (patches (map search-patch patches))))
149 (build-system cmake-build-system)
150 (native-inputs (package-native-inputs llvm))
154 `(;; Don't use '-g' during the build to save space.
155 #:build-type "Release"
156 #:tests? #f)) ; Tests require gtest
157 (home-page "https://compiler-rt.llvm.org")
158 (synopsis "Runtime library for Clang/LLVM")
160 "The \"clang-runtime\" library provides the implementations of run-time
161 functions for C and C++ programs. It also provides header files that allow C
162 and C++ source code to interface with the \"sanitization\" passes of the clang
163 compiler. In LLVM this library is called \"compiler-rt\".")
164 (license (package-license llvm))
166 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
167 (supported-systems (delete "mips64el-linux" %supported-systems))))
169 (define* (clang-from-llvm llvm clang-runtime hash
173 (version (package-version llvm))
177 (uri (llvm-download-uri (if (version>=? version "9.0.1")
181 (sha256 (base32 hash))
182 (patches (map search-patch patches))))
183 ;; Using cmake allows us to treat llvm as an external library. There
184 ;; doesn't seem to be any way to do this with clang's autotools-based
186 (build-system cmake-build-system)
187 (native-inputs (package-native-inputs llvm))
189 `(("libxml2" ,libxml2)
190 ("gcc-lib" ,gcc "lib")
191 ,@(package-inputs llvm)))
194 ("clang-runtime" ,clang-runtime)))
197 (list "-DCLANG_INCLUDE_TESTS=True"
199 ;; Find libgcc_s, crtbegin.o, and crtend.o.
200 (string-append "-DGCC_INSTALL_PREFIX="
201 (assoc-ref %build-inputs "gcc-lib"))
203 ;; Use a sane default include directory.
204 (string-append "-DC_INCLUDE_DIRS="
205 (assoc-ref %build-inputs "libc")
208 ;; Don't use '-g' during the build to save space.
209 #:build-type "Release"
211 #:phases (modify-phases %standard-phases
212 (add-after 'unpack 'add-missing-triplets
214 ;; Clang iterates through known triplets to search for
215 ;; GCC's headers, but does not recognize some of the
216 ;; triplets that are used in Guix.
217 (substitute* ,@(if (version>=? version "6.0")
218 '("lib/Driver/ToolChains/Gnu.cpp")
219 '("lib/Driver/ToolChains.cpp"))
220 (("\"aarch64-linux-gnu\"," all)
221 (string-append "\"aarch64-unknown-linux-gnu\", "
223 (("\"arm-linux-gnueabihf\"," all)
225 " \"arm-unknown-linux-gnueabihf\","))
226 (("\"i686-pc-linux-gnu\"," all)
227 (string-append "\"i686-unknown-linux-gnu\", "
230 (add-after 'unpack 'set-glibc-file-names
231 (lambda* (#:key inputs #:allow-other-keys)
232 (let ((libc (assoc-ref inputs "libc"))
233 (compiler-rt (assoc-ref inputs "clang-runtime"))
234 (gcc (assoc-ref inputs "gcc")))
236 ((version>=? version "6.0")
237 `(;; Link to libclang_rt files from clang-runtime.
238 (substitute* "lib/Driver/ToolChain.cpp"
239 (("getDriver\\(\\)\\.ResourceDir")
240 (string-append "\"" compiler-rt "\"")))
242 ;; Make "LibDir" refer to <glibc>/lib so that it
243 ;; uses the right dynamic linker file name.
244 (substitute* "lib/Driver/ToolChains/Linux.cpp"
245 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
246 (string-append declaration "\"" libc "/lib\";\n"))
248 ;; Make clang look for libstdc++ in the right
250 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
252 "LibStdCXXIncludePathCandidates[] = { \"" gcc
255 ;; Make sure libc's libdir is on the search path, to
256 ;; allow crt1.o & co. to be found.
258 (string-append libc "/lib")))))
260 `((substitute* "lib/Driver/Tools.cpp"
261 ;; Patch the 'getLinuxDynamicLinker' function so that
262 ;; it uses the right dynamic linker file name.
263 (("/lib64/ld-linux-x86-64.so.2")
265 ,(glibc-dynamic-linker))))
267 ;; Link to libclang_rt files from clang-runtime.
268 ;; This substitution needed slight adjustment in 3.8.
269 ,@(if (version>=? version "3.8")
270 '((substitute* "lib/Driver/Tools.cpp"
271 (("TC\\.getDriver\\(\\)\\.ResourceDir")
272 (string-append "\"" compiler-rt "\""))))
273 '((substitute* "lib/Driver/ToolChain.cpp"
274 (("getDriver\\(\\)\\.ResourceDir")
275 (string-append "\"" compiler-rt "\"")))))
277 ;; Make sure libc's libdir is on the search path, to
278 ;; allow crt1.o & co. to be found.
279 (substitute* "lib/Driver/ToolChains.cpp"
281 (string-append libc "/lib"))))))
283 (add-after 'install 'install-clean-up-/share/clang
284 (lambda* (#:key outputs #:allow-other-keys)
285 (let* ((out (assoc-ref outputs "out"))
286 (compl-dir (string-append
287 out "/etc/bash_completion.d")))
288 (with-directory-excursion (string-append out
292 (when (file-exists? file)
294 ;; Delete extensions for proprietary text editors.
295 '("clang-format-bbedit.applescript"
296 "clang-format-sublime.py"
297 ;; Delete Emacs extensions: see their respective Emacs
298 ;; Guix package instead.
299 "clang-rename.el" "clang-format.el"))
300 ;; Install bash completion.
301 (when (file-exists? "bash-autocomplete.sh")
303 (rename-file "bash-autocomplete.sh"
304 (string-append compl-dir "/clang")))))
307 ;; Clang supports the same environment variables as GCC.
309 (list (search-path-specification
311 (files '("include")))
312 (search-path-specification
313 (variable "LIBRARY_PATH")
314 (files '("lib" "lib64")))))
316 (home-page "https://clang.llvm.org")
317 (synopsis "C language family frontend for LLVM")
319 "Clang is a compiler front end for the C, C++, Objective-C and
320 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
321 project includes the Clang front end, the Clang static analyzer, and several
322 code analysis tools.")
323 (license (if (version>=? version "9.0")
324 license:asl2.0 ;with LLVM exceptions
327 (define (make-clang-toolchain clang)
329 (name (string-append (package-name clang) "-toolchain"))
330 (version (package-version clang))
332 (build-system trivial-build-system)
334 '(#:modules ((guix build union))
336 (use-modules (ice-9 match)
340 (let ((out (assoc-ref %outputs "out")))
343 (((names . directories) ...)
344 (union-build out directories)))
346 (union-build (assoc-ref %outputs "debug")
347 (list (assoc-ref %build-inputs
349 (union-build (assoc-ref %outputs "static")
350 (list (assoc-ref %build-inputs
354 (native-search-paths (package-native-search-paths clang))
355 (search-paths (package-search-paths clang))
357 (license (package-license clang))
358 (home-page "https://clang.llvm.org")
359 (synopsis "Complete Clang toolchain for C/C++ development")
360 (description "This package provides a complete Clang toolchain for C/C++
361 development to be installed in user profiles. This includes Clang, as well as
362 libc (headers and binaries, plus debugging symbols in the @code{debug}
363 output), and Binutils.")
364 (outputs '("out" "debug" "static"))
365 (inputs `(("clang" ,clang)
366 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
367 ("binutils" ,binutils)
369 ("libc-debug" ,glibc "debug")
370 ("libc-static" ,glibc "static")))))
372 (define-public clang-runtime-10
373 (clang-runtime-from-llvm
375 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
377 (define-public clang-10
378 (clang-from-llvm llvm-10 clang-runtime-10
379 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
380 #:patches '("clang-10.0-libc-search-path.patch")))
382 (define-public clang-toolchain-10
383 (make-clang-toolchain clang-10))
385 (define-public llvm-9
392 (uri (llvm-download-uri "llvm" version))
395 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))))))
397 (define-public clang-runtime-9
398 (clang-runtime-from-llvm
400 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"))
402 (define-public clang-9
403 (clang-from-llvm llvm-9 clang-runtime-9
404 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
405 #:patches '("clang-9.0-libc-search-path.patch")))
407 (define-public clang-toolchain-9
408 (make-clang-toolchain clang-9))
410 ;; Default LLVM and Clang version.
411 (define-public llvm llvm-9)
412 (define-public clang-runtime clang-runtime-9)
413 (define-public clang clang-9)
414 (define-public clang-toolchain clang-toolchain-9)
416 (define-public llvm-8
422 (uri (llvm-download-uri "llvm" version))
425 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
426 (license license:ncsa)))
428 (define-public clang-runtime-8
429 (clang-runtime-from-llvm
431 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"))
433 (define-public clang-8
434 (clang-from-llvm llvm-8 clang-runtime-8
435 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
436 #:patches '("clang-7.0-libc-search-path.patch")))
438 (define-public clang-toolchain-8
439 (make-clang-toolchain clang-8))
441 (define-public llvm-7
447 (uri (llvm-download-uri "llvm" version))
450 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
452 (define-public clang-runtime-7
453 (clang-runtime-from-llvm
455 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"))
457 (define-public clang-7
458 (clang-from-llvm llvm-7 clang-runtime-7
459 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
460 #:patches '("clang-7.0-libc-search-path.patch")))
462 (define-public clang-toolchain-7
463 (make-clang-toolchain clang-7))
465 (define-public llvm-6
471 (uri (llvm-download-uri "llvm" version))
474 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
476 (define-public clang-runtime-6
477 (clang-runtime-from-llvm
479 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"))
481 (define-public clang-6
482 (clang-from-llvm llvm-6 clang-runtime-6
483 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
484 #:patches '("clang-6.0-libc-search-path.patch")))
486 (define-public clang-toolchain-6
487 (make-clang-toolchain clang-6))
489 (define-public llvm-3.9.1
490 (package (inherit llvm-6)
496 (uri (llvm-download-uri "llvm" version))
499 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
501 (define-public clang-runtime-3.9.1
502 (clang-runtime-from-llvm
504 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
505 '("clang-runtime-asan-build-fixes.patch"
506 "clang-runtime-esan-build-fixes.patch"
507 "clang-3.5-libsanitizer-ustat-fix.patch")))
509 (define-public clang-3.9.1
510 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
511 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
512 #:patches '("clang-3.8-libc-search-path.patch")))
514 (define-public llvm-3.8
515 (package (inherit llvm-3.9.1)
521 (uri (llvm-download-uri "llvm" version))
524 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
526 (define-public clang-runtime-3.8
527 (clang-runtime-from-llvm
529 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
530 '("clang-runtime-asan-build-fixes.patch"
531 "clang-3.5-libsanitizer-ustat-fix.patch")))
533 (define-public clang-3.8
534 (clang-from-llvm llvm-3.8 clang-runtime-3.8
535 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
536 #:patches '("clang-3.8-libc-search-path.patch")))
538 (define-public llvm-3.7
539 (package (inherit llvm-3.8)
544 (uri (llvm-download-uri "llvm" version))
547 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
549 (define-public clang-runtime-3.7
550 (clang-runtime-from-llvm
552 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
553 '("clang-runtime-asan-build-fixes.patch"
554 "clang-3.5-libsanitizer-ustat-fix.patch")))
556 (define-public clang-3.7
557 (clang-from-llvm llvm-3.7 clang-runtime-3.7
558 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
559 #:patches '("clang-3.5-libc-search-path.patch")))
561 (define-public llvm-3.6
562 (package (inherit llvm-3.7)
567 (uri (llvm-download-uri "llvm" version))
570 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
572 (define-public clang-runtime-3.6
573 (clang-runtime-from-llvm
575 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
576 '("clang-runtime-asan-build-fixes.patch")))
578 (define-public clang-3.6
579 (clang-from-llvm llvm-3.6 clang-runtime-3.6
580 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
581 #:patches '("clang-3.5-libc-search-path.patch")))
583 (define-public llvm-3.5
584 (package (inherit llvm-3.6)
589 (uri (llvm-download-uri "llvm" version))
591 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
594 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
596 (define-public clang-runtime-3.5
597 (let ((runtime (clang-runtime-from-llvm
599 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
600 '("clang-runtime-asan-build-fixes.patch"
601 "clang-3.5-libsanitizer-ustat-fix.patch"))))
605 (substitute-keyword-arguments (package-arguments runtime)
606 ((#:phases phases '%standard-phases)
607 `(modify-phases ,phases
608 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
610 (add-after 'unpack 'find-rpc-includes
611 (lambda* (#:key inputs #:allow-other-keys)
613 (string-append (assoc-ref inputs "libtirpc")
615 (or (getenv "CPATH") "")))
616 (setenv "CPLUS_INCLUDE_PATH"
617 (string-append (assoc-ref inputs "libtirpc")
619 (or (getenv "CPLUS_INCLUDE_PATH") "")))
622 `(("libtirpc" ,libtirpc)
623 ("llvm" ,llvm-3.5))))))
625 (define-public clang-3.5
626 (clang-from-llvm llvm-3.5 clang-runtime-3.5
627 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
628 #:patches '("clang-3.5-libc-search-path.patch")))
630 (define-public llvm-for-extempore
631 (package (inherit llvm-3.8)
632 (name "llvm-for-extempore")
636 (uri (string-append "http://extempore.moso.com.au/extras/"
637 "llvm-3.8.0.src-patched-for-extempore.tar.xz"))
640 "1svdl6fxn8l01ni8mpm0bd5h856ahv3h9sdzgmymr6fayckjvqzs"))))
641 ;; Extempore refuses to build on architectures other than x86_64
642 (supported-systems '("x86_64-linux"))))
644 (define-public libcxx
651 (uri (llvm-download-uri "libcxx" version))
654 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
655 (build-system cmake-build-system)
659 (home-page "https://libcxx.llvm.org")
660 (synopsis "C++ standard library")
662 "This package provides an implementation of the C++ standard library for
663 use with Clang, targeting C++11, C++14 and above.")
664 (license license:expat)))
666 ;; Libcxx files specifically used by PySide2.
667 (define-public libcxx-6
670 (version (package-version llvm-6))
673 (inherit (package-source libcxx))
674 (uri (llvm-download-uri "libcxx" version))
677 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
682 (define-public libclc
690 (url "https://github.com/llvm/llvm-project.git")
691 (commit (string-append "llvmorg-" version))))
692 (file-name (git-file-name name version))
695 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
696 (build-system cmake-build-system)
699 (list (string-append "-DLLVM_CLANG="
700 (assoc-ref %build-inputs "clang")
702 (string-append "-DPYTHON="
703 (assoc-ref %build-inputs "python")
706 (modify-phases %standard-phases
707 (add-after 'unpack 'chdir
708 (lambda _ (chdir "libclc") #t)))))
713 (home-page "https://libclc.llvm.org")
714 (synopsis "Libraries for the OpenCL programming language")
716 "This package provides an implementation of the OpenCL library
717 requirements according to version 1.1 of the OpenCL specification.")
718 ;; Apache license 2.0 with LLVM exception
719 (license license:asl2.0)))
721 (define-public libomp
727 (uri (llvm-download-uri "openmp" version))
730 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
731 (file-name (string-append "libomp-" version ".tar.xz"))))
732 (build-system cmake-build-system)
733 ;; XXX: Note this gets built with GCC because building with Clang itself
734 ;; fails (missing <atomic>, even when libcxx is added as an input.)
736 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
737 "-DOPENMP_TEST_C_COMPILER=clang"
738 "-DOPENMP_TEST_CXX_COMPILER=clang++")
739 #:test-target "check-libomp"))
744 ("pkg-config" ,pkg-config)))
746 `(("hwloc" ,hwloc "lib")))
747 (home-page "https://openmp.llvm.org")
748 (synopsis "OpenMP run-time support library")
750 "This package provides the run-time support library developed by the LLVM
751 project for the OpenMP multi-theaded programming extension. This package
752 notably provides @file{libgomp.so}, which is has a binary interface compatible
753 with that of libgomp, the GNU Offloading and Multi Processing Library.")
754 (license license:expat)))
756 (define-public python-llvmlite
758 (name "python-llvmlite")
763 (uri (pypi-uri "llvmlite" version))
766 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
767 (build-system python-build-system)
769 ;; FIXME: One test fails unable to find libm.so
770 ;; https://github.com/numba/llvmlite/issues/537
777 (inherit (package-source llvm-7))
782 (uri (string-append "https://raw.githubusercontent.com/numba/"
783 "llvmlite/v" version "/conda-recipes/"
784 "D47188-svml-VF.patch"))
787 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
790 (uri (string-append "https://raw.githubusercontent.com/numba/"
791 "llvmlite/v" version "/conda-recipes/"
792 "twine_cfg_undefined_behavior.patch"))
795 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
796 (home-page "http://llvmlite.pydata.org")
797 (synopsis "Wrapper around basic LLVM functionality")
799 "This package provides a Python binding to LLVM for use in Numba.")
800 (license license:bsd-3)))
802 (define (package-elisp-from-package source-package package-name
804 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
805 SOURCE-FILES found in SOURCE-PACKAGE."
806 (let ((orig (package-source source-package)))
808 (inherit source-package)
810 (build-system emacs-build-system)
812 (method (origin-method orig))
813 (uri (origin-uri orig))
814 (sha256 (origin-sha256 orig))
815 (file-name (string-append package-name "-"
816 (package-version source-package)))
817 (modules '((guix build utils)
821 `(let* ((source-files (quote ,source-files))
822 (basenames (map basename source-files)))
824 source-files basenames)
825 (map delete-file-recursively
828 (append '("." "..") basenames)))
831 (define-public emacs-clang-format
834 (name "emacs-clang-format")
835 (build-system emacs-build-system)
840 (modify-phases %standard-phases
841 (add-after 'unpack 'configure
842 (lambda* (#:key inputs #:allow-other-keys)
843 (let ((clang (assoc-ref inputs "clang")))
844 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
845 (emacs-substitute-variables "clang-format.el"
846 ("clang-format-executable"
847 (string-append clang "/bin/clang-format"))))
849 (synopsis "Format code using clang-format")
850 (description "This package filters code through @code{clang-format}
851 to fix its formatting. @code{clang-format} is a tool that formats
852 C/C++/Obj-C code according to a set of style options, see
853 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
855 (define-public emacs-clang-rename
858 (name "emacs-clang-rename")
859 (build-system emacs-build-system)
864 (modify-phases %standard-phases
865 (add-after 'unpack 'configure
866 (lambda* (#:key inputs #:allow-other-keys)
867 (let ((clang (assoc-ref inputs "clang")))
868 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
869 (emacs-substitute-variables "clang-rename.el"
870 ("clang-rename-binary"
871 (string-append clang "/bin/clang-rename"))))
873 (synopsis "Rename every occurrence of a symbol using clang-rename")
874 (description "This package renames every occurrence of a symbol at point
875 using @code{clang-rename}.")))