gnu: Use PACKAGE/INHERIT in more places.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
CommitLineData
3e4249ce 1;;; GNU Guix --- Functional package management for GNU
fc9dbf41 2;;; Copyright © 2014, 2016, 2018 Eric Bavier <bavier@member.fsf.org>
1204c510 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
193192ca 4;;; Copyright © 2015, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
ee077430 5;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
290b55c5 6;;; Copyright © 2016, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
584da12d 7;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
a6046f24 8;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
225c5ea0 9;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
0627f93d 10;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
7628ff1f
TG
11;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
12;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
c5296e20 13;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
5dea5cbc 14;;; Copyright © 2019 Arm Ltd <David.Truby@arm.com>
57c7bfec 15;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
66087272 16;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
b1cb8b5d 17;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
851a7caf 18;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
8a34f292 19;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
97f8b22f 20;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
3e4249ce
EB
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)
ac00973c 39 #:use-module ((guix licenses) #:prefix license:)
3e4249ce 40 #:use-module (guix download)
a2cc25ab 41 #:use-module (guix git-download)
97f8b22f 42 #:use-module (guix memoization)
3e4249ce
EB
43 #:use-module (guix utils)
44 #:use-module (guix build-system gnu)
45 #:use-module (guix build-system cmake)
7628ff1f 46 #:use-module (guix build-system emacs)
8892cac3 47 #:use-module (guix build-system python)
57c7bfec 48 #:use-module (guix build-system trivial)
3e4249ce 49 #:use-module (gnu packages)
57c7bfec 50 #:use-module (gnu packages base)
fd6ae1b9
LC
51 #:use-module (gnu packages gcc)
52 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
ee077430 53 #:use-module (gnu packages compression)
f11733bd 54 #:use-module (gnu packages libedit)
ee077430 55 #:use-module (gnu packages libffi)
f11733bd 56 #:use-module (gnu packages lua)
698e91f0 57 #:use-module (gnu packages mpi)
f11733bd 58 #:use-module (gnu packages ncurses)
97f8b22f 59 #:use-module (gnu packages ocaml)
290b55c5 60 #:use-module (gnu packages onc-rpc)
3e4249ce 61 #:use-module (gnu packages perl)
698e91f0 62 #:use-module (gnu packages pkg-config)
3e4249ce 63 #:use-module (gnu packages python)
f11733bd 64 #:use-module (gnu packages swig)
96a9a8d3
LC
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
73as \"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")
3a1c3642
JN
88 ("i686" => "X86")
89 ("i586" => "X86"))))
3e4249ce 90
abcdf6bf 91(define (llvm-uri component version)
4c4d1f69
MB
92 (string-append "https://github.com/llvm/llvm-project/releases/download"
93 "/llvmorg-" version "/" component "-" version ".src.tar.xz"))
cd16014f 94
6b26f915
LC
95(define* (clang-runtime-from-llvm llvm hash
96 #:optional (patches '()))
b81f5693
AW
97 (package
98 (name "clang-runtime")
99 (version (package-version llvm))
100 (source
101 (origin
102 (method url-fetch)
abcdf6bf 103 (uri (llvm-uri "compiler-rt" version))
6b26f915
LC
104 (sha256 (base32 hash))
105 (patches (map search-patch patches))))
b81f5693
AW
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.
3b956a33 112 #:build-type "Release"
3fd9c90c
MB
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))))))
ac97dce1 135 (home-page "https://compiler-rt.llvm.org")
b81f5693
AW
136 (synopsis "Runtime library for Clang/LLVM")
137 (description
138 "The \"clang-runtime\" library provides the implementations of run-time
139functions for C and C++ programs. It also provides header files that allow C
140and C++ source code to interface with the \"sanitization\" passes of the clang
141compiler. In LLVM this library is called \"compiler-rt\".")
00ede157 142 (license (package-license llvm))
9e6b9ea4 143
ac97dce1 144 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
9e6b9ea4 145 (supported-systems (delete "mips64el-linux" %supported-systems))))
b81f5693 146
3b956a33 147(define* (clang-from-llvm llvm clang-runtime hash
77a87ad4
LC
148 #:key (patches '()) tools-extra)
149 "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
150given 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."
3e4249ce
EB
153 (package
154 (name "clang")
155 (version (package-version llvm))
156 (source
157 (origin
158 (method url-fetch)
abcdf6bf 159 (uri (llvm-uri (if (version>=? version "9.0.1")
cd16014f
MB
160 "clang"
161 "cfe")
162 version))
fd6ae1b9 163 (sha256 (base32 hash))
3b956a33 164 (patches (map search-patch patches))))
3e4249ce
EB
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)
77a87ad4 169 (outputs (if tools-extra '("out" "extra") '("out")))
3e4249ce
EB
170 (native-inputs (package-native-inputs llvm))
171 (inputs
172 `(("libxml2" ,libxml2)
c92f1c0a 173 ("gcc-lib" ,gcc "lib")
77a87ad4
LC
174 ,@(package-inputs llvm)
175 ,@(if tools-extra
176 `(("clang-tools-extra" ,tools-extra))
177 '())))
3e4249ce 178 (propagated-inputs
b81f5693
AW
179 `(("llvm" ,llvm)
180 ("clang-runtime" ,clang-runtime)))
fd6ae1b9
LC
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
94585e88
LC
194 ;; Don't use '-g' during the build to save space.
195 #:build-type "Release"
196
fd6ae1b9 197 #:phases (modify-phases %standard-phases
77a87ad4
LC
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 '())
f5cc5de8
MB
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))
5041cc28
MB
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.
9bdbabe9
MB
289 (substitute* "lib/Driver/ToolChain.cpp"
290 (("getDriver\\(\\)\\.ResourceDir")
5041cc28 291 (string-append "\"" compiler-rt "\"")))
9bdbabe9 292
5041cc28
MB
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"))
9bdbabe9 298
5041cc28
MB
299 ;; Make clang look for libstdc++ in the right
300 ;; location.
301 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
302 (string-append
303 "LibStdCXXIncludePathCandidates[] = { \"" gcc
304 "/include/c++\","))
496bbeee 305
5041cc28
MB
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))))
9bdbabe9 317
5041cc28
MB
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 "\"")))))
9bdbabe9 327
5041cc28
MB
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)))
f91046ce
MB
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 '())
0d3063f4
MB
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 '())
1c7372a5
PN
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")
ad8a4a66
PN
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"))
1c7372a5 394 ;; Install bash completion.
ad8a4a66
PN
395 (when (file-exists? "bash-autocomplete.sh")
396 (mkdir-p compl-dir)
397 (rename-file "bash-autocomplete.sh"
398 (string-append compl-dir "/clang")))))
1c7372a5 399 #t)))))
ef11ac87
LC
400
401 ;; Clang supports the same environment variables as GCC.
402 (native-search-paths
403 (list (search-path-specification
f42bfc7a 404 (variable "C_INCLUDE_PATH")
ef11ac87 405 (files '("include")))
f42bfc7a
MB
406 (search-path-specification
407 (variable "CPLUS_INCLUDE_PATH")
408 (files '("include/c++" "include")))
ef11ac87
LC
409 (search-path-specification
410 (variable "LIBRARY_PATH")
411 (files '("lib" "lib64")))))
412
ac97dce1 413 (home-page "https://clang.llvm.org")
3e4249ce
EB
414 (synopsis "C language family frontend for LLVM")
415 (description
416 "Clang is a compiler front end for the C, C++, Objective-C and
417Objective-C++ programming languages. It uses LLVM as its back end. The Clang
418project includes the Clang front end, the Clang static analyzer, and several
419code analysis tools.")
00ede157
MB
420 (license (if (version>=? version "9.0")
421 license:asl2.0 ;with LLVM exceptions
422 license:ncsa))))
1204c510 423
57c7bfec
MO
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
b6684507
LC
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
57c7bfec
MO
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
61a5380b
LC
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"))))))
57c7bfec
MO
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++
468development to be installed in user profiles. This includes Clang, as well as
469libc (headers and binaries, plus debugging symbols in the @code{debug}
470output), 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
7f79358d 479(define-public llvm-11
f1db068a
MB
480 (package
481 (name "llvm")
225c5ea0 482 (version "11.0.0")
f1db068a
MB
483 (source
484 (origin
485 (method url-fetch)
486 (uri (llvm-uri "llvm" version))
487 (sha256
225c5ea0
TGR
488 (base32
489 "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))
f1db068a
MB
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,
534runtime, and idle-time optimization of programs from arbitrary programming
535languages. It currently supports compilation of C and C++ programs, using
536front-ends derived from GCC 4.0.1. A new front-end for the C family of
537languages is in development. The compiler infrastructure includes mirror sets
538of programming tools as well as libraries with equivalent functionality.")
539 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
540
7f79358d
MB
541(define-public clang-runtime-11
542 (clang-runtime-from-llvm
543 llvm-11
225c5ea0 544 "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip"))
7f79358d
MB
545
546(define-public clang-11
547 (clang-from-llvm llvm-11 clang-runtime-11
225c5ea0 548 "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg"
7f79358d
MB
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
225c5ea0 557 "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy")))))
7f79358d
MB
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
193192ca
LC
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"
77a87ad4
LC
582 #:patches '("clang-10.0-libc-search-path.patch")
583 #:tools-extra
584 (origin
585 (method url-fetch)
abcdf6bf 586 (uri (llvm-uri "clang-tools-extra"
77a87ad4
LC
587 (package-version llvm-10)))
588 (sha256
589 (base32
590 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
193192ca
LC
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)
abcdf6bf 602 (uri (llvm-uri "llvm" version))
193192ca
LC
603 (sha256
604 (base32
851a7caf 605 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
851a7caf 606 (patches (search-patches
9e4c24ef
MC
607 "llvm-9-fix-bitcast-miscompilation.patch"
608 "llvm-9-fix-scev-miscompilation.patch"
609 "llvm-9-fix-lpad-miscompilation.patch"))))))
193192ca
LC
610
611(define-public clang-runtime-9
b81f5693 612 (clang-runtime-from-llvm
193192ca 613 llvm-9
af88972b
MB
614 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
615 '("clang-runtime-9-libsanitizer-mode-field.patch")))
b81f5693 616
193192ca
LC
617(define-public clang-9
618 (clang-from-llvm llvm-9 clang-runtime-9
00ede157
MB
619 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
620 #:patches '("clang-9.0-libc-search-path.patch")))
d199a4c7 621
193192ca
LC
622(define-public clang-toolchain-9
623 (make-clang-toolchain clang-9))
57c7bfec 624
00ede157 625(define-public llvm-8
96d5a206 626 (package
f1db068a 627 (inherit llvm-9)
00ede157 628 (version "8.0.0")
96d5a206
DT
629 (source (origin
630 (method url-fetch)
abcdf6bf 631 (uri (llvm-uri "llvm" version))
96d5a206
DT
632 (sha256
633 (base32
00ede157
MB
634 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
635 (license license:ncsa)))
96d5a206 636
00ede157 637(define-public clang-runtime-8
96d5a206 638 (clang-runtime-from-llvm
00ede157 639 llvm-8
af88972b
MB
640 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
641 '("clang-runtime-9-libsanitizer-mode-field.patch")))
96d5a206 642
00ede157
MB
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")))
96d5a206 647
00ede157
MB
648(define-public clang-toolchain-8
649 (make-clang-toolchain clang-8))
96d5a206 650
4289d1d7
MB
651(define-public llvm-7
652 (package
00ede157 653 (inherit llvm-8)
4289d1d7
MB
654 (version "7.0.1")
655 (source (origin
656 (method url-fetch)
abcdf6bf 657 (uri (llvm-uri "llvm" version))
4289d1d7
MB
658 (sha256
659 (base32
660 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
661
662(define-public clang-runtime-7
663 (clang-runtime-from-llvm
664 llvm-7
af88972b
MB
665 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
666 '("clang-runtime-9-libsanitizer-mode-field.patch")))
4289d1d7
MB
667
668(define-public clang-7
501672d7 669 (clang-from-llvm llvm-7 clang-runtime-7
4289d1d7
MB
670 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
671 #:patches '("clang-7.0-libc-search-path.patch")))
672
57c7bfec
MO
673(define-public clang-toolchain-7
674 (make-clang-toolchain clang-7))
675
d199a4c7
MB
676(define-public llvm-6
677 (package
00ede157 678 (inherit llvm-7)
d199a4c7
MB
679 (version "6.0.1")
680 (source (origin
681 (method url-fetch)
abcdf6bf 682 (uri (llvm-uri "llvm" version))
d199a4c7
MB
683 (sha256
684 (base32
685 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
686
687(define-public clang-runtime-6
688 (clang-runtime-from-llvm
689 llvm-6
af88972b
MB
690 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
691 '("clang-runtime-9-libsanitizer-mode-field.patch")))
d199a4c7
MB
692
693(define-public clang-6
501672d7 694 (clang-from-llvm llvm-6 clang-runtime-6
148df605 695 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
9bdbabe9 696 #:patches '("clang-6.0-libc-search-path.patch")))
3b956a33 697
57c7bfec
MO
698(define-public clang-toolchain-6
699 (make-clang-toolchain clang-6))
700
584da12d 701(define-public llvm-3.9.1
00ede157 702 (package (inherit llvm-6)
584da12d
RJ
703 (name "llvm")
704 (version "3.9.1")
705 (source
706 (origin
707 (method url-fetch)
abcdf6bf 708 (uri (llvm-uri "llvm" version))
584da12d
RJ
709 (sha256
710 (base32
a6046f24
MB
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)))))))
584da12d
RJ
718
719(define-public clang-runtime-3.9.1
720 (clang-runtime-from-llvm
721 llvm-3.9.1
6b26f915 722 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
af88972b
MB
723 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
724 "clang-runtime-asan-build-fixes.patch"
0627f93d 725 "clang-runtime-esan-build-fixes.patch"
1a2d8d06 726 "clang-3.5-libsanitizer-ustat-fix.patch")))
584da12d
RJ
727
728(define-public clang-3.9.1
729 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
730 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
9bdbabe9
MB
731 #:patches '("clang-3.8-libc-search-path.patch")))
732
733(define-public llvm-3.8
a6046f24 734 (package (inherit llvm-3.9.1)
9bdbabe9
MB
735 (name "llvm")
736 (version "3.8.1")
737 (source
738 (origin
739 (method url-fetch)
abcdf6bf 740 (uri (llvm-uri "llvm" version))
9bdbabe9
MB
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"
0627f93d 749 '("clang-runtime-asan-build-fixes.patch"
af88972b 750 "clang-runtime-3.8-libsanitizer-mode-field.patch"
1a2d8d06 751 "clang-3.5-libsanitizer-ustat-fix.patch")))
9bdbabe9
MB
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")))
584da12d 757
3b956a33 758(define-public llvm-3.7
00ede157 759 (package (inherit llvm-3.8)
3b956a33
EB
760 (version "3.7.1")
761 (source
762 (origin
763 (method url-fetch)
abcdf6bf 764 (uri (llvm-uri "llvm" version))
3b956a33
EB
765 (sha256
766 (base32
767 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
768
769(define-public clang-runtime-3.7
770 (clang-runtime-from-llvm
771 llvm-3.7
6b26f915 772 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
0627f93d 773 '("clang-runtime-asan-build-fixes.patch"
af88972b 774 "clang-runtime-3.8-libsanitizer-mode-field.patch"
1a2d8d06 775 "clang-3.5-libsanitizer-ustat-fix.patch")))
3b956a33
EB
776
777(define-public clang-3.7
778 (clang-from-llvm llvm-3.7 clang-runtime-3.7
9bdbabe9
MB
779 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
780 #:patches '("clang-3.5-libc-search-path.patch")))
3ebc0905
EB
781
782(define-public llvm-3.6
00ede157 783 (package (inherit llvm-3.7)
3ebc0905
EB
784 (version "3.6.2")
785 (source
786 (origin
787 (method url-fetch)
abcdf6bf 788 (uri (llvm-uri "llvm" version))
3ebc0905
EB
789 (sha256
790 (base32
791 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
792
793(define-public clang-runtime-3.6
794 (clang-runtime-from-llvm
795 llvm-3.6
6b26f915 796 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
af88972b 797 '("clang-runtime-asan-build-fixes.patch")))
3ebc0905
EB
798
799(define-public clang-3.6
800 (clang-from-llvm llvm-3.6 clang-runtime-3.6
9bdbabe9
MB
801 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
802 #:patches '("clang-3.5-libc-search-path.patch")))
1204c510
MW
803
804(define-public llvm-3.5
00ede157 805 (package (inherit llvm-3.6)
a53c486d 806 (version "3.5.2")
1204c510
MW
807 (source
808 (origin
809 (method url-fetch)
abcdf6bf 810 (uri (llvm-uri "llvm" version))
6ba4eca2
RW
811 (patches
812 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1204c510
MW
813 (sha256
814 (base32
a53c486d 815 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1204c510 816
b81f5693 817(define-public clang-runtime-3.5
290b55c5
RW
818 (let ((runtime (clang-runtime-from-llvm
819 llvm-3.5
820 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
821 '("clang-runtime-asan-build-fixes.patch"
5f022a51 822 "clang-runtime-3.5-libsanitizer-mode-field.patch"
290b55c5 823 "clang-3.5-libsanitizer-ustat-fix.patch"))))
1a265842 824 (package/inherit runtime
290b55c5
RW
825 (arguments
826 (substitute-keyword-arguments (package-arguments runtime)
827 ((#:phases phases '%standard-phases)
828 `(modify-phases ,phases
829 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
830 ;; libtirpc.
831 (add-after 'unpack 'find-rpc-includes
832 (lambda* (#:key inputs #:allow-other-keys)
833 (setenv "CPATH"
834 (string-append (assoc-ref inputs "libtirpc")
835 "/include/tirpc/:"
836 (or (getenv "CPATH") "")))
837 (setenv "CPLUS_INCLUDE_PATH"
838 (string-append (assoc-ref inputs "libtirpc")
839 "/include/tirpc/:"
840 (or (getenv "CPLUS_INCLUDE_PATH") "")))
841 #t))))))
842 (inputs
843 `(("libtirpc" ,libtirpc)
844 ("llvm" ,llvm-3.5))))))
b81f5693 845
1204c510 846(define-public clang-3.5
b81f5693 847 (clang-from-llvm llvm-3.5 clang-runtime-3.5
9bdbabe9
MB
848 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
849 #:patches '("clang-3.5-libc-search-path.patch")))
921cb13a 850
f1db068a
MB
851;; Default LLVM and Clang version.
852(define-public llvm llvm-9)
853(define-public clang-runtime clang-runtime-9)
854(define-public clang clang-9)
855(define-public clang-toolchain clang-toolchain-9)
856
857(define-public lld
858 (package
859 (name "lld")
8937cd05 860 (version "11.0.0")
f1db068a
MB
861 (source (origin
862 (method url-fetch)
863 (uri (llvm-uri "lld" version))
864 (sha256
865 (base32
8937cd05 866 "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg"))))
f1db068a
MB
867 (build-system cmake-build-system)
868 (inputs
8937cd05 869 `(("llvm" ,llvm-11)))
f1db068a
MB
870 (arguments
871 `(#:build-type "Release"
872 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
873 ;; package.
874 #:tests? #f))
875 (home-page "https://lld.llvm.org/")
876 (synopsis "Linker from the LLVM project")
877 (description "LLD is a high-performance linker, built as a set of reusable
878components which highly leverage existing libraries in the larger LLVM Project.")
879 (license license:asl2.0))) ; With LLVM exception
880
f11733bd
MB
881(define-public lldb
882 (package
883 (name "lldb")
884 (version "11.0.0")
885 (source (origin
886 (method url-fetch)
887 (uri (llvm-uri "lldb" version))
888 (sha256
889 (base32
890 "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45"))))
891 (build-system cmake-build-system)
892 (arguments
893 `(#:configure-flags '("-DCMAKE_CXX_COMPILER=clang++")))
894 (native-inputs
895 `(("pkg-config" ,pkg-config)
896 ("swig" ,swig)))
897 (inputs
898 `(("clang" ,clang-11)
899 ("llvm" ,llvm-11)
900
901 ;; Optional (but recommended) inputs.
902 ("curses" ,ncurses)
903 ("editline" ,libedit)
904 ("liblzma" ,xz)
905 ("libxml2" ,libxml2)
906 ("lua" ,lua)
907 ("python" ,python)))
908 (home-page "https://lldb.llvm.org/")
909 (synopsis "Low level debugger")
910 (description
911 "LLDB is a high performance debugger built as a set of reusable components
912which highly leverage existing libraries in the larger LLVM project.")
913 (license license:asl2.0))) ;with LLVM exceptions
914
52f9c3b8
MB
915(define-public libcxx
916 (package
917 (name "libcxx")
00ede157 918 (version "9.0.1")
52f9c3b8
MB
919 (source
920 (origin
921 (method url-fetch)
abcdf6bf 922 (uri (llvm-uri "libcxx" version))
52f9c3b8
MB
923 (sha256
924 (base32
00ede157 925 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
52f9c3b8 926 (build-system cmake-build-system)
40a461fd
MB
927 (arguments
928 `(#:phases
929 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
930 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
931 (lambda* (#:key inputs #:allow-other-keys)
932 (let ((gcc (assoc-ref inputs "gcc")))
933 ;; Hide GCC's C++ headers so that they do not interfere with
934 ;; the ones we are attempting to build.
935 (setenv "CPLUS_INCLUDE_PATH"
936 (string-join (delete (string-append gcc "/include/c++")
937 (string-split (getenv "CPLUS_INCLUDE_PATH")
938 #\:))
939 ":"))
940 (format #t
941 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
942 (getenv "CPLUS_INCLUDE_PATH"))
943 #t))))))
52f9c3b8
MB
944 (native-inputs
945 `(("clang" ,clang)
946 ("llvm" ,llvm)))
947 (home-page "https://libcxx.llvm.org")
948 (synopsis "C++ standard library")
949 (description
950 "This package provides an implementation of the C++ standard library for
951use with Clang, targeting C++11, C++14 and above.")
952 (license license:expat)))
953
954;; Libcxx files specifically used by PySide2.
955(define-public libcxx-6
956 (package
957 (inherit libcxx)
958 (version (package-version llvm-6))
959 (source
960 (origin
961 (inherit (package-source libcxx))
abcdf6bf 962 (uri (llvm-uri "libcxx" version))
52f9c3b8
MB
963 (sha256
964 (base32
965 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
966 (native-inputs
967 `(("clang" ,clang-6)
968 ("llvm" ,llvm-6)))))
969
970(define-public libclc
971 (package
972 (name "libclc")
00ede157 973 (version "9.0.1")
52f9c3b8
MB
974 (source
975 (origin
976 (method git-fetch)
977 (uri (git-reference
b0e7b699 978 (url "https://github.com/llvm/llvm-project")
52f9c3b8
MB
979 (commit (string-append "llvmorg-" version))))
980 (file-name (git-file-name name version))
981 (sha256
982 (base32
00ede157 983 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
52f9c3b8
MB
984 (build-system cmake-build-system)
985 (arguments
986 `(#:configure-flags
987 (list (string-append "-DLLVM_CLANG="
988 (assoc-ref %build-inputs "clang")
989 "/bin/clang")
990 (string-append "-DPYTHON="
991 (assoc-ref %build-inputs "python")
992 "/bin/python3"))
993 #:phases
994 (modify-phases %standard-phases
995 (add-after 'unpack 'chdir
996 (lambda _ (chdir "libclc") #t)))))
997 (native-inputs
998 `(("clang" ,clang)
999 ("llvm" ,llvm)
1000 ("python" ,python)))
1001 (home-page "https://libclc.llvm.org")
1002 (synopsis "Libraries for the OpenCL programming language")
1003 (description
1004 "This package provides an implementation of the OpenCL library
1005requirements according to version 1.1 of the OpenCL specification.")
1006 ;; Apache license 2.0 with LLVM exception
1007 (license license:asl2.0)))
1008
1009(define-public libomp
1010 (package
1011 (name "libomp")
00ede157 1012 (version "9.0.1")
52f9c3b8
MB
1013 (source (origin
1014 (method url-fetch)
abcdf6bf 1015 (uri (llvm-uri "openmp" version))
52f9c3b8
MB
1016 (sha256
1017 (base32
00ede157 1018 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
52f9c3b8
MB
1019 (file-name (string-append "libomp-" version ".tar.xz"))))
1020 (build-system cmake-build-system)
1021 ;; XXX: Note this gets built with GCC because building with Clang itself
1022 ;; fails (missing <atomic>, even when libcxx is added as an input.)
1023 (arguments
1024 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
1025 "-DOPENMP_TEST_C_COMPILER=clang"
1026 "-DOPENMP_TEST_CXX_COMPILER=clang++")
1027 #:test-target "check-libomp"))
1028 (native-inputs
1029 `(("clang" ,clang)
1030 ("llvm" ,llvm)
1031 ("perl" ,perl)
1032 ("pkg-config" ,pkg-config)))
1033 (inputs
1034 `(("hwloc" ,hwloc "lib")))
1035 (home-page "https://openmp.llvm.org")
1036 (synopsis "OpenMP run-time support library")
1037 (description
1038 "This package provides the run-time support library developed by the LLVM
1039project for the OpenMP multi-theaded programming extension. This package
1040notably provides @file{libgomp.so}, which is has a binary interface compatible
1041with that of libgomp, the GNU Offloading and Multi Processing Library.")
1042 (license license:expat)))
1043
8892cac3
RW
1044(define-public python-llvmlite
1045 (package
1046 (name "python-llvmlite")
8a34f292 1047 (version "0.34.0")
8892cac3
RW
1048 (source
1049 (origin
1050 (method url-fetch)
1051 (uri (pypi-uri "llvmlite" version))
1052 (sha256
1053 (base32
8a34f292 1054 "0qqzs6h34002ig2jn31vk08q9hh5kn84lhmv4bljz3yakg8y0gph"))))
8892cac3 1055 (build-system python-build-system)
66087272 1056 (arguments
8a34f292
MC
1057 `(#:phases
1058 (modify-phases %standard-phases
1059 (add-after 'unpack 'patch-reference-to-llvmlite.so
1060 ;; ctypes.CDLL uses dlopen to load libllvmlite.so, which
1061 ;; fails, so locate it by its absolute path. Change it in
1062 ;; ffi.py, not utils.py, because setup.py relies on the
1063 ;; output of get_library_name for proper installation.
1064 (lambda* (#:key outputs #:allow-other-keys)
1065 (let* ((out (assoc-ref outputs "out"))
1066 (libllvmlite.so (string-append out "/lib/python"
1067 ,(version-major+minor
1068 (package-version python))
1069 "/site-packages/llvmlite/"
1070 "binding/libllvmlite.so")))
1071 (substitute* "llvmlite/binding/ffi.py"
1072 (("_lib_name = get_library_name\\(\\)")
1073 (format #f "_lib_name = ~s" libllvmlite.so)))
1074 #t)))
1075 (add-after 'unpack 'skip-failing-tests
1076 (lambda _
1077 (substitute* "llvmlite/tests/test_binding.py"
1078 ((" def test_libm\\(self\\).*" all)
1079 (string-append " @unittest.skip('Fails on Guix')\n" all)))
1080 #t))
1081 (add-before 'build 'set-compiler/linker-flags
1082 (lambda* (#:key inputs #:allow-other-keys)
1083 (let ((llvm (assoc-ref inputs "llvm")))
1084 ;; Refer to ffi/Makefile.linux.
1085 (setenv "CPPFLAGS" "-fPIC")
1086 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
1087 llvm "/lib"))
1088 #t))))))
8892cac3
RW
1089 (inputs
1090 `(("llvm"
8a34f292
MC
1091 ,(let* ((patches-commit "061ab39e1d4591f3aa842458252a19ad01858167")
1092 (patch-uri (lambda (name)
1093 (string-append
1094 "https://raw.githubusercontent.com/numba/"
1095 "llvmlite/" patches-commit "/conda-recipes/"
1096 name)))
1097 (patch-origin (lambda (name hash)
1098 (origin
1099 (method url-fetch)
1100 (uri (patch-uri name))
1101 (sha256 (base32 hash)))))
1102 (arch-independent-patches
6ee74687 1103 (list
8a34f292
MC
1104 (patch-origin
1105 "partial-testing.patch"
1106 "1cwy4jsmijd838q0bylxl77vrwrb7ksijfly5062ay32303jmj86")
1107 (patch-origin
1108 "0001-Revert-Limit-size-of-non-GlobalValue-name.patch"
1109 "0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295"))))
1110 (if (string=? "aarch64-linux" (%current-system))
1111 (package
1112 (inherit llvm-9)
1113 (source
6ee74687 1114 (origin
8a34f292
MC
1115 (inherit (package-source llvm-9))
1116 (patches
1117 `(,(patch-origin
1118 "intel-D47188-svml-VF_LLVM9.patch"
1119 "1f9ld7wc8bn4gbvdsmk07w1rq371h42vy05rxsq9a22f57rljqbd")
1120 ,@arch-independent-patches
1121 ,@(origin-patches (package-source llvm-9)))))))
1122 (package
1123 (inherit llvm-10)
1124 (source
6ee74687 1125 (origin
8a34f292
MC
1126 (inherit (package-source llvm-10))
1127 (patches
1128 `(,(patch-origin
1129 "intel-D47188-svml-VF.patch"
1130 "0n46qjwfl7i12bl7wp0cyxl277axfvaaz5lxx5kdlgwjcpa582dg")
1131 ,(patch-origin
1132 "expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch"
1133 "0jxhjkkwwi1cy898l2n57l73ckpw0v73lqnrifp7r1mwpsh624nv")
1134 ,@arch-independent-patches
1135 ,@(origin-patches (package-source llvm-10))))))))))))
1136 (home-page "https://llvmlite.pydata.org")
8892cac3
RW
1137 (synopsis "Wrapper around basic LLVM functionality")
1138 (description
1139 "This package provides a Python binding to LLVM for use in Numba.")
1140 (license license:bsd-3)))
7628ff1f
TG
1141
1142(define-public emacs-clang-format
1143 (package
1144 (inherit clang)
1145 (name "emacs-clang-format")
1146 (build-system emacs-build-system)
1147 (inputs
1148 `(("clang" ,clang)))
1149 (arguments
1150 `(#:phases
1151 (modify-phases %standard-phases
1152 (add-after 'unpack 'configure
1153 (lambda* (#:key inputs #:allow-other-keys)
1154 (let ((clang (assoc-ref inputs "clang")))
1155 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
1156 (emacs-substitute-variables "clang-format.el"
1157 ("clang-format-executable"
1158 (string-append clang "/bin/clang-format"))))
1159 #t)))))
1160 (synopsis "Format code using clang-format")
3bb22e54 1161 (description "This package filters code through @code{clang-format}
7628ff1f
TG
1162to fix its formatting. @code{clang-format} is a tool that formats
1163C/C++/Obj-C code according to a set of style options, see
3bdcc668 1164@url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
51002b72
PN
1165
1166(define-public emacs-clang-rename
1167 (package
1168 (inherit clang)
1169 (name "emacs-clang-rename")
1170 (build-system emacs-build-system)
1171 (inputs
1172 `(("clang" ,clang)))
1173 (arguments
1174 `(#:phases
1175 (modify-phases %standard-phases
1176 (add-after 'unpack 'configure
1177 (lambda* (#:key inputs #:allow-other-keys)
1178 (let ((clang (assoc-ref inputs "clang")))
1179 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1180 (emacs-substitute-variables "clang-rename.el"
1181 ("clang-rename-binary"
1182 (string-append clang "/bin/clang-rename"))))
1183 #t)))))
1184 (synopsis "Rename every occurrence of a symbol using clang-rename")
1185 (description "This package renames every occurrence of a symbol at point
1186using @code{clang-rename}.")))
97f8b22f
LC
1187
1188(define make-ocaml-llvm
1189 ;; Make it a memoizing procedure so its callers below don't end up defining
1190 ;; two equal-but-not-eq "ocaml-llvm" packages for the default LLVM.
1191 (mlambdaq (llvm)
1192 (package
1193 (inherit llvm)
1194 (name "ocaml-llvm")
1195 (outputs '("out"))
1196 (arguments
1197 `(#:configure-flags
1198 (list
1199 (string-append "-DLLVM_OCAML_EXTERNAL_LLVM_LIBDIR="
1200 (assoc-ref %build-inputs "llvm") "/lib")
1201 "-DBUILD_SHARED_LIBS=TRUE"
1202 "-DLLVM_OCAML_OUT_OF_TREE=TRUE"
1203 (string-append "-DLLVM_OCAML_INSTALL_PATH="
1204 (assoc-ref %outputs "out") "/lib/ocaml/site-lib"))
1205 #:phases
1206 (modify-phases %standard-phases
1207 (replace 'build
1208 (lambda _
1209 (invoke "make" "ocaml_all")))
1210 (replace 'install
1211 (lambda _
1212 (invoke "cmake" "-P" "bindings/ocaml/cmake_install.cmake"))))))
1213 (inputs
1214 `(("llvm" ,llvm)))
1215 (native-inputs
1216 `(("ocaml" ,ocaml)
1217 ("ocaml-findlib" ,ocaml-findlib)
1218 ("ocaml-ounit" ,ocaml-ounit)
1219 ("python" ,python)))
1220 (propagated-inputs
1221 `(("ocaml-integers" ,ocaml-integers)
1222 ("ocaml-ctypes" ,ocaml-ctypes)))
1223 (synopsis "OCaml bindings to LLVM")
1224 (description "This package contains the OCaml bindings distributed with
1225LLVM."))))
1226
1227(define-public ocaml-llvm (make-ocaml-llvm llvm))
1228(define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9))
1229(define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10))
1230(define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11))