gnu: emacs-consult: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
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, 2021 Ricardo Wurmus <rekado@elephly.net>
7 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
8 ;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
11 ;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
12 ;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
13 ;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
14 ;;; Copyright © 2019 Arm Ltd <David.Truby@arm.com>
15 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
16 ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
17 ;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
18 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
19 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
20 ;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
21 ;;;
22 ;;; This file is part of GNU Guix.
23 ;;;
24 ;;; GNU Guix is free software; you can redistribute it and/or modify it
25 ;;; under the terms of the GNU General Public License as published by
26 ;;; the Free Software Foundation; either version 3 of the License, or (at
27 ;;; your option) any later version.
28 ;;;
29 ;;; GNU Guix is distributed in the hope that it will be useful, but
30 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
31 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 ;;; GNU General Public License for more details.
33 ;;;
34 ;;; You should have received a copy of the GNU General Public License
35 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
36
37 (define-module (gnu packages llvm)
38 #:use-module (guix packages)
39 #:use-module ((guix licenses) #:prefix license:)
40 #:use-module (guix download)
41 #:use-module (guix git-download)
42 #:use-module (guix memoization)
43 #:use-module (guix utils)
44 #:use-module (guix build-system gnu)
45 #:use-module (guix build-system cmake)
46 #:use-module (guix build-system emacs)
47 #:use-module (guix build-system python)
48 #:use-module (guix build-system trivial)
49 #:use-module (gnu packages)
50 #:use-module (gnu packages base)
51 #:use-module (gnu packages gcc)
52 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
53 #:use-module (gnu packages compression)
54 #:use-module (gnu packages libedit)
55 #:use-module (gnu packages libffi)
56 #:use-module (gnu packages lua)
57 #:use-module (gnu packages mpi)
58 #:use-module (gnu packages ncurses)
59 #:use-module (gnu packages ocaml)
60 #:use-module (gnu packages onc-rpc)
61 #:use-module (gnu packages perl)
62 #:use-module (gnu packages pkg-config)
63 #:use-module (gnu packages python)
64 #:use-module (gnu packages swig)
65 #:use-module (gnu packages xml)
66 #:export (system->llvm-target))
67
68 (define* (system->llvm-target #:optional
69 (system (or (and=> (%current-target-system)
70 gnu-triplet->nix-system)
71 (%current-system))))
72 "Return the LLVM target name that corresponds to SYSTEM, a system type such
73 as \"x86_64-linux\"."
74 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
75 (letrec-syntax ((matches (syntax-rules (=>)
76 ((_ (system-prefix => target) rest ...)
77 (if (string-prefix? system-prefix system)
78 target
79 (matches rest ...)))
80 ((_)
81 (error "LLVM target for system is unknown" system)))))
82 (matches ("aarch64" => "AArch64")
83 ("armhf" => "ARM")
84 ("mips64el" => "Mips")
85 ("powerpc" => "PowerPC")
86 ("riscv" => "RISCV")
87 ("x86_64" => "X86")
88 ("i686" => "X86")
89 ("i586" => "X86"))))
90
91 (define (llvm-uri component version)
92 (string-append "https://github.com/llvm/llvm-project/releases/download"
93 "/llvmorg-" version "/" component "-" version ".src.tar.xz"))
94
95 (define* (clang-runtime-from-llvm llvm hash
96 #:optional (patches '()))
97 (package
98 (name "clang-runtime")
99 (version (package-version llvm))
100 (source
101 (origin
102 (method url-fetch)
103 (uri (llvm-uri "compiler-rt" version))
104 (sha256 (base32 hash))
105 (patches (map search-patch patches))))
106 (build-system cmake-build-system)
107 (native-inputs (package-native-inputs llvm))
108 (inputs
109 `(("llvm" ,llvm)))
110 (arguments
111 `(;; Don't use '-g' during the build to save space.
112 #:build-type "Release"
113 #:tests? #f ; Tests require gtest
114 #:modules ((srfi srfi-1)
115 (ice-9 match)
116 ,@%cmake-build-system-modules)
117 #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
118 (add-after 'set-paths 'hide-glibc
119 ;; Work around https://issues.guix.info/issue/36882. We need to
120 ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
121 ;; in GCC, at the bottom of GCC include search-path is used.
122 (lambda* (#:key inputs #:allow-other-keys)
123 (let* ((filters '("libc"))
124 (input-directories
125 (filter-map (lambda (input)
126 (match input
127 ((name . dir)
128 (and (not (member name filters))
129 dir))))
130 inputs)))
131 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
132 '("include")
133 input-directories)
134 #t))))))
135 (home-page "https://compiler-rt.llvm.org")
136 (synopsis "Runtime library for Clang/LLVM")
137 (description
138 "The \"clang-runtime\" library provides the implementations of run-time
139 functions for C and C++ programs. It also provides header files that allow C
140 and C++ source code to interface with the \"sanitization\" passes of the clang
141 compiler. In LLVM this library is called \"compiler-rt\".")
142 (license (package-license llvm))
143
144 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
145 (supported-systems (delete "mips64el-linux" %supported-systems))))
146
147 (define* (clang-from-llvm llvm clang-runtime hash
148 #:key (patches '()) tools-extra)
149 "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
150 given PATCHES. When TOOLS-EXTRA is given, it must point to the
151 'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
152 'modularize', and other tools."
153 (package
154 (name "clang")
155 (version (package-version llvm))
156 (source
157 (origin
158 (method url-fetch)
159 (uri (llvm-uri (if (version>=? version "9.0.1")
160 "clang"
161 "cfe")
162 version))
163 (sha256 (base32 hash))
164 (patches (map search-patch patches))))
165 ;; Using cmake allows us to treat llvm as an external library. There
166 ;; doesn't seem to be any way to do this with clang's autotools-based
167 ;; build system.
168 (build-system cmake-build-system)
169 (outputs (if tools-extra '("out" "extra") '("out")))
170 (native-inputs (package-native-inputs llvm))
171 (inputs
172 `(("libxml2" ,libxml2)
173 ("gcc-lib" ,gcc "lib")
174 ,@(package-inputs llvm)
175 ,@(if tools-extra
176 `(("clang-tools-extra" ,tools-extra))
177 '())))
178 (propagated-inputs
179 `(("llvm" ,llvm)
180 ("clang-runtime" ,clang-runtime)))
181 (arguments
182 `(#:configure-flags
183 (list "-DCLANG_INCLUDE_TESTS=True"
184
185 ;; Find libgcc_s, crtbegin.o, and crtend.o.
186 (string-append "-DGCC_INSTALL_PREFIX="
187 (assoc-ref %build-inputs "gcc-lib"))
188
189 ;; Use a sane default include directory.
190 (string-append "-DC_INCLUDE_DIRS="
191 (assoc-ref %build-inputs "libc")
192 "/include"))
193
194 ;; Don't use '-g' during the build to save space.
195 #:build-type "Release"
196
197 #:phases (modify-phases %standard-phases
198 ,@(if tools-extra
199 `((add-after 'unpack 'add-tools-extra
200 (lambda* (#:key inputs #:allow-other-keys)
201 ;; Unpack the 'clang-tools-extra' tarball under
202 ;; tools/.
203 (let ((extra (assoc-ref inputs
204 "clang-tools-extra")))
205 (invoke "tar" "xf" extra)
206 (rename-file ,(string-append
207 "clang-tools-extra-"
208 (package-version llvm)
209 ".src")
210 "tools/extra")
211 #t)))
212 (add-after 'install 'move-extra-tools
213 (lambda* (#:key outputs #:allow-other-keys)
214 ;; Move the extra tools to the "extra" output.
215 ;; These programs alone weigh in at 296 MiB,
216 ;; because they statically-link a whole bunch of
217 ;; Clang libraries.
218 (let* ((out (assoc-ref outputs "out"))
219 (extra (assoc-ref outputs "extra"))
220 (bin (string-append out "/bin"))
221 (bin* (string-append extra "/bin"))
222 (lib (string-append out "/lib")))
223 (define (move program)
224 (rename-file (string-append bin "/" program)
225 (string-append bin* "/"
226 program)))
227
228 (mkdir-p bin*)
229 (for-each move
230 '("clang-apply-replacements"
231 "clang-change-namespace"
232 "clangd"
233 "clang-doc"
234 "clang-include-fixer"
235 "clang-move"
236 "clang-query"
237 "clang-reorder-fields"
238 "clang-tidy"
239 "find-all-symbols"
240 "modularize"
241 "pp-trace"))
242
243 ;; Remove MiBs of .a files coming from
244 ;; 'clang-tools-extra'.
245 (for-each (lambda (component)
246 (delete-file
247 (string-append lib "/libclang"
248 component ".a")))
249 '("ApplyReplacements"
250 "ChangeNamespace"
251 "Daemon"
252 "DaemonTweaks"
253 "Doc"
254 "IncludeFixer"
255 "IncludeFixerPlugin"
256 "Move"))
257 (for-each delete-file
258 (find-files
259 lib
260 "^(libfindAllSymbols|libclangTidy)"))
261 #t))))
262 '())
263 (add-after 'unpack 'add-missing-triplets
264 (lambda _
265 ;; Clang iterates through known triplets to search for
266 ;; GCC's headers, but does not recognize some of the
267 ;; triplets that are used in Guix.
268 (substitute* ,@(if (version>=? version "6.0")
269 '("lib/Driver/ToolChains/Gnu.cpp")
270 '("lib/Driver/ToolChains.cpp"))
271 (("\"aarch64-linux-gnu\"," all)
272 (string-append "\"aarch64-unknown-linux-gnu\", "
273 all))
274 (("\"arm-linux-gnueabihf\"," all)
275 (string-append all
276 " \"arm-unknown-linux-gnueabihf\","))
277 (("\"i686-pc-linux-gnu\"," all)
278 (string-append "\"i686-unknown-linux-gnu\", "
279 all)))
280 #t))
281 (add-after 'unpack 'set-glibc-file-names
282 (lambda* (#:key inputs #:allow-other-keys)
283 (let ((libc (assoc-ref inputs "libc"))
284 (compiler-rt (assoc-ref inputs "clang-runtime"))
285 (gcc (assoc-ref inputs "gcc")))
286 ,@(cond
287 ((version>=? version "6.0")
288 `(;; Link to libclang_rt files from clang-runtime.
289 (substitute* "lib/Driver/ToolChain.cpp"
290 (("getDriver\\(\\)\\.ResourceDir")
291 (string-append "\"" compiler-rt "\"")))
292
293 ;; Make "LibDir" refer to <glibc>/lib so that it
294 ;; uses the right dynamic linker file name.
295 (substitute* "lib/Driver/ToolChains/Linux.cpp"
296 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
297 (string-append declaration "\"" libc "/lib\";\n"))
298
299 ;; Make clang look for libstdc++ in the right
300 ;; location.
301 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
302 (string-append
303 "LibStdCXXIncludePathCandidates[] = { \"" gcc
304 "/include/c++\","))
305
306 ;; Make sure libc's libdir is on the search path, to
307 ;; allow crt1.o & co. to be found.
308 (("@GLIBC_LIBDIR@")
309 (string-append libc "/lib")))))
310 (else
311 `((substitute* "lib/Driver/Tools.cpp"
312 ;; Patch the 'getLinuxDynamicLinker' function so that
313 ;; it uses the right dynamic linker file name.
314 (("/lib64/ld-linux-x86-64.so.2")
315 (string-append libc
316 ,(glibc-dynamic-linker))))
317
318 ;; Link to libclang_rt files from clang-runtime.
319 ;; This substitution needed slight adjustment in 3.8.
320 ,@(if (version>=? version "3.8")
321 '((substitute* "lib/Driver/Tools.cpp"
322 (("TC\\.getDriver\\(\\)\\.ResourceDir")
323 (string-append "\"" compiler-rt "\""))))
324 '((substitute* "lib/Driver/ToolChain.cpp"
325 (("getDriver\\(\\)\\.ResourceDir")
326 (string-append "\"" compiler-rt "\"")))))
327
328 ;; Make sure libc's libdir is on the search path, to
329 ;; allow crt1.o & co. to be found.
330 (substitute* "lib/Driver/ToolChains.cpp"
331 (("@GLIBC_LIBDIR@")
332 (string-append libc "/lib"))))))
333 #t)))
334 ,@(if (version>=? version "10")
335 `((add-after 'install 'adjust-cmake-file
336 (lambda* (#:key outputs #:allow-other-keys)
337 (let ((out (assoc-ref outputs "out")))
338 ;; Clang generates a CMake file with "targets"
339 ;; for each installed library file. Downstream
340 ;; consumers of the CMake interface can use this
341 ;; to get absolute library locations. Including
342 ;; this file will needlessly assert that _all_
343 ;; libraries are available, which causes problems
344 ;; in Guix because some are removed (see the
345 ;; move-extra-tools phase). Thus, remove the
346 ;; asserts so that the main functionality works.
347 (substitute*
348 (string-append
349 out
350 "/lib/cmake/clang/ClangTargets-release.cmake")
351 (("list\\(APPEND _IMPORT_CHECK_TARGETS.*" all)
352 (string-append "# Disabled by Guix.\n#" all)))
353 #t))))
354 '())
355 ,@(if (version>? version "3.8")
356 `((add-after 'install 'symlink-cfi_blacklist
357 (lambda* (#:key inputs outputs #:allow-other-keys)
358 (let* ((out (assoc-ref outputs "out"))
359 (lib-share (string-append out "/lib/clang/"
360 ,version "/share"))
361 (compiler-rt (assoc-ref inputs "clang-runtime"))
362 ;; The location varies between Clang versions.
363 (cfi-blacklist
364 (cond
365 ((file-exists?
366 (string-append compiler-rt "/cfi_blacklist.txt"))
367 (string-append compiler-rt "/cfi_blacklist.txt"))
368 (else (string-append compiler-rt
369 "/share/cfi_blacklist.txt")))))
370 (mkdir-p lib-share)
371 ;; Symlink cfi_blacklist.txt to where Clang expects
372 ;; to find it.
373 (symlink cfi-blacklist
374 (string-append lib-share "/cfi_blacklist.txt"))
375 #t))))
376 '())
377 (add-after 'install 'install-clean-up-/share/clang
378 (lambda* (#:key outputs #:allow-other-keys)
379 (let* ((out (assoc-ref outputs "out"))
380 (compl-dir (string-append
381 out "/etc/bash_completion.d")))
382 (with-directory-excursion (string-append out
383 "/share/clang")
384 (for-each
385 (lambda (file)
386 (when (file-exists? file)
387 (delete-file file)))
388 ;; Delete extensions for proprietary text editors.
389 '("clang-format-bbedit.applescript"
390 "clang-format-sublime.py"
391 ;; Delete Emacs extensions: see their respective Emacs
392 ;; Guix package instead.
393 "clang-rename.el" "clang-format.el"))
394 ;; Install bash completion.
395 (when (file-exists? "bash-autocomplete.sh")
396 (mkdir-p compl-dir)
397 (rename-file "bash-autocomplete.sh"
398 (string-append compl-dir "/clang")))))
399 #t)))))
400
401 ;; Clang supports the same environment variables as GCC.
402 (native-search-paths
403 (list (search-path-specification
404 (variable "C_INCLUDE_PATH")
405 (files '("include")))
406 (search-path-specification
407 (variable "CPLUS_INCLUDE_PATH")
408 (files '("include/c++" "include")))
409 (search-path-specification
410 (variable "LIBRARY_PATH")
411 (files '("lib" "lib64")))))
412
413 (home-page "https://clang.llvm.org")
414 (synopsis "C language family frontend for LLVM")
415 (description
416 "Clang is a compiler front end for the C, C++, Objective-C and
417 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
418 project includes the Clang front end, the Clang static analyzer, and several
419 code analysis tools.")
420 (license (if (version>=? version "9.0")
421 license:asl2.0 ;with LLVM exceptions
422 license:ncsa))))
423
424 (define (make-clang-toolchain clang)
425 (package
426 (name (string-append (package-name clang) "-toolchain"))
427 (version (package-version clang))
428 (source #f)
429 (build-system trivial-build-system)
430 (arguments
431 '(#:modules ((guix build union))
432 #:builder (begin
433 (use-modules (ice-9 match)
434 (srfi srfi-26)
435 (guix build union))
436
437 (let ((out (assoc-ref %outputs "out")))
438
439 (match %build-inputs
440 (((names . directories) ...)
441 (union-build out directories)))
442
443 ;; Create 'cc' and 'c++' so that one can use it as a
444 ;; drop-in replacement for the default tool chain and
445 ;; have configure scripts find the compiler.
446 (symlink "clang" (string-append out "/bin/cc"))
447 (symlink "clang++" (string-append out "/bin/c++"))
448
449 (union-build (assoc-ref %outputs "debug")
450 (list (assoc-ref %build-inputs
451 "libc-debug")))
452 (union-build (assoc-ref %outputs "static")
453 (list (assoc-ref %build-inputs
454 "libc-static")))
455 #t))))
456
457 (native-search-paths
458 (append (package-native-search-paths clang)
459 (list (search-path-specification ;copied from glibc
460 (variable "GUIX_LOCPATH")
461 (files '("lib/locale"))))))
462 (search-paths (package-search-paths clang))
463
464 (license (package-license clang))
465 (home-page "https://clang.llvm.org")
466 (synopsis "Complete Clang toolchain for C/C++ development")
467 (description "This package provides a complete Clang toolchain for C/C++
468 development to be installed in user profiles. This includes Clang, as well as
469 libc (headers and binaries, plus debugging symbols in the @code{debug}
470 output), and Binutils.")
471 (outputs '("out" "debug" "static"))
472 (inputs `(("clang" ,clang)
473 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
474 ("binutils" ,binutils)
475 ("libc" ,glibc)
476 ("libc-debug" ,glibc "debug")
477 ("libc-static" ,glibc "static")))))
478
479 (define-public llvm-11
480 (package
481 (name "llvm")
482 (version "11.0.0")
483 (source
484 (origin
485 (method url-fetch)
486 (uri (llvm-uri "llvm" version))
487 (sha256
488 (base32
489 "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))
490 (build-system cmake-build-system)
491 (outputs '("out" "opt-viewer"))
492 (native-inputs
493 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
494 ("perl" ,perl)))
495 (inputs
496 `(("libffi" ,libffi)))
497 (propagated-inputs
498 `(("zlib" ,zlib))) ;to use output from llvm-config
499 (arguments
500 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
501 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
502 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
503 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
504 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
505 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
506
507 ;; Don't use '-g' during the build, to save space.
508 #:build-type "Release"
509 #:phases
510 (modify-phases %standard-phases
511 (add-before 'build 'shared-lib-workaround
512 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
513 ;; doesn't seem to get the correct rpath to be able to run
514 ;; from the build directory. Set LD_LIBRARY_PATH as a
515 ;; workaround.
516 (lambda _
517 (setenv "LD_LIBRARY_PATH"
518 (string-append (getcwd) "/lib"))
519 #t))
520 (add-after 'install 'install-opt-viewer
521 (lambda* (#:key outputs #:allow-other-keys)
522 (let* ((out (assoc-ref outputs "out"))
523 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
524 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
525 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
526 (mkdir-p opt-viewer-share-dir)
527 (rename-file (string-append out "/share/opt-viewer")
528 opt-viewer-dir))
529 #t)))))
530 (home-page "https://www.llvm.org")
531 (synopsis "Optimizing compiler infrastructure")
532 (description
533 "LLVM is a compiler infrastructure designed for compile-time, link-time,
534 runtime, and idle-time optimization of programs from arbitrary programming
535 languages. It currently supports compilation of C and C++ programs, using
536 front-ends derived from GCC 4.0.1. A new front-end for the C family of
537 languages is in development. The compiler infrastructure includes mirror sets
538 of programming tools as well as libraries with equivalent functionality.")
539 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
540
541 (define-public clang-runtime-11
542 (clang-runtime-from-llvm
543 llvm-11
544 "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip"))
545
546 (define-public clang-11
547 (clang-from-llvm llvm-11 clang-runtime-11
548 "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg"
549 #:patches '("clang-11.0-libc-search-path.patch")
550 #:tools-extra
551 (origin
552 (method url-fetch)
553 (uri (llvm-uri "clang-tools-extra"
554 (package-version llvm-11)))
555 (sha256
556 (base32
557 "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy")))))
558
559 (define-public clang-toolchain-11
560 (make-clang-toolchain clang-11))
561
562 (define-public llvm-10
563 (package
564 (inherit llvm-11)
565 (version "10.0.0")
566 (source
567 (origin
568 (method url-fetch)
569 (uri (llvm-uri "llvm" version))
570 (sha256
571 (base32
572 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))))
573
574 (define-public clang-runtime-10
575 (clang-runtime-from-llvm
576 llvm-10
577 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
578
579 (define-public clang-10
580 (clang-from-llvm llvm-10 clang-runtime-10
581 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
582 #:patches '("clang-10.0-libc-search-path.patch")
583 #:tools-extra
584 (origin
585 (method url-fetch)
586 (uri (llvm-uri "clang-tools-extra"
587 (package-version llvm-10)))
588 (sha256
589 (base32
590 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
591
592 (define-public clang-toolchain-10
593 (make-clang-toolchain clang-10))
594
595 (define-public llvm-9
596 (package
597 (inherit llvm-10)
598 (version "9.0.1")
599 (source
600 (origin
601 (method url-fetch)
602 (uri (llvm-uri "llvm" version))
603 (sha256
604 (base32
605 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
606 (patches (search-patches
607 "llvm-9-fix-bitcast-miscompilation.patch"
608 "llvm-9-fix-scev-miscompilation.patch"
609 "llvm-9-fix-lpad-miscompilation.patch"))))))
610
611 (define-public clang-runtime-9
612 (clang-runtime-from-llvm
613 llvm-9
614 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
615 '("clang-runtime-9-libsanitizer-mode-field.patch")))
616
617 (define-public clang-9
618 (clang-from-llvm llvm-9 clang-runtime-9
619 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
620 #:patches '("clang-9.0-libc-search-path.patch")))
621
622 (define-public clang-toolchain-9
623 (make-clang-toolchain clang-9))
624
625 (define-public llvm-8
626 (package
627 (inherit llvm-9)
628 (version "8.0.0")
629 (source (origin
630 (method url-fetch)
631 (uri (llvm-uri "llvm" version))
632 (sha256
633 (base32
634 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
635 (license license:ncsa)))
636
637 (define-public clang-runtime-8
638 (clang-runtime-from-llvm
639 llvm-8
640 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
641 '("clang-runtime-9-libsanitizer-mode-field.patch")))
642
643 (define-public clang-8
644 (clang-from-llvm llvm-8 clang-runtime-8
645 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
646 #:patches '("clang-7.0-libc-search-path.patch")))
647
648 (define-public clang-toolchain-8
649 (make-clang-toolchain clang-8))
650
651 (define-public llvm-7
652 (package
653 (inherit llvm-8)
654 (version "7.0.1")
655 (source (origin
656 (method url-fetch)
657 (uri (llvm-uri "llvm" version))
658 (sha256
659 (base32
660 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
661
662 (define-public clang-runtime-7
663 (clang-runtime-from-llvm
664 llvm-7
665 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
666 '("clang-runtime-9-libsanitizer-mode-field.patch")))
667
668 (define-public clang-7
669 (clang-from-llvm llvm-7 clang-runtime-7
670 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
671 #:patches '("clang-7.0-libc-search-path.patch")))
672
673 (define-public clang-toolchain-7
674 (make-clang-toolchain clang-7))
675
676 (define-public llvm-6
677 (package
678 (inherit llvm-7)
679 (version "6.0.1")
680 (source (origin
681 (method url-fetch)
682 (uri (llvm-uri "llvm" version))
683 (sha256
684 (base32
685 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
686
687 (define-public clang-runtime-6
688 (clang-runtime-from-llvm
689 llvm-6
690 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
691 '("clang-runtime-9-libsanitizer-mode-field.patch")))
692
693 (define-public clang-6
694 (clang-from-llvm llvm-6 clang-runtime-6
695 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
696 #:patches '("clang-6.0-libc-search-path.patch")))
697
698 (define-public clang-toolchain-6
699 (make-clang-toolchain clang-6))
700
701 (define-public llvm-3.9.1
702 (package (inherit llvm-6)
703 (name "llvm")
704 (version "3.9.1")
705 (source
706 (origin
707 (method url-fetch)
708 (uri (llvm-uri "llvm" version))
709 (sha256
710 (base32
711 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
712 (outputs '("out"))
713 (arguments
714 (substitute-keyword-arguments (package-arguments llvm)
715 ((#:phases phases)
716 `(modify-phases ,phases
717 (delete 'install-opt-viewer)))))))
718
719 (define-public clang-runtime-3.9.1
720 (clang-runtime-from-llvm
721 llvm-3.9.1
722 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
723 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
724 "clang-runtime-asan-build-fixes.patch"
725 "clang-runtime-esan-build-fixes.patch"
726 "clang-3.5-libsanitizer-ustat-fix.patch")))
727
728 (define-public clang-3.9.1
729 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
730 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
731 #:patches '("clang-3.8-libc-search-path.patch")))
732
733 (define-public llvm-3.8
734 (package (inherit llvm-3.9.1)
735 (name "llvm")
736 (version "3.8.1")
737 (source
738 (origin
739 (method url-fetch)
740 (uri (llvm-uri "llvm" version))
741 (sha256
742 (base32
743 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
744
745 (define-public clang-runtime-3.8
746 (clang-runtime-from-llvm
747 llvm-3.8
748 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
749 '("clang-runtime-asan-build-fixes.patch"
750 "clang-runtime-3.8-libsanitizer-mode-field.patch"
751 "clang-3.5-libsanitizer-ustat-fix.patch")))
752
753 (define-public clang-3.8
754 (clang-from-llvm llvm-3.8 clang-runtime-3.8
755 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
756 #:patches '("clang-3.8-libc-search-path.patch")))
757
758 (define-public llvm-3.7
759 (package (inherit llvm-3.8)
760 (version "3.7.1")
761 (source
762 (origin
763 (method url-fetch)
764 (uri (llvm-uri "llvm" version))
765 (sha256
766 (base32
767 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
768
769 (define-public clang-runtime-3.7
770 (clang-runtime-from-llvm
771 llvm-3.7
772 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
773 '("clang-runtime-asan-build-fixes.patch"
774 "clang-runtime-3.8-libsanitizer-mode-field.patch"
775 "clang-3.5-libsanitizer-ustat-fix.patch")))
776
777 (define-public clang-3.7
778 (clang-from-llvm llvm-3.7 clang-runtime-3.7
779 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
780 #:patches '("clang-3.5-libc-search-path.patch")))
781
782 (define-public llvm-3.6
783 (package (inherit llvm-3.7)
784 (version "3.6.2")
785 (source
786 (origin
787 (method url-fetch)
788 (uri (llvm-uri "llvm" version))
789 (sha256
790 (base32
791 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
792
793 (define-public llvm-3.5
794 (package (inherit llvm-3.6)
795 (version "3.5.2")
796 (source
797 (origin
798 (method url-fetch)
799 (uri (llvm-uri "llvm" version))
800 (patches
801 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
802 (sha256
803 (base32
804 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
805
806 (define-public clang-runtime-3.5
807 (let ((runtime (clang-runtime-from-llvm
808 llvm-3.5
809 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
810 '("clang-runtime-asan-build-fixes.patch"
811 "clang-runtime-3.5-libsanitizer-mode-field.patch"
812 "clang-3.5-libsanitizer-ustat-fix.patch"))))
813 (package/inherit runtime
814 (arguments
815 (substitute-keyword-arguments (package-arguments runtime)
816 ((#:phases phases '%standard-phases)
817 `(modify-phases ,phases
818 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
819 ;; libtirpc.
820 (add-after 'unpack 'find-rpc-includes
821 (lambda* (#:key inputs #:allow-other-keys)
822 (setenv "CPATH"
823 (string-append (assoc-ref inputs "libtirpc")
824 "/include/tirpc/:"
825 (or (getenv "CPATH") "")))
826 (setenv "CPLUS_INCLUDE_PATH"
827 (string-append (assoc-ref inputs "libtirpc")
828 "/include/tirpc/:"
829 (or (getenv "CPLUS_INCLUDE_PATH") "")))
830 #t))))))
831 (inputs
832 `(("libtirpc" ,libtirpc)
833 ("llvm" ,llvm-3.5))))))
834
835 (define-public clang-3.5
836 (clang-from-llvm llvm-3.5 clang-runtime-3.5
837 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
838 #:patches '("clang-3.5-libc-search-path.patch")))
839
840 ;; Default LLVM and Clang version.
841 (define-public llvm llvm-9)
842 (define-public clang-runtime clang-runtime-9)
843 (define-public clang clang-9)
844 (define-public clang-toolchain clang-toolchain-9)
845
846 (define-public lld
847 (package
848 (name "lld")
849 (version "11.0.0")
850 (source (origin
851 (method url-fetch)
852 (uri (llvm-uri "lld" version))
853 (sha256
854 (base32
855 "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg"))))
856 (build-system cmake-build-system)
857 (inputs
858 `(("llvm" ,llvm-11)))
859 (arguments
860 `(#:build-type "Release"
861 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
862 ;; package.
863 #:tests? #f))
864 (home-page "https://lld.llvm.org/")
865 (synopsis "Linker from the LLVM project")
866 (description "LLD is a high-performance linker, built as a set of reusable
867 components which highly leverage existing libraries in the larger LLVM Project.")
868 (license license:asl2.0))) ; With LLVM exception
869
870 (define-public lldb
871 (package
872 (name "lldb")
873 (version "11.0.0")
874 (source (origin
875 (method url-fetch)
876 (uri (llvm-uri "lldb" version))
877 (sha256
878 (base32
879 "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45"))))
880 (build-system cmake-build-system)
881 (arguments
882 `(#:configure-flags '("-DCMAKE_CXX_COMPILER=clang++")))
883 (native-inputs
884 `(("pkg-config" ,pkg-config)
885 ("swig" ,swig)))
886 (inputs
887 `(("clang" ,clang-11)
888 ("llvm" ,llvm-11)
889
890 ;; Optional (but recommended) inputs.
891 ("curses" ,ncurses)
892 ("editline" ,libedit)
893 ("liblzma" ,xz)
894 ("libxml2" ,libxml2)
895 ("lua" ,lua)
896 ("python" ,python)))
897 (home-page "https://lldb.llvm.org/")
898 (synopsis "Low level debugger")
899 (description
900 "LLDB is a high performance debugger built as a set of reusable components
901 which highly leverage existing libraries in the larger LLVM project.")
902 (license license:asl2.0))) ;with LLVM exceptions
903
904 (define-public libcxx
905 (package
906 (name "libcxx")
907 (version "9.0.1")
908 (source
909 (origin
910 (method url-fetch)
911 (uri (llvm-uri "libcxx" version))
912 (sha256
913 (base32
914 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
915 (build-system cmake-build-system)
916 (arguments
917 `(#:phases
918 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
919 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
920 (lambda* (#:key inputs #:allow-other-keys)
921 (let ((gcc (assoc-ref inputs "gcc")))
922 ;; Hide GCC's C++ headers so that they do not interfere with
923 ;; the ones we are attempting to build.
924 (setenv "CPLUS_INCLUDE_PATH"
925 (string-join (delete (string-append gcc "/include/c++")
926 (string-split (getenv "CPLUS_INCLUDE_PATH")
927 #\:))
928 ":"))
929 (format #t
930 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
931 (getenv "CPLUS_INCLUDE_PATH"))
932 #t))))))
933 (native-inputs
934 `(("clang" ,clang)
935 ("llvm" ,llvm)))
936 (home-page "https://libcxx.llvm.org")
937 (synopsis "C++ standard library")
938 (description
939 "This package provides an implementation of the C++ standard library for
940 use with Clang, targeting C++11, C++14 and above.")
941 (license license:expat)))
942
943 ;; Libcxx files specifically used by PySide2.
944 (define-public libcxx-6
945 (package
946 (inherit libcxx)
947 (version (package-version llvm-6))
948 (source
949 (origin
950 (inherit (package-source libcxx))
951 (uri (llvm-uri "libcxx" version))
952 (sha256
953 (base32
954 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
955 (native-inputs
956 `(("clang" ,clang-6)
957 ("llvm" ,llvm-6)))))
958
959 (define-public libcxxabi-6
960 (package
961 (name "libcxxabi")
962 (version "6.0.1")
963 (source
964 (origin
965 (method git-fetch)
966 (uri (git-reference
967 (url "https://github.com/llvm/llvm-project")
968 (commit (string-append "llvmorg-" version))))
969 (file-name (git-file-name name version))
970 (sha256
971 (base32
972 "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g"))))
973 (build-system cmake-build-system)
974 (arguments
975 `(#:configure-flags
976 (list (string-append "-DLIBCXXABI_LIBCXX_INCLUDES="
977 (assoc-ref %build-inputs "libcxx")
978 "/include")
979 "-DCMAKE_C_COMPILER=clang"
980 "-DCMAKE_CXX_COMPILER=clang++")
981 #:phases
982 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
983 (add-after 'unpack 'chdir
984 (lambda _ (chdir "libcxxabi")))
985 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
986 (lambda* (#:key inputs #:allow-other-keys)
987 (let ((gcc (assoc-ref inputs "gcc")))
988 ;; Hide GCC's C++ headers so that they do not interfere with
989 ;; the ones we are attempting to build.
990 (setenv "CPLUS_INCLUDE_PATH"
991 (string-join
992 (cons (string-append
993 (assoc-ref inputs "libcxx") "/include/c++/v1")
994 (delete (string-append gcc "/include/c++")
995 (string-split (getenv "CPLUS_INCLUDE_PATH")
996 #\:)))
997 ":"))
998 (format #true
999 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
1000 (getenv "CPLUS_INCLUDE_PATH")))))
1001 (add-after 'install 'install-headers
1002 (lambda* (#:key outputs #:allow-other-keys)
1003 (let ((include-dir (string-append
1004 (assoc-ref outputs "out") "/include")))
1005 (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir)
1006 (install-file "../libcxxabi/include/cxxabi.h" include-dir)))))))
1007 (native-inputs
1008 `(("clang" ,clang-6)
1009 ("llvm" ,llvm-6)
1010 ("libcxx" ,libcxx-6)))
1011 (home-page "https://libcxxabi.llvm.org")
1012 (synopsis "C++ standard library support")
1013 (description
1014 "This package provides an implementation of low level support for a
1015 standard C++ library.")
1016 (license license:expat)))
1017
1018 (define-public libcxx+libcxxabi-6
1019 (package
1020 (inherit libcxx-6)
1021 (name "libcxx+libcxxabi")
1022 (version (package-version libcxx-6))
1023 (arguments
1024 `(#:configure-flags
1025 (list "-DLIBCXX_CXX_ABI=libcxxabi"
1026 (string-append "-DLIBCXX_CXX_ABI_INCLUDE_PATHS="
1027 (assoc-ref %build-inputs "libcxxabi")
1028 "/include"))
1029 #:phases
1030 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
1031 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
1032 (lambda* (#:key inputs #:allow-other-keys)
1033 (let ((gcc (assoc-ref inputs "gcc")))
1034 ;; Hide GCC's C++ headers so that they do not interfere with
1035 ;; the ones we are attempting to build.
1036 (setenv "CPLUS_INCLUDE_PATH"
1037 (string-join
1038 (delete (string-append gcc "/include/c++")
1039 (string-split (getenv "CPLUS_INCLUDE_PATH")
1040 #\:))
1041 ":"))
1042 (format #true
1043 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
1044 (getenv "CPLUS_INCLUDE_PATH"))))))))
1045 (native-inputs
1046 `(("clang" ,clang-6)
1047 ("llvm" ,llvm-6)
1048 ("libcxxabi" ,libcxxabi-6)))))
1049
1050 (define-public libclc
1051 (package
1052 (name "libclc")
1053 (version "9.0.1")
1054 (source
1055 (origin
1056 (method git-fetch)
1057 (uri (git-reference
1058 (url "https://github.com/llvm/llvm-project")
1059 (commit (string-append "llvmorg-" version))))
1060 (file-name (git-file-name name version))
1061 (sha256
1062 (base32
1063 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
1064 (build-system cmake-build-system)
1065 (arguments
1066 `(#:configure-flags
1067 (list (string-append "-DLLVM_CLANG="
1068 (assoc-ref %build-inputs "clang")
1069 "/bin/clang")
1070 (string-append "-DPYTHON="
1071 (assoc-ref %build-inputs "python")
1072 "/bin/python3"))
1073 #:phases
1074 (modify-phases %standard-phases
1075 (add-after 'unpack 'chdir
1076 (lambda _ (chdir "libclc") #t)))))
1077 (native-inputs
1078 `(("clang" ,clang)
1079 ("llvm" ,llvm)
1080 ("python" ,python)))
1081 (home-page "https://libclc.llvm.org")
1082 (synopsis "Libraries for the OpenCL programming language")
1083 (description
1084 "This package provides an implementation of the OpenCL library
1085 requirements according to version 1.1 of the OpenCL specification.")
1086 ;; Apache license 2.0 with LLVM exception
1087 (license license:asl2.0)))
1088
1089 (define-public libomp
1090 (package
1091 (name "libomp")
1092 (version "9.0.1")
1093 (source (origin
1094 (method url-fetch)
1095 (uri (llvm-uri "openmp" version))
1096 (sha256
1097 (base32
1098 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
1099 (file-name (string-append "libomp-" version ".tar.xz"))))
1100 (build-system cmake-build-system)
1101 ;; XXX: Note this gets built with GCC because building with Clang itself
1102 ;; fails (missing <atomic>, even when libcxx is added as an input.)
1103 (arguments
1104 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
1105 "-DOPENMP_TEST_C_COMPILER=clang"
1106 "-DOPENMP_TEST_CXX_COMPILER=clang++")
1107 #:test-target "check-libomp"))
1108 (native-inputs
1109 `(("clang" ,clang)
1110 ("llvm" ,llvm)
1111 ("perl" ,perl)
1112 ("pkg-config" ,pkg-config)))
1113 (inputs
1114 `(("hwloc" ,hwloc "lib")))
1115 (home-page "https://openmp.llvm.org")
1116 (synopsis "OpenMP run-time support library")
1117 (description
1118 "This package provides the run-time support library developed by the LLVM
1119 project for the OpenMP multi-theaded programming extension. This package
1120 notably provides @file{libgomp.so}, which is has a binary interface compatible
1121 with that of libgomp, the GNU Offloading and Multi Processing Library.")
1122 (license license:expat)))
1123
1124 (define-public python-llvmlite
1125 (package
1126 (name "python-llvmlite")
1127 (version "0.34.0")
1128 (source
1129 (origin
1130 (method url-fetch)
1131 (uri (pypi-uri "llvmlite" version))
1132 (sha256
1133 (base32
1134 "0qqzs6h34002ig2jn31vk08q9hh5kn84lhmv4bljz3yakg8y0gph"))))
1135 (build-system python-build-system)
1136 (arguments
1137 `(#:phases
1138 (modify-phases %standard-phases
1139 (add-after 'unpack 'patch-reference-to-llvmlite.so
1140 ;; ctypes.CDLL uses dlopen to load libllvmlite.so, which
1141 ;; fails, so locate it by its absolute path. Change it in
1142 ;; ffi.py, not utils.py, because setup.py relies on the
1143 ;; output of get_library_name for proper installation.
1144 (lambda* (#:key outputs #:allow-other-keys)
1145 (let* ((out (assoc-ref outputs "out"))
1146 (libllvmlite.so (string-append out "/lib/python"
1147 ,(version-major+minor
1148 (package-version python))
1149 "/site-packages/llvmlite/"
1150 "binding/libllvmlite.so")))
1151 (substitute* "llvmlite/binding/ffi.py"
1152 (("_lib_name = get_library_name\\(\\)")
1153 (format #f "_lib_name = ~s" libllvmlite.so)))
1154 #t)))
1155 (add-after 'unpack 'skip-failing-tests
1156 (lambda _
1157 (substitute* "llvmlite/tests/test_binding.py"
1158 ((" def test_libm\\(self\\).*" all)
1159 (string-append " @unittest.skip('Fails on Guix')\n" all)))
1160 #t))
1161 (add-before 'build 'set-compiler/linker-flags
1162 (lambda* (#:key inputs #:allow-other-keys)
1163 (let ((llvm (assoc-ref inputs "llvm")))
1164 ;; Refer to ffi/Makefile.linux.
1165 (setenv "CPPFLAGS" "-fPIC")
1166 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
1167 llvm "/lib"))
1168 #t))))))
1169 (inputs
1170 `(("llvm"
1171 ,(let* ((patches-commit "061ab39e1d4591f3aa842458252a19ad01858167")
1172 (patch-uri (lambda (name)
1173 (string-append
1174 "https://raw.githubusercontent.com/numba/"
1175 "llvmlite/" patches-commit "/conda-recipes/"
1176 name)))
1177 (patch-origin (lambda (name hash)
1178 (origin
1179 (method url-fetch)
1180 (uri (patch-uri name))
1181 (sha256 (base32 hash)))))
1182 (arch-independent-patches
1183 (list
1184 (patch-origin
1185 "partial-testing.patch"
1186 "1cwy4jsmijd838q0bylxl77vrwrb7ksijfly5062ay32303jmj86")
1187 (patch-origin
1188 "0001-Revert-Limit-size-of-non-GlobalValue-name.patch"
1189 "0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295"))))
1190 (if (string=? "aarch64-linux" (%current-system))
1191 (package
1192 (inherit llvm-9)
1193 (source
1194 (origin
1195 (inherit (package-source llvm-9))
1196 (patches
1197 `(,(patch-origin
1198 "intel-D47188-svml-VF_LLVM9.patch"
1199 "1f9ld7wc8bn4gbvdsmk07w1rq371h42vy05rxsq9a22f57rljqbd")
1200 ,@arch-independent-patches
1201 ,@(origin-patches (package-source llvm-9)))))))
1202 (package
1203 (inherit llvm-10)
1204 (source
1205 (origin
1206 (inherit (package-source llvm-10))
1207 (patches
1208 `(,(patch-origin
1209 "intel-D47188-svml-VF.patch"
1210 "0n46qjwfl7i12bl7wp0cyxl277axfvaaz5lxx5kdlgwjcpa582dg")
1211 ,(patch-origin
1212 "expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch"
1213 "0jxhjkkwwi1cy898l2n57l73ckpw0v73lqnrifp7r1mwpsh624nv")
1214 ,@arch-independent-patches
1215 ,@(origin-patches (package-source llvm-10))))))))))))
1216 (home-page "https://llvmlite.pydata.org")
1217 (synopsis "Wrapper around basic LLVM functionality")
1218 (description
1219 "This package provides a Python binding to LLVM for use in Numba.")
1220 (license license:bsd-3)))
1221
1222 (define-public emacs-clang-format
1223 (package
1224 (inherit clang)
1225 (name "emacs-clang-format")
1226 (build-system emacs-build-system)
1227 (inputs
1228 `(("clang" ,clang)))
1229 (arguments
1230 `(#:phases
1231 (modify-phases %standard-phases
1232 (add-after 'unpack 'configure
1233 (lambda* (#:key inputs #:allow-other-keys)
1234 (let ((clang (assoc-ref inputs "clang")))
1235 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
1236 (emacs-substitute-variables "clang-format.el"
1237 ("clang-format-executable"
1238 (string-append clang "/bin/clang-format"))))
1239 #t)))))
1240 (synopsis "Format code using clang-format")
1241 (description "This package filters code through @code{clang-format}
1242 to fix its formatting. @code{clang-format} is a tool that formats
1243 C/C++/Obj-C code according to a set of style options, see
1244 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
1245
1246 (define-public emacs-clang-rename
1247 (package
1248 (inherit clang)
1249 (name "emacs-clang-rename")
1250 (build-system emacs-build-system)
1251 (inputs
1252 `(("clang" ,clang)))
1253 (arguments
1254 `(#:phases
1255 (modify-phases %standard-phases
1256 (add-after 'unpack 'configure
1257 (lambda* (#:key inputs #:allow-other-keys)
1258 (let ((clang (assoc-ref inputs "clang")))
1259 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1260 (emacs-substitute-variables "clang-rename.el"
1261 ("clang-rename-binary"
1262 (string-append clang "/bin/clang-rename"))))
1263 #t)))))
1264 (synopsis "Rename every occurrence of a symbol using clang-rename")
1265 (description "This package renames every occurrence of a symbol at point
1266 using @code{clang-rename}.")))
1267
1268 (define make-ocaml-llvm
1269 ;; Make it a memoizing procedure so its callers below don't end up defining
1270 ;; two equal-but-not-eq "ocaml-llvm" packages for the default LLVM.
1271 (mlambdaq (llvm)
1272 (package
1273 (inherit llvm)
1274 (name "ocaml-llvm")
1275 (outputs '("out"))
1276 (arguments
1277 `(#:configure-flags
1278 (list
1279 (string-append "-DLLVM_OCAML_EXTERNAL_LLVM_LIBDIR="
1280 (assoc-ref %build-inputs "llvm") "/lib")
1281 "-DBUILD_SHARED_LIBS=TRUE"
1282 "-DLLVM_OCAML_OUT_OF_TREE=TRUE"
1283 (string-append "-DLLVM_OCAML_INSTALL_PATH="
1284 (assoc-ref %outputs "out") "/lib/ocaml/site-lib"))
1285 #:phases
1286 (modify-phases %standard-phases
1287 (replace 'build
1288 (lambda _
1289 (invoke "make" "ocaml_all")))
1290 (replace 'install
1291 (lambda _
1292 (invoke "cmake" "-P" "bindings/ocaml/cmake_install.cmake"))))))
1293 (inputs
1294 `(("llvm" ,llvm)))
1295 (native-inputs
1296 `(("ocaml" ,ocaml)
1297 ("ocaml-findlib" ,ocaml-findlib)
1298 ("ocaml-ounit" ,ocaml-ounit)
1299 ("python" ,python)))
1300 (propagated-inputs
1301 `(("ocaml-integers" ,ocaml-integers)
1302 ("ocaml-ctypes" ,ocaml-ctypes)))
1303 (synopsis "OCaml bindings to LLVM")
1304 (description "This package contains the OCaml bindings distributed with
1305 LLVM."))))
1306
1307 (define-public ocaml-llvm (make-ocaml-llvm llvm))
1308 (define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9))
1309 (define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10))
1310 (define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11))