gnu: r-biocviews: Update to 1.64.1.
[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, 2021 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–2022 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; Copyright © 2018, 2021, 2022 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 © 2021, 2022 Maxime Devos <maximedevos@telenet.be>
20 ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
21 ;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
22 ;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
23 ;;; Copyright © 2021, 2022 Guillaume Le Vaillant <glv@posteo.net>
24 ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
25 ;;; Copyright © 2022 Greg Hogan <code@greghogan.com>
26 ;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
27 ;;; Copyright © 2022 Clément Lassieur <clement@lassieur.org>
28 ;;;
29 ;;; This file is part of GNU Guix.
30 ;;;
31 ;;; GNU Guix is free software; you can redistribute it and/or modify it
32 ;;; under the terms of the GNU General Public License as published by
33 ;;; the Free Software Foundation; either version 3 of the License, or (at
34 ;;; your option) any later version.
35 ;;;
36 ;;; GNU Guix is distributed in the hope that it will be useful, but
37 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
38 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 ;;; GNU General Public License for more details.
40 ;;;
41 ;;; You should have received a copy of the GNU General Public License
42 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
43
44 (define-module (gnu packages llvm)
45 #:use-module (guix packages)
46 #:use-module ((guix licenses) #:prefix license:)
47 #:use-module (guix download)
48 #:use-module (guix gexp)
49 #:use-module (guix git-download)
50 #:use-module (guix memoization)
51 #:use-module (guix utils)
52 #:use-module (guix build-system gnu)
53 #:use-module (guix build-system cmake)
54 #:use-module (guix build-system emacs)
55 #:use-module (guix build-system python)
56 #:use-module (guix build-system trivial)
57 #:use-module (gnu packages)
58 #:use-module (gnu packages autotools)
59 #:use-module (gnu packages base)
60 #:use-module (gnu packages gcc)
61 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
62 #:use-module (gnu packages check) ;python-lit
63 #:use-module (gnu packages compression)
64 #:use-module (gnu packages julia) ;julia-patch
65 #:use-module (gnu packages libedit)
66 #:use-module (gnu packages libffi)
67 #:use-module (gnu packages lua)
68 #:use-module (gnu packages mpi)
69 #:use-module (gnu packages ncurses)
70 #:use-module (gnu packages ocaml)
71 #:use-module (gnu packages onc-rpc)
72 #:use-module (gnu packages perl)
73 #:use-module (gnu packages pkg-config)
74 #:use-module (gnu packages python)
75 #:use-module (gnu packages swig)
76 #:use-module (gnu packages xml)
77 #:use-module (srfi srfi-1)
78 #:use-module (ice-9 match)
79 #:export (make-lld-wrapper
80 system->llvm-target))
81
82 (define* (system->llvm-target #:optional
83 (system (or (and=> (%current-target-system)
84 gnu-triplet->nix-system)
85 (%current-system))))
86 "Return the LLVM target name that corresponds to SYSTEM, a system type such
87 as \"x86_64-linux\"."
88 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
89 (letrec-syntax ((matches (syntax-rules (=>)
90 ((_ (system-prefix => target) rest ...)
91 (if (string-prefix? system-prefix system)
92 target
93 (matches rest ...)))
94 ((_)
95 (error "LLVM target for system is unknown" system)))))
96 (matches ("aarch64" => "AArch64")
97 ("armhf" => "ARM")
98 ("mips64el" => "Mips")
99 ("powerpc" => "PowerPC")
100 ("riscv" => "RISCV")
101 ("x86_64" => "X86")
102 ("i686" => "X86")
103 ("i586" => "X86"))))
104
105 (define (llvm-uri component version)
106 ;; LLVM release candidate file names are formatted 'tool-A.B.C-rcN/tool-A.B.CrcN.src.tar.xz'
107 ;; so we specify the version as A.B.C-rcN and delete the hyphen when referencing the file name.
108 (string-append "https://github.com/llvm/llvm-project/releases/download"
109 "/llvmorg-" version "/" component "-" (string-delete #\- version) ".src.tar.xz"))
110
111 (define %llvm-release-monitoring-url
112 "https://github.com/llvm/llvm-project/releases")
113
114 (define* (clang-runtime-from-llvm llvm
115 #:optional
116 hash
117 (patches '()))
118 (package
119 (name "clang-runtime")
120 (version (package-version llvm))
121 (source
122 (if hash
123 (origin
124 (method url-fetch)
125 (uri (llvm-uri "compiler-rt" version))
126 (sha256 (base32 hash))
127 (patches (map search-patch patches)))
128 (llvm-monorepo (package-version llvm))))
129 (build-system cmake-build-system)
130 (native-inputs (package-native-inputs llvm))
131 (inputs
132 (list llvm))
133 (arguments
134 `(;; Don't use '-g' during the build to save space.
135 #:build-type "Release"
136 #:tests? #f ; Tests require gtest
137 #:modules ((srfi srfi-1)
138 (ice-9 match)
139 ,@%cmake-build-system-modules)
140 #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
141 (add-after 'set-paths 'hide-glibc
142 ;; Work around https://issues.guix.info/issue/36882. We need to
143 ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
144 ;; in GCC, at the bottom of GCC include search-path is used.
145 (lambda* (#:key inputs #:allow-other-keys)
146 (let* ((filters '("libc"))
147 (input-directories
148 (filter-map (lambda (input)
149 (match input
150 ((name . dir)
151 (and (not (member name filters))
152 dir))))
153 inputs)))
154 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
155 '("include")
156 input-directories)
157 #t))))))
158 (home-page "https://compiler-rt.llvm.org")
159 (synopsis "Runtime library for Clang/LLVM")
160 (description
161 "The \"clang-runtime\" library provides the implementations of run-time
162 functions for C and C++ programs. It also provides header files that allow C
163 and C++ source code to interface with the \"sanitization\" passes of the clang
164 compiler. In LLVM this library is called \"compiler-rt\".")
165 (license (package-license llvm))
166 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)
167 (upstream-name . "compiler-rt")))
168
169 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
170 (supported-systems (delete "mips64el-linux" %supported-systems))))
171
172 (define* (clang-from-llvm llvm clang-runtime
173 #:optional hash
174 #:key (patches '()) tools-extra
175 (properties
176 (append `((release-monitoring-url
177 . ,%llvm-release-monitoring-url))
178 (clang-properties (package-version llvm)))))
179 "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
180 given PATCHES. When TOOLS-EXTRA is given, it must point to the
181 'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
182 'modularize', and other tools."
183 (package
184 (name "clang")
185 (version (package-version llvm))
186 (source
187 (if hash
188 (origin
189 (method url-fetch)
190 (uri (llvm-uri (if (version>=? version "9.0.1")
191 "clang"
192 "cfe")
193 version))
194 (sha256 (base32 hash))
195 (patches (map search-patch patches)))
196 (llvm-monorepo (package-version llvm))))
197 ;; Using cmake allows us to treat llvm as an external library. There
198 ;; doesn't seem to be any way to do this with clang's autotools-based
199 ;; build system.
200 (build-system cmake-build-system)
201 (native-inputs (package-native-inputs llvm))
202 (inputs
203 `(("libxml2" ,libxml2)
204 ("gcc-lib" ,gcc "lib")
205 ,@(package-inputs llvm)
206 ,@(if tools-extra
207 `(("clang-tools-extra" ,tools-extra))
208 '())))
209 (propagated-inputs
210 (list llvm clang-runtime))
211 (arguments
212 `(#:configure-flags
213 (list "-DCLANG_INCLUDE_TESTS=True"
214
215 ;; Find libgcc_s, crtbegin.o, and crtend.o.
216 (string-append "-DGCC_INSTALL_PREFIX="
217 (assoc-ref %build-inputs "gcc-lib"))
218
219 ;; Use a sane default include directory.
220 (string-append "-DC_INCLUDE_DIRS="
221 (assoc-ref %build-inputs "libc")
222 "/include")
223 ,@(if (target-riscv64?)
224 (list "-DLIBOMP_LIBFLAGS=-latomic"
225 "-DCMAKE_SHARED_LINKER_FLAGS=-latomic")
226 `()))
227
228 ,@(if (target-riscv64?)
229 `(#:make-flags '("LDFLAGS=-latomic"))
230 '())
231
232 ;; Don't use '-g' during the build to save space.
233 #:build-type "Release"
234
235 #:phases (modify-phases %standard-phases
236 ,@(if tools-extra
237 `((add-after 'unpack 'add-tools-extra
238 (lambda* (#:key inputs #:allow-other-keys)
239 ;; Unpack the 'clang-tools-extra' tarball under
240 ;; tools/.
241 (let ((extra (assoc-ref inputs
242 "clang-tools-extra")))
243 (invoke "tar" "xf" extra)
244 (rename-file ,(string-append
245 "clang-tools-extra-"
246 (string-delete #\- (package-version llvm))
247 ".src")
248 "tools/extra")
249 ;; Build and link to shared libraries.
250 (substitute* "cmake/modules/AddClang.cmake"
251 (("BUILD_SHARED_LIBS") "True"))
252 #t))))
253 '())
254 (add-after 'unpack 'add-missing-triplets
255 (lambda _
256 ;; Clang iterates through known triplets to search for
257 ;; GCC's headers, but does not recognize some of the
258 ;; triplets that are used in Guix.
259 (substitute* ,@(if (version>=? version "6.0")
260 '("lib/Driver/ToolChains/Gnu.cpp")
261 '("lib/Driver/ToolChains.cpp"))
262 (("\"aarch64-linux-gnu\"," all)
263 (string-append "\"aarch64-unknown-linux-gnu\", "
264 all))
265 (("\"arm-linux-gnueabihf\"," all)
266 (string-append all
267 " \"arm-unknown-linux-gnueabihf\","))
268 (("\"i686-pc-linux-gnu\"," all)
269 (string-append "\"i686-unknown-linux-gnu\", "
270 all)))
271 #t))
272 (add-after 'unpack 'set-glibc-file-names
273 (lambda* (#:key inputs #:allow-other-keys)
274 (let ((libc (assoc-ref inputs "libc"))
275 (compiler-rt (assoc-ref inputs "clang-runtime"))
276 (gcc (assoc-ref inputs "gcc")))
277 ,@(cond
278 ((version>=? version "6.0")
279 `(;; Link to libclang_rt files from clang-runtime.
280 (substitute* "lib/Driver/ToolChain.cpp"
281 (("getDriver\\(\\)\\.ResourceDir")
282 (string-append "\"" compiler-rt "\"")))
283
284 ;; Make "LibDir" refer to <glibc>/lib so that it
285 ;; uses the right dynamic linker file name.
286 (substitute* "lib/Driver/ToolChains/Linux.cpp"
287 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
288 (string-append declaration "\"" libc "/lib\";\n"))
289
290 ;; Make clang look for libstdc++ in the right
291 ;; location.
292 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
293 (string-append
294 "LibStdCXXIncludePathCandidates[] = { \"" gcc
295 "/include/c++\","))
296
297 ;; Make sure libc's libdir is on the search path, to
298 ;; allow crt1.o & co. to be found.
299 (("@GLIBC_LIBDIR@")
300 (string-append libc "/lib")))))
301 (else
302 `((substitute* "lib/Driver/Tools.cpp"
303 ;; Patch the 'getLinuxDynamicLinker' function so that
304 ;; it uses the right dynamic linker file name.
305 (("/lib64/ld-linux-x86-64.so.2")
306 (string-append libc
307 ,(glibc-dynamic-linker))))
308
309 ;; Link to libclang_rt files from clang-runtime.
310 ;; This substitution needed slight adjustment in 3.8.
311 ,@(if (version>=? version "3.8")
312 '((substitute* "lib/Driver/Tools.cpp"
313 (("TC\\.getDriver\\(\\)\\.ResourceDir")
314 (string-append "\"" compiler-rt "\""))))
315 '((substitute* "lib/Driver/ToolChain.cpp"
316 (("getDriver\\(\\)\\.ResourceDir")
317 (string-append "\"" compiler-rt "\"")))))
318
319 ;; Make sure libc's libdir is on the search path, to
320 ;; allow crt1.o & co. to be found.
321 (substitute* "lib/Driver/ToolChains.cpp"
322 (("@GLIBC_LIBDIR@")
323 (string-append libc "/lib"))))))
324 #t)))
325 ,@(if (version>=? version "10")
326 `((add-after 'install 'adjust-cmake-file
327 (lambda* (#:key outputs #:allow-other-keys)
328 (let ((out (assoc-ref outputs "out")))
329 ;; Clang generates a CMake file with "targets"
330 ;; for each installed library file. Downstream
331 ;; consumers of the CMake interface can use this
332 ;; to get absolute library locations. Including
333 ;; this file will needlessly assert that _all_
334 ;; libraries are available, which causes problems
335 ;; in Guix because some are removed (see the
336 ;; move-extra-tools phase). Thus, remove the
337 ;; asserts so that the main functionality works.
338 (substitute*
339 (string-append
340 out
341 "/lib/cmake/clang/ClangTargets-release.cmake")
342 (("list\\(APPEND _IMPORT_CHECK_TARGETS.*" all)
343 (string-append "# Disabled by Guix.\n#" all)))
344 #t))))
345 '())
346 ,@(if (version>? version "3.8")
347 `((add-after 'install 'symlink-cfi_ignorelist
348 (lambda* (#:key inputs outputs #:allow-other-keys)
349 (let* ((out (assoc-ref outputs "out"))
350 (lib-share (string-append out "/lib/clang/"
351 ,version "/share"))
352 (compiler-rt (assoc-ref inputs "clang-runtime"))
353 (file-name ,(if (version>=? version "13")
354 "cfi_ignorelist.txt"
355 "cfi_blacklist.txt"))
356 ;; The location varies between Clang versions.
357 (cfi-ignorelist
358 (cond
359 ((file-exists?
360 (string-append compiler-rt "/" file-name))
361 (string-append compiler-rt "/" file-name))
362 (else (string-append compiler-rt
363 "/share/" file-name)))))
364 (mkdir-p lib-share)
365 ;; Symlink the ignorelist to where Clang expects
366 ;; to find it.
367 ;; Not all architectures support CFI.
368 ;; see: compiler-rt/cmake/config-ix.cmake
369 (when (file-exists? cfi-ignorelist)
370 (symlink cfi-ignorelist
371 (string-append lib-share "/" file-name)))))))
372 '())
373 (add-after 'install 'install-clean-up-/share/clang
374 (lambda* (#:key outputs #:allow-other-keys)
375 (let* ((out (assoc-ref outputs "out"))
376 (compl-dir (string-append
377 out "/etc/bash_completion.d")))
378 (with-directory-excursion (string-append out
379 "/share/clang")
380 (for-each
381 (lambda (file)
382 (when (file-exists? file)
383 (delete-file file)))
384 ;; Delete extensions for proprietary text editors.
385 '("clang-format-bbedit.applescript"
386 "clang-format-sublime.py"
387 ;; Delete Emacs extensions: see their respective Emacs
388 ;; Guix package instead.
389 "clang-rename.el" "clang-format.el"))
390 ;; Install bash completion.
391 (when (file-exists? "bash-autocomplete.sh")
392 (mkdir-p compl-dir)
393 (rename-file "bash-autocomplete.sh"
394 (string-append compl-dir "/clang")))))
395 #t)))))
396
397 ;; Clang supports the same environment variables as GCC.
398 (native-search-paths
399 (list (search-path-specification
400 (variable "C_INCLUDE_PATH")
401 (files '("include")))
402 (search-path-specification
403 (variable "CPLUS_INCLUDE_PATH")
404 (files '("include/c++" "include")))
405 (search-path-specification
406 (variable "OBJC_INCLUDE_PATH")
407 (files '("include")))
408 (search-path-specification
409 (variable "LIBRARY_PATH")
410 (files '("lib" "lib64")))))
411
412 (home-page "https://clang.llvm.org")
413 (synopsis "C language family frontend for LLVM")
414 (description
415 "Clang is a compiler front end for the C, C++, Objective-C and
416 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
417 project includes the Clang front end, the Clang static analyzer, and several
418 code analysis tools.")
419 (properties properties)
420 (license (if (version>=? version "9.0")
421 license:asl2.0 ;with LLVM exceptions
422 license:ncsa))))
423
424 (define (clang-properties version)
425 "Return package properties for Clang VERSION."
426 `((compiler-cpu-architectures
427 ("x86_64"
428 ;; This list was obtained by running:
429 ;;
430 ;; guix shell clang -- llc -march=x86-64 -mattr=help
431 ;;
432 ;; filtered from uninteresting entries such as "i686" and "pentium".
433 ,@(if (version>=? version "10.0") ;TODO: refine
434 '("atom"
435 "barcelona"
436 "bdver1"
437 "bdver2"
438 "bdver3"
439 "bdver4"
440 "bonnell"
441 "broadwell"
442 "btver1"
443 "btver2"
444 "c3"
445 "c3-2"
446 "cannonlake"
447 "cascadelake"
448 "cooperlake"
449 "core-avx-i"
450 "core-avx2"
451 "core2"
452 "corei7"
453 "corei7-avx"
454 "generic"
455 "geode"
456 "goldmont"
457 "goldmont-plus"
458 "haswell"
459 "icelake-client"
460 "icelake-server"
461 "ivybridge"
462 "k8"
463 "k8-sse3"
464 "knl"
465 "knm"
466 "lakemont"
467 "nehalem"
468 "nocona"
469 "opteron"
470 "opteron-sse3"
471 "sandybridge"
472 "silvermont"
473 "skx"
474 "skylake"
475 "skylake-avx512"
476 "slm"
477 "tigerlake"
478 "tremont"
479 "westmere"
480 "x86-64"
481 "x86-64-v2"
482 "x86-64-v3"
483 "x86-64-v4"
484 "znver1"
485 "znver2"
486 "znver3")
487 '())))))
488
489 (define (make-clang-toolchain clang libomp)
490 (package
491 (name (string-append (package-name clang) "-toolchain"))
492 (version (package-version clang))
493 (source #f)
494 (build-system trivial-build-system)
495 (arguments
496 '(#:modules ((guix build union))
497 #:builder (begin
498 (use-modules (ice-9 match)
499 (srfi srfi-26)
500 (guix build union))
501
502 (let ((out (assoc-ref %outputs "out")))
503
504 (match %build-inputs
505 (((names . directories) ...)
506 (union-build out directories)))
507
508 ;; Create 'cc' and 'c++' so that one can use it as a
509 ;; drop-in replacement for the default tool chain and
510 ;; have configure scripts find the compiler.
511 (symlink "clang" (string-append out "/bin/cc"))
512 (symlink "clang++" (string-append out "/bin/c++"))
513
514 (union-build (assoc-ref %outputs "debug")
515 (list (assoc-ref %build-inputs
516 "libc-debug")))
517 (union-build (assoc-ref %outputs "static")
518 (list (assoc-ref %build-inputs
519 "libc-static")))
520 #t))))
521
522 (native-search-paths
523 (append (package-native-search-paths clang)
524 (list (search-path-specification ;copied from glibc
525 (variable "GUIX_LOCPATH")
526 (files '("lib/locale"))))))
527 (search-paths (package-search-paths clang))
528
529 (license (package-license clang))
530 (properties (package-properties clang)) ;for 'compiler-cpu-architectures'
531 (home-page "https://clang.llvm.org")
532 (synopsis "Complete Clang toolchain for C/C++ development")
533 (description "This package provides a complete Clang toolchain for C/C++
534 development to be installed in user profiles. This includes Clang, as well as
535 libc (headers and binaries, plus debugging symbols in the @code{debug}
536 output), and Binutils.")
537 (outputs '("out" "debug" "static"))
538 (inputs `(("clang" ,clang)
539 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
540 ("binutils" ,binutils)
541 ("libomp" ,libomp) ;used when linking with '-fopenmp'
542 ("libc" ,glibc)
543 ("libc-debug" ,glibc "debug")
544 ("libc-static" ,glibc "static")))))
545
546 (define %llvm-monorepo-hashes
547 '(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")))
548
549 (define %llvm-patches
550 '(("14.0.6" . ("clang-14.0-libc-search-path.patch"))))
551
552 (define (llvm-monorepo version)
553 (origin
554 (method git-fetch)
555 (uri (git-reference
556 (url "https://github.com/llvm/llvm-project")
557 (commit (string-append "llvmorg-" version))))
558 (file-name (git-file-name "llvm-project" version))
559 (sha256 (base32 (assoc-ref %llvm-monorepo-hashes version)))
560 (patches (map search-patch (assoc-ref %llvm-patches version)))))
561
562 (define-public llvm-14
563 (package
564 (name "llvm")
565 (version "14.0.6")
566 (source (llvm-monorepo version))
567 (build-system cmake-build-system)
568 (outputs '("out" "opt-viewer"))
569 (native-inputs
570 `(("python" ,python-wrapper)
571 ("perl" ,perl)))
572 (inputs
573 (list libffi))
574 (propagated-inputs
575 (list zlib)) ;to use output from llvm-config
576 (arguments
577 (list
578 #:configure-flags
579 #~(list
580 ;; These options are required for cross-compiling LLVM according
581 ;; to <https://llvm.org/docs/HowToCrossCompileLLVM.html>.
582 #$@(if (%current-target-system)
583 #~((string-append "-DLLVM_TABLEGEN="
584 #+(file-append this-package
585 "/bin/llvm-tblgen"))
586 #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
587 (%current-target-system))
588 #$(string-append "-DLLVM_TARGET_ARCH="
589 (system->llvm-target))
590 #$(string-append "-DLLVM_TARGETS_TO_BUILD="
591 (system->llvm-target)))
592 '())
593 "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
594 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
595 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
596 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
597 "-DLLVM_REQUIRES_RTTI=1" ;for some third-party utilities
598 "-DLLVM_INSTALL_UTILS=ON") ;needed for rustc
599 ;; Don't use '-g' during the build, to save space.
600 #:build-type "Release"
601 #:phases
602 #~(modify-phases %standard-phases
603 (add-after 'unpack 'change-directory
604 (lambda _
605 (chdir "llvm")))
606 (add-after 'install 'install-opt-viewer
607 (lambda* (#:key outputs #:allow-other-keys)
608 (let* ((out (assoc-ref outputs "out"))
609 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
610 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
611 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
612 (mkdir-p opt-viewer-share-dir)
613 (rename-file (string-append out "/share/opt-viewer")
614 opt-viewer-dir)))))))
615 (home-page "https://www.llvm.org")
616 (synopsis "Optimizing compiler infrastructure")
617 (description
618 "LLVM is a compiler infrastructure designed for compile-time, link-time,
619 runtime, and idle-time optimization of programs from arbitrary programming
620 languages. It currently supports compilation of C and C++ programs, using
621 front-ends derived from GCC 4.0.1. A new front-end for the C family of
622 languages is in development. The compiler infrastructure includes mirror sets
623 of programming tools as well as libraries with equivalent functionality.")
624 (license license:asl2.0)
625 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
626
627 (define-public clang-runtime-14
628 (let ((template (clang-runtime-from-llvm llvm-14)))
629 (package
630 (inherit template)
631 (arguments
632 (substitute-keyword-arguments (package-arguments template)
633 ((#:phases phases '(@ (guix build cmake-build-system) %standard-phases))
634 #~(modify-phases #$phases
635 (add-after 'unpack 'change-directory
636 (lambda _
637 (chdir "compiler-rt")))))))
638 (native-inputs
639 `(;; FIXME: libfuzzer fails to build with GCC 10.
640 ("gcc" ,gcc-11)
641 ,@(package-native-inputs template))))))
642
643 (define-public clang-14
644 (let ((template
645 (clang-from-llvm llvm-14 clang-runtime-14
646 #:tools-extra
647 (origin
648 (method url-fetch)
649 (uri (llvm-uri "clang-tools-extra"
650 (package-version llvm-14)))
651 (sha256
652 (base32
653 "0rhq4wkmvr369nkk059skzzw7jx6qhzqhmiwmqg4sp66avzviwvw"))))))
654 (package
655 (inherit template)
656 (arguments
657 (substitute-keyword-arguments (package-arguments template)
658 ((#:phases phases '(@ (guix build cmake-build-system) %standard-phases))
659 #~(modify-phases #$phases
660 (add-after 'unpack 'change-directory
661 (lambda _
662 (chdir "clang"))))))))))
663
664 (define-public libomp-14
665 (package
666 (name "libomp")
667 (version (package-version llvm-14))
668 (source (origin
669 (method url-fetch)
670 (uri (llvm-uri "openmp" version))
671 (sha256
672 (base32
673 "07zby3gwy5c8jssabrhjk3nsxlwipnm6sk4dsvck1l5d0br1ywsg"))
674 (file-name (string-append "libomp-" version ".tar.xz"))))
675 (build-system cmake-build-system)
676 ;; XXX: Note this gets built with GCC because building with Clang itself
677 ;; fails (missing <atomic>, even when libcxx is added as an input.)
678 (arguments
679 (list
680 #:configure-flags #~(list "-DLIBOMP_USE_HWLOC=ON"
681 "-DOPENMP_TEST_C_COMPILER=clang"
682 "-DOPENMP_TEST_CXX_COMPILER=clang++")
683 #:test-target "check-libomp"
684 #:phases
685 #~(modify-phases %standard-phases
686 (add-after 'unpack 'chdir-to-source-and-install-license
687 (lambda _
688 (chdir #$(string-append "../openmp-" version ".src"))
689 (install-file "LICENSE.TXT"
690 (string-append #$output "/share/doc")))))))
691 (native-inputs
692 (list clang-14 llvm-14 perl pkg-config python))
693 (inputs
694 (list `(,hwloc "lib")))
695 (home-page "https://openmp.llvm.org")
696 (synopsis "OpenMP run-time support library")
697 (description
698 "This package provides the run-time support library developed by the LLVM
699 project for the OpenMP multi-theaded programming extension. This package
700 notably provides @file{libgomp.so}, which is has a binary interface compatible
701 with that of libgomp, the GNU Offloading and Multi Processing Library.")
702 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)
703 (upstream-name . "openmp")))
704 (license license:expat)))
705
706 (define-public clang-toolchain-14
707 (make-clang-toolchain clang-14 libomp-14))
708
709 (define-public llvm-13
710 (package
711 (inherit llvm-14)
712 (version "13.0.1")
713 (source
714 (origin
715 (method url-fetch)
716 (uri (llvm-uri "llvm" version))
717 (sha256
718 (base32
719 "0d681xiixmx9inwvz14vi3xsznrcryk06a8rvk9cljiq5kc80szc"))))
720 (arguments
721 (substitute-keyword-arguments (package-arguments llvm-14)
722 ((#:phases phases '%standard-phases)
723 #~(modify-phases #$phases
724 (delete 'change-directory)))))
725 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
726
727 (define-public clang-runtime-13
728 (clang-runtime-from-llvm
729 llvm-13
730 "1z2xr9nn4mgc3hn9ark2k5y4wznpk47xppkp63bcbagr6589acvv"))
731
732 (define-public clang-13
733 (clang-from-llvm llvm-13 clang-runtime-13
734 "1j8pr5kk8iqyb4jds3yl7c6x672617h4ngkpl4575j7mk4nrwykq"
735 #:patches '("clang-13.0-libc-search-path.patch")
736 #:tools-extra
737 (origin
738 (method url-fetch)
739 (uri (llvm-uri "clang-tools-extra"
740 (package-version llvm-13)))
741 (sha256
742 (base32
743 "1l4jjdqfl9hrh0fwzv27hc263zc6x61h09vs4ni3yla8i1cwhayc")))))
744
745 (define-public libomp-13
746 (package
747 (inherit libomp-14)
748 (version (package-version llvm-13))
749 (source (origin
750 (method url-fetch)
751 (uri (llvm-uri "openmp" version))
752 (sha256
753 (base32
754 "0kvbr4j6ldpssiv7chgqra5y77n7jwbyxlwcl7z32v31f49jcybb"))
755 (file-name (string-append "libomp-" version ".tar.xz"))))
756 (arguments
757 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
758 "-DOPENMP_TEST_C_COMPILER=clang"
759 "-DOPENMP_TEST_CXX_COMPILER=clang++"
760
761 ;; Work around faulty target detection, fixed in 14:
762 ;; https://github.com/llvm/llvm-project/issues/52910
763 "-DLIBOMPTARGET_BUILD_AMDGCN_BCLIB=OFF")
764 #:test-target "check-libomp"))
765 (native-inputs
766 (modify-inputs (package-native-inputs libomp-14)
767 (replace "clang" clang-13)
768 (replace "llvm" llvm-13)))))
769
770 (define-public clang-toolchain-13
771 (make-clang-toolchain clang-13 libomp-13))
772
773 (define-public llvm-12
774 (package
775 (inherit llvm-13)
776 (version "12.0.1")
777 (source
778 (origin
779 (method url-fetch)
780 (uri (llvm-uri "llvm" version))
781 (sha256
782 (base32
783 "1pzx9zrmd7r3481sbhwvkms68fwhffpp4mmz45dgrkjpyl2q96kx"))))
784 (arguments
785 ;; TODO(core-updates): Unconditionally use quasiquote
786 `(#:configure-flags
787 ,#~(#$(if (%current-target-system)
788 #~quasiquote
789 #~quote)
790 ;; These options are required for cross-compiling LLVM according to
791 ;; https://llvm.org/docs/HowToCrossCompileLLVM.html.
792 (#$@(if (%current-target-system)
793 #~(,(string-append "-DLLVM_TABLEGEN="
794 #+(file-append this-package
795 "/bin/llvm-tblgen"))
796 #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
797 (%current-target-system))
798 #$(string-append "-DLLVM_TARGET_ARCH="
799 (system->llvm-target))
800 #$(string-append "-DLLVM_TARGETS_TO_BUILD="
801 (system->llvm-target)))
802 #~())
803 "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
804 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
805 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
806 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
807 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
808 "-DLLVM_INSTALL_UTILS=ON")) ; Needed for rustc.
809 ;; Don't use '-g' during the build, to save space.
810 #:build-type "Release"
811 #:phases
812 (modify-phases %standard-phases
813 ,@(if (assoc "config" (package-native-inputs this-package))
814 `((add-after 'unpack 'update-config
815 (lambda* (#:key inputs native-inputs #:allow-other-keys)
816 (let ((config.guess (search-input-file
817 (or inputs native-inputs)
818 "/bin/config.guess")))
819 (copy-file config.guess "cmake/config.guess")))))
820 '())
821 (add-before 'build 'shared-lib-workaround
822 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
823 ;; doesn't seem to get the correct rpath to be able to run
824 ;; from the build directory. Set LD_LIBRARY_PATH as a
825 ;; workaround.
826 (lambda _
827 (setenv "LD_LIBRARY_PATH"
828 (string-append (getcwd) "/lib"))
829 #t))
830 (add-after 'install 'install-opt-viewer
831 (lambda* (#:key outputs #:allow-other-keys)
832 (let* ((out (assoc-ref outputs "out"))
833 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
834 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
835 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
836 (mkdir-p opt-viewer-share-dir)
837 (rename-file (string-append out "/share/opt-viewer")
838 opt-viewer-dir))
839 #t)))))))
840
841 (define-public clang-runtime-12
842 (clang-runtime-from-llvm
843 llvm-12
844 "1950rg294izdwkaasi7yjrmadc9mzdd5paf0q63jjcq2m3rdbj5l"))
845
846 (define-public clang-12
847 (clang-from-llvm llvm-12 clang-runtime-12
848 "0px4gl27az6cdz6adds89qzdwb1cqpjsfvrldbz9qvpmphrj34bf"
849 #:patches '("clang-12.0-libc-search-path.patch")
850 #:tools-extra
851 (origin
852 (method url-fetch)
853 (uri (llvm-uri "clang-tools-extra"
854 (package-version llvm-12)))
855 (sha256
856 (base32
857 "1r9a4fdz9ci58b5z2inwvm4z4cdp6scrivnaw05dggkxz7yrwrb5")))))
858
859 (define-public libomp-12
860 (package
861 (inherit libomp-13)
862 (version (package-version llvm-12))
863 (source (origin
864 (method url-fetch)
865 (uri (llvm-uri "openmp" version))
866 (sha256
867 (base32
868 "14dh0r6h2xh747ffgnsl4z08h0ri04azi9vf79cbz7ma1r27kzk0"))
869 (file-name (string-append "libomp-" version ".tar.xz"))))
870 (arguments
871 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
872 "-DOPENMP_TEST_C_COMPILER=clang"
873 "-DOPENMP_TEST_CXX_COMPILER=clang++")
874 #:test-target "check-libomp"))
875 (native-inputs
876 (modify-inputs (package-native-inputs libomp-13)
877 (replace "clang" clang-12)
878 (replace "llvm" llvm-12)))))
879
880 (define-public clang-toolchain-12
881 (make-clang-toolchain clang-12 libomp-12))
882
883 (define-public llvm-11
884 (package
885 (inherit llvm-12)
886 (version "11.0.0")
887 (source
888 (origin
889 (method url-fetch)
890 (uri (llvm-uri "llvm" version))
891 (sha256
892 (base32
893 "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))))
894
895 (define-public clang-runtime-11
896 (clang-runtime-from-llvm
897 llvm-11
898 "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip"))
899
900 (define-public clang-11
901 (clang-from-llvm llvm-11 clang-runtime-11
902 "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg"
903 #:patches '("clang-11.0-libc-search-path.patch")
904 #:tools-extra
905 (origin
906 (method url-fetch)
907 (uri (llvm-uri "clang-tools-extra"
908 (package-version llvm-11)))
909 (sha256
910 (base32
911 "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy")))))
912
913 (define-public libomp-11
914 (package
915 (inherit libomp-12)
916 (version (package-version llvm-11))
917 (source (origin
918 (method url-fetch)
919 (uri (llvm-uri "openmp" version))
920 (sha256
921 (base32
922 "0k389d0g9zlfyzh1kpb3i5jdawzpn0hrdxzbjinpvdv7rbw4sw1d"))
923 (file-name (string-append "libomp-" version ".tar.xz"))))
924 (native-inputs
925 (modify-inputs (package-native-inputs libomp-12)
926 (replace "clang" clang-11)
927 (replace "llvm" llvm-11)))))
928
929 (define-public clang-toolchain-11
930 (make-clang-toolchain clang-11 libomp-11))
931
932 (define-public llvm-10
933 (package
934 (inherit llvm-11)
935 (version "10.0.1")
936 (source
937 (origin
938 (method url-fetch)
939 (uri (llvm-uri "llvm" version))
940 (sha256
941 (base32
942 "1wydhbp9kyjp5y0rc627imxgkgqiv3dfirbqil9dgpnbaw5y7n65"))))
943 (native-inputs
944 `(("python" ,python-wrapper)
945 ("perl" ,perl)
946 ;; In llvm-11 riscv64 support was added manually to config.guess.
947 ,@(if (target-riscv64?)
948 `(("config" ,config))
949 '())))))
950
951 (define-public clang-runtime-10
952 (clang-runtime-from-llvm
953 llvm-10
954 "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr"))
955
956 (define-public clang-10
957 (clang-from-llvm llvm-10 clang-runtime-10
958 "091bvcny2lh32zy8f3m9viayyhb2zannrndni7325rl85cwgr6pr"
959 #:patches '("clang-10.0-libc-search-path.patch")
960 #:tools-extra
961 (origin
962 (method url-fetch)
963 (uri (llvm-uri "clang-tools-extra"
964 (package-version llvm-10)))
965 (sha256
966 (base32
967 "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh")))))
968
969 (define-public libomp-10
970 (package
971 (inherit libomp-11)
972 (version (package-version llvm-10))
973 (source (origin
974 (method url-fetch)
975 (uri (llvm-uri "openmp" version))
976 (sha256
977 (base32
978 "0i4bn84lkpm5w3qkpvwm5z6jdj8fynp7d3bcasa1xyq4is6757yi"))
979 (file-name (string-append "libomp-" version ".tar.xz"))))
980 (native-inputs
981 (modify-inputs (package-native-inputs libomp-11)
982 (replace "clang" clang-10)
983 (replace "llvm" llvm-10)))))
984
985 (define-public clang-toolchain-10
986 (make-clang-toolchain clang-10 libomp-10))
987
988 (define-public llvm-9
989 (package
990 (inherit llvm-10)
991 (version "9.0.1")
992 (source
993 (origin
994 (method url-fetch)
995 (uri (llvm-uri "llvm" version))
996 (sha256
997 (base32
998 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
999 (patches (search-patches
1000 "llvm-9-fix-bitcast-miscompilation.patch"
1001 "llvm-9-fix-scev-miscompilation.patch"
1002 "llvm-9-fix-lpad-miscompilation.patch"))))
1003 (arguments
1004 (if (target-riscv64?)
1005 (substitute-keyword-arguments (package-arguments llvm-10)
1006 ((#:phases phases)
1007 `(modify-phases ,phases
1008 (add-after 'unpack 'patch-dsymutil-link
1009 (lambda _
1010 (substitute* "tools/dsymutil/CMakeLists.txt"
1011 (("endif\\(APPLE\\)")
1012 (string-append
1013 "endif(APPLE)\n\n"
1014 "if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES \"riscv64\")\n"
1015 " target_link_libraries(dsymutil PRIVATE atomic)\n"
1016 "endif()"))))))))
1017 (package-arguments llvm-10)))))
1018
1019 (define-public clang-runtime-9
1020 (clang-runtime-from-llvm
1021 llvm-9
1022 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
1023 '("clang-runtime-9-libsanitizer-mode-field.patch")))
1024
1025 (define-public clang-9
1026 (clang-from-llvm llvm-9 clang-runtime-9
1027 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
1028 #:patches '("clang-9.0-libc-search-path.patch")))
1029
1030 (define-public libomp-9
1031 (package
1032 (inherit libomp-10)
1033 (version (package-version llvm-9))
1034 (source (origin
1035 (method url-fetch)
1036 (uri (llvm-uri "openmp" version))
1037 (sha256
1038 (base32
1039 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
1040 (file-name (string-append "libomp-" version ".tar.xz"))))
1041 (native-inputs
1042 (modify-inputs (package-native-inputs libomp-10)
1043 (replace "clang" clang-9)
1044 (replace "llvm" llvm-9)))))
1045
1046 (define-public clang-toolchain-9
1047 (make-clang-toolchain clang-9 libomp-9))
1048
1049 (define-public llvm-8
1050 (package
1051 (inherit llvm-9)
1052 (version "8.0.1")
1053 (source (origin
1054 (method url-fetch)
1055 (uri (llvm-uri "llvm" version))
1056 (sha256
1057 (base32
1058 "1rvm5gqp5v8hfn17kqws3zhk94w4kxndal12bqa0y57p09nply24"))
1059 (patches (search-patches "llvm-8-fix-build-with-gcc-10.patch"))))
1060 (license license:ncsa)))
1061
1062 (define-public clang-runtime-8
1063 (clang-runtime-from-llvm
1064 llvm-8
1065 "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi"
1066 '("clang-runtime-9-libsanitizer-mode-field.patch")))
1067
1068 (define-public clang-8
1069 (clang-from-llvm llvm-8 clang-runtime-8
1070 "0ihnbdl058gvl2wdy45p5am55bq8ifx8m9mhcsgj9ax8yxlzvvvh"
1071 #:patches '("clang-8.0-libc-search-path.patch")))
1072
1073 (define-public libomp-8
1074 (package
1075 (inherit libomp-9)
1076 (version (package-version llvm-8))
1077 (source (origin
1078 (method url-fetch)
1079 (uri (llvm-uri "openmp" version))
1080 (sha256
1081 (base32
1082 "0b3jlxhqbpyd1nqkpxjfggm5d9va5qpyf7d4i5y7n4a1mlydv19y"))
1083 (file-name (string-append "libomp-" version ".tar.xz"))))
1084 (native-inputs
1085 (modify-inputs (package-native-inputs libomp-9)
1086 (replace "clang" clang-8)
1087 (replace "llvm" llvm-8)))
1088 (license license:ncsa)))
1089
1090 (define-public clang-toolchain-8
1091 (make-clang-toolchain clang-8 libomp-8))
1092
1093 (define-public llvm-7
1094 (package
1095 (inherit llvm-8)
1096 (version "7.1.0")
1097 (source (origin
1098 (method url-fetch)
1099 (uri (llvm-uri "llvm" version))
1100 (sha256
1101 (base32
1102 "0r1p5didv4rkgxyvbkyz671xddg6i3dxvbpsi1xxipkla0l9pk0v"))))))
1103
1104 (define-public clang-runtime-7
1105 (clang-runtime-from-llvm
1106 llvm-7
1107 "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5"
1108 '("clang-runtime-9-libsanitizer-mode-field.patch")))
1109
1110 (define-public clang-7
1111 (clang-from-llvm llvm-7 clang-runtime-7
1112 "0vc4i87qwxnw9lci4ayws9spakg0z6w5w670snj9f8g5m9rc8zg9"
1113 #:patches '("clang-7.0-libc-search-path.patch")))
1114
1115 (define-public libomp-7
1116 (package
1117 (inherit libomp-8)
1118 (version (package-version llvm-7))
1119 (source (origin
1120 (method url-fetch)
1121 (uri (llvm-uri "openmp" version))
1122 (sha256
1123 (base32
1124 "1dg53wzsci2kra8lh1y0chh60h2l8h1by93br5spzvzlxshkmrqy"))
1125 (file-name (string-append "libomp-" version ".tar.xz"))))
1126 (native-inputs
1127 (modify-inputs (package-native-inputs libomp-8)
1128 (replace "clang" clang-7)
1129 (replace "llvm" llvm-7)))))
1130
1131 (define-public clang-toolchain-7
1132 (make-clang-toolchain clang-7 libomp-7))
1133
1134 (define-public llvm-6
1135 (package
1136 (inherit llvm-7)
1137 (version "6.0.1")
1138 (source (origin
1139 (method url-fetch)
1140 (uri (llvm-uri "llvm" version))
1141 (sha256
1142 (base32
1143 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
1144
1145 (define-public clang-runtime-6
1146 (clang-runtime-from-llvm
1147 llvm-6
1148 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
1149 '("clang-runtime-9-libsanitizer-mode-field.patch")))
1150
1151 (define-public clang-6
1152 (clang-from-llvm llvm-6 clang-runtime-6
1153 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
1154 #:patches '("clang-6.0-libc-search-path.patch")))
1155
1156 (define-public libomp-6
1157 (package
1158 (inherit libomp-7)
1159 (version (package-version llvm-6))
1160 (source (origin
1161 (method url-fetch)
1162 (uri (string-append "https://releases.llvm.org/"
1163 version "/openmp-" version
1164 ".src.tar.xz"))
1165 (sha256
1166 (base32
1167 "0nhwfba9c351r16zgyjyfwdayr98nairky3c2f0b2lc360mwmbv6"))
1168 (file-name (string-append "libomp-" version ".tar.xz"))))
1169 (native-inputs
1170 (modify-inputs (package-native-inputs libomp-7)
1171 (replace "clang" clang-6)
1172 (replace "llvm" llvm-6)))))
1173
1174 (define-public clang-toolchain-6
1175 (make-clang-toolchain clang-6 libomp-6))
1176
1177 (define-public llvm-3.9.1
1178 (package (inherit llvm-6)
1179 (name "llvm")
1180 (version "3.9.1")
1181 (source
1182 (origin
1183 (method url-fetch)
1184 (uri (llvm-uri "llvm" version))
1185 (sha256
1186 (base32
1187 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
1188 (outputs '("out"))
1189 (arguments
1190 (substitute-keyword-arguments (package-arguments llvm)
1191 ((#:phases phases)
1192 #~(modify-phases #$phases
1193 (add-before 'build 'shared-lib-workaround
1194 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
1195 ;; doesn't seem to get the correct rpath to be able to run
1196 ;; from the build directory. Set LD_LIBRARY_PATH as a
1197 ;; workaround.
1198 (lambda _
1199 (setenv "LD_LIBRARY_PATH"
1200 (string-append (getcwd) "/lib"))))
1201 (delete 'install-opt-viewer)))))))
1202
1203 (define-public clang-runtime-3.9.1
1204 (clang-runtime-from-llvm
1205 llvm-3.9.1
1206 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
1207 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
1208 "clang-runtime-asan-build-fixes.patch"
1209 "clang-runtime-esan-build-fixes.patch"
1210 "clang-3.5-libsanitizer-ustat-fix.patch")))
1211
1212 (define-public clang-3.9.1
1213 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
1214 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
1215 #:patches '("clang-3.8-libc-search-path.patch")))
1216
1217 (define-public llvm-3.8
1218 (package (inherit llvm-3.9.1)
1219 (name "llvm")
1220 (version "3.8.1")
1221 (source
1222 (origin
1223 (method url-fetch)
1224 (uri (llvm-uri "llvm" version))
1225 (sha256
1226 (base32
1227 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))
1228 (patches (search-patches "llvm-3.x.1-fix-build-with-gcc.patch"))))))
1229
1230 (define-public clang-runtime-3.8
1231 (clang-runtime-from-llvm
1232 llvm-3.8
1233 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
1234 '("clang-runtime-asan-build-fixes.patch"
1235 "clang-runtime-3.8-libsanitizer-mode-field.patch"
1236 "clang-3.5-libsanitizer-ustat-fix.patch")))
1237
1238 (define-public clang-3.8
1239 (clang-from-llvm llvm-3.8 clang-runtime-3.8
1240 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
1241 #:patches '("clang-3.8-libc-search-path.patch")))
1242
1243 (define-public llvm-3.7
1244 (package (inherit llvm-3.8)
1245 (version "3.7.1")
1246 (source
1247 (origin
1248 (method url-fetch)
1249 (uri (llvm-uri "llvm" version))
1250 (sha256
1251 (base32
1252 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))
1253 (patches (search-patches "llvm-3.x.1-fix-build-with-gcc.patch"))))))
1254
1255 (define-public clang-runtime-3.7
1256 (clang-runtime-from-llvm
1257 llvm-3.7
1258 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
1259 '("clang-runtime-asan-build-fixes.patch"
1260 "clang-runtime-3.8-libsanitizer-mode-field.patch"
1261 "clang-3.5-libsanitizer-ustat-fix.patch"
1262 "clang-runtime-3.7-fix-build-with-python3.patch")))
1263
1264 (define-public clang-3.7
1265 (clang-from-llvm llvm-3.7 clang-runtime-3.7
1266 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
1267 #:patches '("clang-3.5-libc-search-path.patch")))
1268
1269 (define-public llvm-3.6
1270 (package (inherit llvm-3.7)
1271 (version "3.6.2")
1272 (source
1273 (origin
1274 (method url-fetch)
1275 (uri (llvm-uri "llvm" version))
1276 (patches
1277 (search-patches "llvm-3.6-fix-build-with-gcc-10.patch"))
1278 (sha256
1279 (base32
1280 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
1281
1282 (define-public llvm-3.5
1283 (package (inherit llvm-3.6)
1284 (version "3.5.2")
1285 (source
1286 (origin
1287 (method url-fetch)
1288 (uri (llvm-uri "llvm" version))
1289 (patches
1290 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1291 (sha256
1292 (base32
1293 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1294
1295 (define-public clang-runtime-3.5
1296 (let ((runtime (clang-runtime-from-llvm
1297 llvm-3.5
1298 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
1299 '("clang-runtime-asan-build-fixes.patch"
1300 "clang-runtime-3.5-libsanitizer-mode-field.patch"
1301 "clang-3.5-libsanitizer-ustat-fix.patch"))))
1302 (package/inherit runtime
1303 (arguments
1304 (substitute-keyword-arguments (package-arguments runtime)
1305 ((#:phases phases '%standard-phases)
1306 `(modify-phases ,phases
1307 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
1308 ;; libtirpc.
1309 (add-after 'unpack 'find-rpc-includes
1310 (lambda* (#:key inputs #:allow-other-keys)
1311 (setenv "CPATH"
1312 (string-append
1313 (search-input-directory inputs "/include/tirpc")
1314 ":" (or (getenv "CPATH") "")))
1315 (setenv "CPLUS_INCLUDE_PATH"
1316 (string-append
1317 (search-input-directory inputs "/include/tirpc")
1318 ":" (or (getenv "CPLUS_INCLUDE_PATH") "")))))))))
1319 (inputs
1320 `(("libtirpc" ,libtirpc)
1321 ("llvm" ,llvm-3.5))))))
1322
1323 (define-public clang-3.5
1324 (clang-from-llvm llvm-3.5 clang-runtime-3.5
1325 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
1326 #:patches '("clang-3.5-libc-search-path.patch")))
1327
1328 ;; Default LLVM and Clang version.
1329 (define-public libomp libomp-13)
1330 (define-public llvm llvm-13)
1331 (define-public clang-runtime clang-runtime-13)
1332 (define-public clang clang-13)
1333 (define-public clang-toolchain clang-toolchain-13)
1334
1335 (define-public llvm-for-rocm
1336 (package
1337 ;; Based on LLVM 14 as of v5.0.0
1338 (inherit llvm-14)
1339 (name "llvm-for-rocm")
1340 (version "5.1.3") ;this must match '%rocm-version'
1341 (source (origin
1342 (method git-fetch)
1343 (uri (git-reference
1344 (url "https://github.com/RadeonOpenCompute/llvm-project.git")
1345 (commit (string-append "rocm-" version))))
1346 (file-name (git-file-name name version))
1347 (sha256
1348 (base32
1349 "0j6ydfkwrxwskgnhxc3cmry42n5faqbnwf2747qgf7lz5id8h8g5"))
1350 (patches
1351 (search-patches "llvm-roc-5.0.0-linkdl.patch"
1352 "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
1353 (arguments
1354 (substitute-keyword-arguments (package-arguments llvm-14)
1355 ((#:configure-flags flags)
1356 #~(list"-DLLVM_ENABLE_PROJECTS=llvm;clang;lld"
1357 "-DLLVM_TARGETS_TO_BUILD=AMDGPU;X86"
1358 "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
1359 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
1360 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
1361 "-DLLVM_VERSION_SUFFIX="))))
1362 (properties `((hidden? . #t)
1363 ,@(package-properties llvm-14)))))
1364
1365 \f
1366
1367 (define-public libunwind-headers
1368 (package
1369 (name "libunwind-headers")
1370 (version "13.0.0")
1371 (source (origin
1372 (method url-fetch)
1373 (uri (llvm-uri "libunwind" version))
1374 (sha256
1375 (base32
1376 "1qb5ickp7qims5q7sxacj3fwq1kklvnl94k3v9hpl5qn284iky1n"))))
1377 (build-system cmake-build-system)
1378 (arguments
1379 '(#:phases (modify-phases (map (lambda (phase)
1380 (assq phase %standard-phases))
1381 '(set-paths unpack))
1382 (add-after 'unpack 'install
1383 (lambda* (#:key outputs #:allow-other-keys)
1384 (let ((out (assoc-ref outputs "out")))
1385 (mkdir out)
1386 (copy-recursively "include"
1387 (string-append out "/include"))))))))
1388 (home-page "https://clang.llvm.org/docs/Toolchain.html")
1389 (synopsis "LLVM libunwind header files")
1390 (description
1391 "This package contains header files for the LLVM C++ unwinding library.")
1392 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))
1393 (license license:asl2.0))) ;with LLVM exceptions
1394
1395 (define-public lld-14
1396 (package
1397 (name "lld")
1398 (version "14.0.6")
1399 (source (llvm-monorepo version))
1400 (build-system cmake-build-system)
1401 (inputs
1402 (list llvm-14))
1403 (arguments
1404 '(#:build-type "Release"
1405 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
1406 ;; package.
1407 #:tests? #f
1408 #:phases (modify-phases %standard-phases
1409 (add-after 'unpack 'change-directory
1410 (lambda _
1411 (chdir "lld"))))))
1412 (home-page "https://lld.llvm.org/")
1413 (synopsis "Linker from the LLVM project")
1414 (description "LLD is a high-performance linker, built as a set of reusable
1415 components which highly leverage existing libraries in the larger LLVM Project.")
1416 (license license:asl2.0))) ; With LLVM exception
1417
1418 (define-public lld-13
1419 (package
1420 (inherit lld-14)
1421 (version "13.0.1")
1422 (source (origin
1423 (method url-fetch)
1424 (uri (llvm-uri "lld" version))
1425 (sha256
1426 (base32
1427 "1yscckcszfr234k4svhybdbsnz6w65x8pldl6c2nhyxzx12zfsk6"))))
1428 (native-inputs
1429 ;; Note: check <https://bugs.llvm.org/show_bug.cgi?id=49228> to see
1430 ;; whether this is still necessary.
1431 (list libunwind-headers))
1432 (inputs
1433 (list llvm-13))
1434 (arguments
1435 '(#:build-type "Release"
1436 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
1437 ;; package.
1438 #:tests? #f))
1439 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
1440
1441 (define-public lld-12
1442 (package
1443 (inherit lld-13)
1444 (version "12.0.1")
1445 (source (origin
1446 (method url-fetch)
1447 (uri (llvm-uri "lld" version))
1448 (sha256
1449 (base32
1450 "0qg3fgc7wj34hdkqn21y03zcmsdd01szhhm1hfki63iifrm3y2v9"))))
1451 (inputs (modify-inputs (package-inputs lld)
1452 (replace "llvm" llvm-12)))))
1453
1454 (define-public lld lld-14)
1455
1456 (define* (make-lld-wrapper lld #:key lld-as-ld?)
1457 "Return a LLD wrapper. When LLD-AS-LD? is true, create a 'ld' symlink that
1458 points to 'lld'."
1459 (package
1460 (name (if lld-as-ld? "lld-as-ld-wrapper" "lld-wrapper"))
1461 (version "0")
1462 (source #f)
1463 (build-system trivial-build-system)
1464 (inputs (list (make-ld-wrapper "ld.lld-wrapper" #:binutils lld
1465 #:linker "ld.lld")
1466 (make-ld-wrapper "lld-wrapper" #:binutils lld #:linker
1467 "lld")))
1468 (arguments
1469 (list #:builder
1470 #~(let ((ld.lld (string-append #$(this-package-input
1471 "ld.lld-wrapper")
1472 "/bin/ld.lld"))
1473 (lld (string-append #$(this-package-input "lld-wrapper")
1474 "/bin/lld")))
1475 (mkdir #$output)
1476 (mkdir (string-append #$output "/bin"))
1477 (symlink ld.lld (string-append #$output "/bin/ld.lld"))
1478 (symlink lld (string-append #$output "/bin/lld"))
1479 (when #$lld-as-ld?
1480 (symlink ld.lld (string-append #$output "/bin/ld"))))))
1481 (synopsis "LLD linker wrapper")
1482 (description "This is a linker wrapper for LLD; like @code{ld-wrapper}, it
1483 wraps the linker to add any missing @code{-rpath} flags, and to detect any
1484 misuse of libraries outside of the store.")
1485 (home-page "https://www.gnu.org/software/guix/")
1486 (license license:gpl3+)))
1487
1488 ;;; A LLD wrapper suitable to use with -fuse-ld and GCC or with Clang.
1489 (define-public lld-wrapper
1490 (make-lld-wrapper lld))
1491
1492 ;;; A LLD wrapper that can be used as a (near) drop-in replacement to GNU ld.
1493 (define-public lld-as-ld-wrapper
1494 (make-lld-wrapper lld #:lld-as-ld? #t))
1495
1496 (define-public lldb
1497 (package
1498 (name "lldb")
1499 (version "14.0.6")
1500 (source (llvm-monorepo version))
1501 (build-system cmake-build-system)
1502 (arguments
1503 (list
1504 #:configure-flags #~(list "-DOPENMP_TEST_CXX_COMPILER=clang++")
1505 #:phases
1506 #~(modify-phases %standard-phases
1507 (add-after 'unpack 'chdir-to-source
1508 (lambda _
1509 (chdir "lldb"))))))
1510 (native-inputs
1511 (list pkg-config swig))
1512 (inputs
1513 (list clang-14
1514 llvm-14
1515 ;; Optional (but recommended) inputs.
1516 ncurses
1517 libedit
1518 xz
1519 libxml2
1520 lua
1521 python))
1522 (home-page "https://lldb.llvm.org/")
1523 (synopsis "Low level debugger")
1524 (description
1525 "LLDB is a high performance debugger built as a set of reusable components
1526 which highly leverage existing libraries in the larger LLVM project.")
1527 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))
1528 (license license:asl2.0))) ;with LLVM exceptions
1529
1530 (define-public libcxx
1531 (package
1532 (name "libcxx")
1533 (version "9.0.1")
1534 (source
1535 (origin
1536 (method url-fetch)
1537 (uri (llvm-uri "libcxx" version))
1538 (sha256
1539 (base32
1540 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
1541 (build-system cmake-build-system)
1542 (arguments
1543 `(#:phases
1544 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
1545 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
1546 (lambda* (#:key inputs #:allow-other-keys)
1547 (let ((gcc (assoc-ref inputs "gcc")))
1548 ;; Hide GCC's C++ headers so that they do not interfere with
1549 ;; the ones we are attempting to build.
1550 (setenv "CPLUS_INCLUDE_PATH"
1551 (string-join (delete (string-append gcc "/include/c++")
1552 (string-split (getenv "CPLUS_INCLUDE_PATH")
1553 #\:))
1554 ":"))
1555 (format #t
1556 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
1557 (getenv "CPLUS_INCLUDE_PATH"))
1558 #t))))))
1559 (native-inputs
1560 (list clang llvm))
1561 (home-page "https://libcxx.llvm.org")
1562 (synopsis "C++ standard library")
1563 (description
1564 "This package provides an implementation of the C++ standard library for
1565 use with Clang, targeting C++11, C++14 and above.")
1566 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))
1567 (license license:expat)))
1568
1569 ;; Libcxx files specifically used by PySide2.
1570 (define-public libcxx-6
1571 (package
1572 (inherit libcxx)
1573 (version (package-version llvm-6))
1574 (source
1575 (origin
1576 (inherit (package-source libcxx))
1577 (uri (llvm-uri "libcxx" version))
1578 (sha256
1579 (base32
1580 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
1581 (native-inputs
1582 (list clang-6 llvm-6))))
1583
1584 (define-public libcxxabi-6
1585 (package
1586 (name "libcxxabi")
1587 (version "6.0.1")
1588 (source
1589 (origin
1590 (method git-fetch)
1591 (uri (git-reference
1592 (url "https://github.com/llvm/llvm-project")
1593 (commit (string-append "llvmorg-" version))))
1594 (file-name (git-file-name name version))
1595 (sha256
1596 (base32
1597 "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g"))))
1598 (build-system cmake-build-system)
1599 (arguments
1600 `(#:configure-flags
1601 (list (string-append "-DLIBCXXABI_LIBCXX_INCLUDES="
1602 (assoc-ref %build-inputs "libcxx")
1603 "/include")
1604 "-DCMAKE_C_COMPILER=clang"
1605 "-DCMAKE_CXX_COMPILER=clang++")
1606 #:phases
1607 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
1608 (add-after 'unpack 'chdir
1609 (lambda _ (chdir "libcxxabi")))
1610 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
1611 (lambda* (#:key inputs #:allow-other-keys)
1612 (let ((gcc (assoc-ref inputs "gcc")))
1613 ;; Hide GCC's C++ headers so that they do not interfere with
1614 ;; the ones we are attempting to build.
1615 (setenv "CPLUS_INCLUDE_PATH"
1616 (string-join
1617 (cons (string-append
1618 (assoc-ref inputs "libcxx") "/include/c++/v1")
1619 (delete (string-append gcc "/include/c++")
1620 (string-split (getenv "CPLUS_INCLUDE_PATH")
1621 #\:)))
1622 ":"))
1623 (format #true
1624 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
1625 (getenv "CPLUS_INCLUDE_PATH")))))
1626 (add-after 'install 'install-headers
1627 (lambda* (#:key outputs #:allow-other-keys)
1628 (let ((include-dir (string-append
1629 (assoc-ref outputs "out") "/include")))
1630 (install-file "../libcxxabi/include/__cxxabi_config.h" include-dir)
1631 (install-file "../libcxxabi/include/cxxabi.h" include-dir)))))))
1632 (native-inputs
1633 (list clang-6 llvm-6 libcxx-6))
1634 (home-page "https://libcxxabi.llvm.org")
1635 (synopsis "C++ standard library support")
1636 (description
1637 "This package provides an implementation of low level support for a
1638 standard C++ library.")
1639 (license license:expat)))
1640
1641 (define-public libcxx+libcxxabi-6
1642 (package
1643 (inherit libcxx-6)
1644 (name "libcxx+libcxxabi")
1645 (version (package-version libcxx-6))
1646 (arguments
1647 `(#:configure-flags
1648 (list "-DLIBCXX_CXX_ABI=libcxxabi"
1649 (string-append "-DLIBCXX_CXX_ABI_INCLUDE_PATHS="
1650 (assoc-ref %build-inputs "libcxxabi")
1651 "/include"))
1652 #:phases
1653 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
1654 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
1655 (lambda* (#:key inputs #:allow-other-keys)
1656 (let ((gcc (assoc-ref inputs "gcc")))
1657 ;; Hide GCC's C++ headers so that they do not interfere with
1658 ;; the ones we are attempting to build.
1659 (setenv "CPLUS_INCLUDE_PATH"
1660 (string-join
1661 (delete (string-append gcc "/include/c++")
1662 (string-split (getenv "CPLUS_INCLUDE_PATH")
1663 #\:))
1664 ":"))
1665 (format #true
1666 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
1667 (getenv "CPLUS_INCLUDE_PATH"))))))))
1668 (native-inputs
1669 (list clang-6 llvm-6 libcxxabi-6))))
1670
1671 (define-public libclc
1672 (package
1673 (name "libclc")
1674 (version "9.0.1")
1675 (source
1676 (origin
1677 (method git-fetch)
1678 (uri (git-reference
1679 (url "https://github.com/llvm/llvm-project")
1680 (commit (string-append "llvmorg-" version))))
1681 (file-name (git-file-name name version))
1682 (sha256
1683 (base32
1684 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
1685 (build-system cmake-build-system)
1686 (arguments
1687 `(#:configure-flags
1688 (list (string-append "-DLLVM_CLANG="
1689 (assoc-ref %build-inputs "clang")
1690 "/bin/clang")
1691 (string-append "-DPYTHON="
1692 (assoc-ref %build-inputs "python")
1693 "/bin/python3"))
1694 #:phases
1695 (modify-phases %standard-phases
1696 (add-after 'unpack 'chdir
1697 (lambda _ (chdir "libclc") #t)))))
1698 (native-inputs
1699 (list clang-9 llvm-9 python))
1700 (home-page "https://libclc.llvm.org")
1701 (synopsis "Libraries for the OpenCL programming language")
1702 (description
1703 "This package provides an implementation of the OpenCL library
1704 requirements according to version 1.1 of the OpenCL specification.")
1705 ;; Apache license 2.0 with LLVM exception
1706 (license license:asl2.0)))
1707
1708 (define-public python-llvmlite
1709 (package
1710 (name "python-llvmlite")
1711 (version "0.38.0")
1712 (source
1713 (origin
1714 (method url-fetch)
1715 (uri (pypi-uri "llvmlite" version))
1716 (sha256
1717 (base32
1718 "0p4nyic9rm7s2fm3m3wpkh568594p9q9nfyjkqxny49vrxn1d7d9"))))
1719 (build-system python-build-system)
1720 (arguments
1721 `(#:phases
1722 (modify-phases %standard-phases
1723 (add-after 'unpack 'patch-reference-to-llvmlite.so
1724 ;; ctypes.CDLL uses dlopen to load libllvmlite.so, which
1725 ;; fails, so locate it by its absolute path. Change it in
1726 ;; ffi.py, not utils.py, because setup.py relies on the
1727 ;; output of get_library_name for proper installation.
1728 (lambda* (#:key outputs #:allow-other-keys)
1729 (let* ((out (assoc-ref outputs "out"))
1730 (libllvmlite.so (string-append out "/lib/python"
1731 ,(version-major+minor
1732 (package-version python))
1733 "/site-packages/llvmlite/"
1734 "binding/libllvmlite.so")))
1735 (substitute* "llvmlite/binding/ffi.py"
1736 (("_lib_name = get_library_name\\(\\)")
1737 (format #f "_lib_name = ~s" libllvmlite.so))))))
1738 (add-after 'unpack 'skip-failing-tests
1739 (lambda _
1740 (substitute* "llvmlite/tests/test_binding.py"
1741 ((" def test_libm\\(self\\).*" all)
1742 (string-append " @unittest.skip('Fails on Guix')\n" all)))))
1743 (add-before 'build 'set-compiler/linker-flags
1744 (lambda* (#:key inputs #:allow-other-keys)
1745 (let ((llvm (assoc-ref inputs "llvm")))
1746 ;; Refer to ffi/Makefile.linux.
1747 (setenv "CPPFLAGS" "-fPIC")
1748 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
1749 llvm "/lib"))))))))
1750 (inputs
1751 (list
1752 (let* ((patches-commit
1753 "a4a19e8af2c5ef9b9901f20193e4be070726da97")
1754 (patch-uri (lambda (name)
1755 (string-append
1756 "https://raw.githubusercontent.com/numba/"
1757 "llvmlite/"
1758 patches-commit
1759 "/conda-recipes/"
1760 name)))
1761 (patch-origin (lambda (name hash)
1762 (origin (method url-fetch)
1763 (uri (patch-uri name))
1764 (sha256 (base32 hash)))))
1765 (arch-independent-patches
1766 (list (patch-origin
1767 "partial-testing.patch"
1768 "0g3nkci87knvmn7piqhmh4bcc65ff8r921cvfcibyiv65klv3syg")
1769 (patch-origin
1770 "0001-Revert-Limit-size-of-non-GlobalValue-name.patch"
1771 "0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295"))))
1772 (package
1773 (inherit llvm-11)
1774 (source
1775 (origin
1776 (inherit (package-source llvm-11))
1777 (patches (if (string=? "aarch64-linux" (%current-system))
1778 `(,(patch-origin
1779 "intel-D47188-svml-VF_LLVM9.patch"
1780 "0gnnlfxr8p1a7ls93hzcpfqpa8r0icypfwj8l9cmkslq5sz8p64r")
1781 ,@arch-independent-patches
1782 ,@(origin-patches (package-source llvm-11)))
1783 `(,(patch-origin
1784 "intel-D47188-svml-VF.patch"
1785 "0gnnlfxr8p1a7ls93hzcpfqpa8r0icypfwj8l9cmkslq5sz8p64r")
1786 ,(patch-origin
1787 "expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch"
1788 "0jxhjkkwwi1cy898l2n57l73ckpw0v73lqnrifp7r1mwpsh624nv")
1789 ,@arch-independent-patches
1790 ,@(origin-patches (package-source llvm-11)))))))))))
1791 (home-page "https://llvmlite.pydata.org")
1792 (synopsis "Wrapper around basic LLVM functionality")
1793 (description
1794 "This package provides a Python binding to LLVM for use in Numba.")
1795 (license license:bsd-3)))
1796
1797 (define-public (clang-python-bindings clang)
1798 "Return a package for the Python bindings of CLANG."
1799 (package
1800 (inherit clang)
1801 (name "python-clang")
1802 (build-system python-build-system)
1803 (outputs '("out"))
1804 (arguments
1805 '(#:phases (modify-phases %standard-phases
1806 (add-before 'build 'change-directory
1807 (lambda _
1808 (chdir "bindings/python")))
1809 (add-before 'build 'create-setup-py
1810 (lambda _
1811 ;; Generate a basic "setup.py", enough so it can be
1812 ;; built and installed.
1813 (with-output-to-file "setup.py"
1814 (lambda ()
1815 (display "from setuptools import setup
1816 setup(name=\"clang\", packages=[\"clang\"])\n")))))
1817 (add-before 'build 'set-libclang-file-name
1818 (lambda* (#:key inputs #:allow-other-keys)
1819 ;; Record the absolute file name of libclang.so.
1820 (let ((libclang (search-input-file inputs
1821 "/lib/libclang.so")))
1822 (substitute* "clang/cindex.py"
1823 (("libclang\\.so") libclang))))))))
1824 (inputs (list clang))
1825 (synopsis "Python bindings to libclang")))
1826
1827 (define-public python-clang-10
1828 (clang-python-bindings clang-10))
1829
1830 (define-public python-clang-11
1831 (clang-python-bindings clang-11))
1832
1833 (define-public python-clang-12
1834 (clang-python-bindings clang-12))
1835
1836 (define-public python-clang-13
1837 (clang-python-bindings clang-13))
1838
1839 (define-public emacs-clang-format
1840 (package
1841 (inherit clang)
1842 (name "emacs-clang-format")
1843 (build-system emacs-build-system)
1844 (inputs
1845 (list clang))
1846 (propagated-inputs '())
1847 (arguments
1848 `(#:phases
1849 (modify-phases %standard-phases
1850 (add-after 'unpack 'configure
1851 (lambda* (#:key inputs #:allow-other-keys)
1852 (let ((clang-format (search-input-file inputs "/bin/clang-format")))
1853 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
1854 (emacs-substitute-variables "clang-format.el"
1855 ("clang-format-executable"
1856 clang-format))))))))
1857 (synopsis "Format code using clang-format")
1858 (description "This package filters code through @code{clang-format}
1859 to fix its formatting. @code{clang-format} is a tool that formats
1860 C/C++/Obj-C code according to a set of style options, see
1861 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
1862
1863 (define-public emacs-clang-rename
1864 (package
1865 (inherit clang)
1866 (name "emacs-clang-rename")
1867 (build-system emacs-build-system)
1868 (inputs
1869 (list clang))
1870 (arguments
1871 `(#:phases
1872 (modify-phases %standard-phases
1873 (add-after 'unpack 'configure
1874 (lambda* (#:key inputs #:allow-other-keys)
1875 (let ((clang-rename (search-input-file inputs "/bin/clang-rename")))
1876 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1877 (emacs-substitute-variables "clang-rename.el"
1878 ("clang-rename-binary"
1879 clang-rename))))))))
1880 (synopsis "Rename every occurrence of a symbol using clang-rename")
1881 (description "This package renames every occurrence of a symbol at point
1882 using @code{clang-rename}.")))
1883
1884 \f
1885 ;;;
1886 ;;; LLVM variants.
1887 ;;;
1888
1889 (define make-ocaml-llvm
1890 ;; Make it a memoizing procedure so its callers below don't end up defining
1891 ;; two equal-but-not-eq "ocaml-llvm" packages for the default LLVM.
1892 (mlambdaq (llvm)
1893 (package
1894 (inherit llvm)
1895 (name "ocaml-llvm")
1896 (outputs '("out"))
1897 (arguments
1898 `(#:configure-flags
1899 (list
1900 (string-append "-DLLVM_OCAML_EXTERNAL_LLVM_LIBDIR="
1901 (assoc-ref %build-inputs "llvm") "/lib")
1902 "-DBUILD_SHARED_LIBS=TRUE"
1903 "-DLLVM_OCAML_OUT_OF_TREE=TRUE"
1904 (string-append "-DLLVM_OCAML_INSTALL_PATH="
1905 (assoc-ref %outputs "out") "/lib/ocaml/site-lib"))
1906 #:phases
1907 (modify-phases %standard-phases
1908 (replace 'build
1909 (lambda _
1910 (invoke "make" "ocaml_all")))
1911 (replace 'install
1912 (lambda _
1913 (invoke "cmake" "-P" "bindings/ocaml/cmake_install.cmake"))))))
1914 (inputs
1915 (list llvm))
1916 (native-inputs
1917 (list ocaml ocaml-findlib ocaml-ounit python))
1918 (propagated-inputs
1919 (list ocaml-integers ocaml-ctypes))
1920 (synopsis "OCaml bindings to LLVM")
1921 (description "This package contains the OCaml bindings distributed with
1922 LLVM."))))
1923
1924 (define-public ocaml-llvm (make-ocaml-llvm llvm))
1925 (define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9))
1926 (define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10))
1927 (define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11))
1928
1929 (define-public llvm-julia
1930 (package
1931 (inherit llvm-11)
1932 (name "llvm-julia")
1933 (properties `((hidden? . #t)
1934 ,@(package-properties llvm-11)))
1935 (source (origin
1936 (inherit (package-source llvm-11))
1937 ;; Those patches are inside the Julia source repo.
1938 ;; They are _not_ Julia specific (https://github.com/julialang/julia#llvm)
1939 ;; but they are required to build Julia.
1940 ;; Discussion: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919628
1941 (patches
1942 (map (match-lambda
1943 ((name hash)
1944 (julia-patch name hash)))
1945 (list
1946 '("llvm-D27629-AArch64-large_model_6.0.1"
1947 "1qrshmlqvnasdyc158vfn3hnbigqph3lsq7acb9w8lwkpnnm2j4z")
1948 '("llvm8-D34078-vectorize-fdiv"
1949 "19spqc3xsazn1xs9gpcgv9ldadfkv49rmc5khl7sf1dlmhgi4602")
1950 '("llvm-7.0-D44650"
1951 "1h55kkmkiisfj6sk956if2bcj9s0v6n5czn8dxb870vp5nccj3ir")
1952 '("llvm7-symver-jlprefix"
1953 "00ng32x6xhm9czczirn5r1q1mc1myad44fqhi061hwh1vb46dwgm")
1954 '("llvm-6.0-DISABLE_ABI_CHECKS"
1955 "014fawd1ba7yckalypfld22zgic87x9nx3cim42zrwygywd36pyg")
1956 '("llvm9-D50010-VNCoercion-ni"
1957 "1s1d3sjsiq4vxg7ncy5cz56zgy5vcq6ls3iqaiqkvr23wyryqmdx")
1958 '("llvm7-revert-D44485"
1959 "0f59kq3p3mpwsbmskypbi4zn01l6ig0x7v2rjp08k2r8z8m6fa8n")
1960 '("llvm-11-D75072-SCEV-add-type"
1961 "176xi1lnbnv2rcs05ywhyb7pd0xgmibayvwzksksg44wg2dh8mbx")
1962 '("llvm-julia-tsan-custom-as"
1963 "0awh40kf6lm4wn1nsjd1bmhfwq7rqj811szanp2xkpspykw9hg9s")
1964 '("llvm-D80101"
1965 "1gsdwmgmpbignvqyxcnlprj899259p3dvdznlncd84ss445qgq3j")
1966 '("llvm-D84031"
1967 "0nks9sbk7p0r5gyr0idrmm93a5fmdai8kihz9532dx4zhcvvqbjc")
1968 '("llvm-10-D85553"
1969 "1zjq7j9q2qp56hwkc8yc8f0z7kvam3j7hj8sb7qyd77r255ff78l")
1970 '("llvm-10-unique_function_clang-sa"
1971 "1jys9w2zqk3dasnxqh0qz5ij7rxi6mkgq9pqjsclmamr5169zyan")
1972 ;'("llvm-D88630-clang-cmake"
1973 ; "0rs6s71nqnjkny7i69gqazhqj5jqfdr0bkxs2v5a55sfx8fa1k54")
1974 '("llvm-11-D85313-debuginfo-empty-arange"
1975 "1f672d5385xpgb8yrim8d3b7wg2z1l81agnshm1q61kdvjixqx32")
1976 '("llvm-11-D90722-rtdyld-absolute-relocs"
1977 "0kmnai229yyxkmpk9lxd180mcnhk2i8d87k2sg89gc8as18w10r6")
1978 '("llvm-invalid-addrspacecast-sink"
1979 "1n1b7j4s80vj7x5377aj9vyphmxx1q6bm0chhkxp6zsy3mx3g2ry")
1980 '("llvm-11-D92906-ppc-setjmp"
1981 "0cmd4dsblp7a8m03j16dqxws0ijh55zf4jzzxmj341qxa1gamdp9")
1982 '("llvm-11-PR48458-X86ISelDAGToDAG"
1983 "0vwzvlhsdazhxg4gj8g2f00a4f8qc5cgac23w575xk3pgba1jh6y")
1984 '("llvm-11-D93092-ppc-knownbits"
1985 "1748bypsc7c9lbs3fnkv0kwvch6bn85kj98j4jdaz254ig0wa6xj")
1986 '("llvm-11-D93154-globalisel-as"
1987 "1k5wd4z3pa7zj0gyjkif7viqj906dhqlbb7dc95gig40nbxv6zpj")
1988 '("llvm-11-ppc-half-ctr"
1989 "0piywisfz6cmw3133kz7vzhiqflq2y7igakqxlym0gi8pqylv7w9")
1990 '("llvm-11-ppc-sp-from-bp"
1991 "1wmg3485cx5f9pbykyl3jibk1wwv4w1x30hl4jyfndzr2yh8azf9")
1992 '("llvm-rGb498303066a6-gcc11-header-fix"
1993 "0hkd4rwhvh8g2yh13g29wiwnjpv2yd1hdyiv1ryw8izl25bz9c67")
1994 '("llvm-11-D94813-mergeicmps"
1995 "0cmy0ywkgyrdcvr9bd6pd912lyd4gcsrib4z0v05dwgcdxhk7y29")
1996 '("llvm-11-D94980-CTR-half"
1997 "1yf8cxib3z8hz7zi9n6v2g2c6vpfr4slq9hpx8m8yq8f1jbyw3fw")
1998 '("llvm-11-D94058-sext-atomic-ops"
1999 "1x6p6k6q651z5jcqxx8vj17cxnv196mka7mwn7dpp6c23lwgfdpb")
2000 '("llvm-11-D96283-dagcombine-half"
2001 "0lv4iq2f8qrcz1xyxfic3bcr5p0aqam3a7c6pp6fnw3riixm096k"))))
2002 (patch-flags '("-p1"))))
2003 (arguments
2004 (substitute-keyword-arguments (package-arguments llvm-11)
2005 ((#:phases phases)
2006 `(modify-phases ,phases
2007 (add-after 'unpack 'patch-round-two
2008 ;; We have to do the patching in two rounds because we can't
2009 ;; pass '-p1' and '-p2' in the source field.
2010 (lambda* (#:key inputs #:allow-other-keys)
2011 (map (lambda (patchname)
2012 (invoke "patch" patchname "-p2"))
2013 (list "llvm-11-AArch64-FastIsel-bug"
2014 "llvm-11-D97435-AArch64-movaddrreg"
2015 "llvm-11-D97571-AArch64-loh"
2016 "llvm-11-aarch64-addrspace"))))))
2017 ((#:build-type _) "Release")
2018 ((#:configure-flags flags)
2019 `(list
2020 ;; Build a native compiler and the NVPTX backend (NVIDIA) since
2021 ;; Julia insists on it, nothing more. This reduces build times and
2022 ;; disk usage.
2023 ,(string-append "-DLLVM_TARGETS_TO_BUILD=" (system->llvm-target))
2024 "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=NVPTX"
2025
2026 "-DLLVM_INSTALL_UTILS=ON"
2027 "-DLLVM_BUILD_TESTS=ON"
2028 "-DLLVM_ENABLE_FFI=ON"
2029 "-DLLVM_ENABLE_RTTI=ON"
2030 ;; "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
2031 ;; "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
2032 ;; "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly"
2033 "-DLLVM_ENABLE_DUMP=ON"
2034 "-DLLVM_LINK_LLVM_DYLIB=ON"
2035 "-DLLVM_VERSION_SUFFIX:STRING=jl"))))
2036 (inputs
2037 (append
2038 (package-inputs llvm-11)
2039 `(("llvm-11-AArch64-FastIsel-bug"
2040 ,(julia-patch "llvm-11-AArch64-FastIsel-bug"
2041 "1m2vddj1mw4kbij8hbrx82piyy6bvr2x7wwdnlxfaqcm72ipzyh9"))
2042 ("llvm-11-D97435-AArch64-movaddrreg"
2043 ,(julia-patch "llvm-11-D97435-AArch64-movaddrreg"
2044 "10jnavq9ljkj7j2gqj2zd1pwqpqb5zs3zp9h96pmz0djbmxwa86y"))
2045 ("llvm-11-D97571-AArch64-loh"
2046 ,(julia-patch "llvm-11-D97571-AArch64-loh"
2047 "128zcbg1w1j7hngsf7z1a7alc6lig6l2rqgjp6i8nk3k3f842v6n"))
2048 ("llvm-11-aarch64-addrspace"
2049 ,(julia-patch "llvm-11-aarch64-addrspace"
2050 "0ckbzgfirxrf2d5bpinpngp7gnilbjrk0cbdfyl3h6f5v6i6xj6m")))))))
2051
2052 (define %cling-version "0.9")
2053
2054 (define llvm-cling ;LLVM 9 with approximately 10 patches for cling
2055 (let ((base llvm-9))
2056 (package/inherit base
2057 (name "llvm-cling")
2058 (source
2059 (origin
2060 (inherit (package-source base))
2061 (method git-fetch)
2062 (uri (git-reference
2063 (url "http://root.cern/git/llvm.git")
2064 (commit (string-append "cling-v" %cling-version))))
2065 (file-name (git-file-name "llvm-cling" %cling-version))
2066 (sha256
2067 (base32
2068 "0y3iwv3c9152kybmdrwvadggjs163r25h7rmlxzr3hfpr463pnwf"))
2069 (modules '((guix build utils)))
2070 (snippet
2071 ;; The source is missing an include directive (see:
2072 ;; https://github.com/vgvassilev/cling/issues/219).
2073 '(substitute* "utils/benchmark/src/benchmark_register.h"
2074 (("^#include <vector>.*" all)
2075 (string-append all "#include <limits>\n"))))))
2076 (outputs '("out"))
2077 (arguments
2078 (substitute-keyword-arguments (package-arguments base)
2079 ((#:configure-flags _ ''())
2080 '(list "-DLLVM_PARALLEL_LINK_JOBS=1" ;cater to smaller build machines
2081 ;; Only enable compiler support for the host architecture to
2082 ;; save on build time.
2083 "-DLLVM_TARGETS_TO_BUILD=host;NVPTX"
2084 "-DLLVM_INSTALL_UTILS=ON"
2085 "-DLLVM_ENABLE_RTTI=ON"
2086 "-DLLVM_ENABLE_FFI=ON"
2087 "-DLLVM_BUILD_LLVM_DYLIB=ON"
2088 "-DLLVM_LINK_LLVM_DYLIB=ON"))
2089 ((#:phases phases '%standard-phases)
2090 `(modify-phases ,phases
2091 (delete 'shared-lib-workaround)
2092 (delete 'install-opt-viewer))))))))
2093
2094 (define clang-cling-runtime
2095 (let ((base clang-runtime-9))
2096 (package/inherit base
2097 (name "clang-cling-runtime")
2098 (arguments
2099 (substitute-keyword-arguments (package-arguments base)
2100 ((#:phases phases '%standard-phases)
2101 `(modify-phases ,phases
2102 (add-after 'install 'delete-static-libraries
2103 ;; This reduces the size from 22 MiB to 4 MiB.
2104 (lambda* (#:key outputs #:allow-other-keys)
2105 (let ((out (assoc-ref outputs "out")))
2106 (for-each delete-file (find-files out "\\.a$")))))))))
2107 (inputs (modify-inputs (package-inputs base)
2108 (replace "llvm" llvm-cling))))))
2109
2110 (define clang-cling ;modified clang 9 with ~ 60 patches for cling
2111 (let ((base clang-9))
2112 (package/inherit base
2113 (name "clang-cling")
2114 (source
2115 (origin
2116 (inherit (package-source base))
2117 (method git-fetch)
2118 (uri (git-reference
2119 (url "http://root.cern/git/clang.git")
2120 (commit (string-append "cling-v" %cling-version))))
2121 (file-name (git-file-name "clang-cling" %cling-version))
2122 (sha256
2123 (base32
2124 "128mxkwghss6589wvm6amzv183aq88rdrnfxjiyjcji5hx84vpby"))))
2125 (arguments
2126 (substitute-keyword-arguments (package-arguments base)
2127 ((#:phases phases '%standard-phases)
2128 `(modify-phases ,phases
2129 (add-after 'install 'delete-static-libraries
2130 ;; This reduces the size by half, from 220 MiB to 112 MiB.
2131 (lambda* (#:key outputs #:allow-other-keys)
2132 (let ((out (assoc-ref outputs "out")))
2133 (for-each delete-file (find-files out "\\.a$")))))))))
2134 (propagated-inputs
2135 (modify-inputs (package-propagated-inputs base)
2136 (replace "llvm" llvm-cling)
2137 (replace "clang-runtime" clang-cling-runtime))))))
2138
2139 (define-public cling
2140 ;; The tagged v0.9 release doesn't build, so use the latest commit.
2141 (let ((commit "d78d1a03fedfd2bf6d2b6ff295aca576d98940df")
2142 (revision "1")
2143 (version* "0.9"))
2144 (package
2145 (name "cling")
2146 (version (git-version version* revision commit))
2147 (source (origin
2148 (method git-fetch)
2149 (uri (git-reference
2150 (url "http://root.cern/git/cling.git")
2151 (commit commit)))
2152 (file-name (git-file-name name version))
2153 (sha256
2154 (base32
2155 "0lsbxv21b4qw11xkw9iipdpca64jjwwqxm0qf5v2cgdlibf8m8n9"))
2156 ;; Patch submitted upstream here:
2157 ;; https://github.com/root-project/cling/pull/433.
2158 (patches (search-patches "cling-use-shared-library.patch"))))
2159 (build-system cmake-build-system)
2160 (arguments
2161 (list
2162 #:build-type "Release" ;keep the build as lean as possible
2163 #:tests? #f ;FIXME: 78 tests fail (out of ~200)
2164 #:test-target "check-cling"
2165 #:configure-flags
2166 #~(list (string-append "-DCLING_CXX_PATH="
2167 (search-input-file %build-inputs "bin/g++"))
2168 ;; XXX: The AddLLVM.cmake module expects LLVM_EXTERNAL_LIT to
2169 ;; be a Python script, not a shell executable.
2170 (string-append "-DLLVM_EXTERNAL_LIT="
2171 (search-input-file %build-inputs "bin/.lit-real")))
2172 #:phases
2173 #~(modify-phases %standard-phases
2174 (add-after 'unpack 'set-version
2175 (lambda _
2176 (make-file-writable "VERSION")
2177 (call-with-output-file "VERSION"
2178 (lambda (port)
2179 (format port "~a~%" #$version)))))
2180 (add-after 'unpack 'patch-paths
2181 (lambda* (#:key inputs #:allow-other-keys)
2182 (substitute* "lib/Interpreter/CIFactory.cpp"
2183 (("\bsed\b")
2184 (which "sed"))
2185 ;; This ensures that the default C++ library used by Cling is
2186 ;; that of the compiler that was used to build it, rather
2187 ;; than that of whatever g++ happens to be on PATH.
2188 (("ReadCompilerIncludePaths\\(CLING_CXX_RLTV")
2189 (format #f "ReadCompilerIncludePaths(~s"
2190 (search-input-file inputs "bin/g++")))
2191 ;; Cling uses libclang's CompilerInvocation::GetResourcesPath
2192 ;; to resolve Clang's library prefix, but this fails on Guix
2193 ;; because it is relative to the output of cling rather than
2194 ;; clang (see:
2195 ;; https://github.com/root-project/cling/issues/434). Fully
2196 ;; shortcut the logic in this method to return the correct
2197 ;; static location.
2198 (("static std::string getResourceDir.*" all)
2199 (string-append all
2200 " return std::string(\""
2201 #$(this-package-input "clang-cling")
2202 "/lib/clang/" #$(package-version clang-cling)
2203 "\");")))
2204 ;; Check for the 'lit' command for the tests, not 'lit.py'
2205 ;; (see: https://github.com/root-project/cling/issues/432).
2206 (substitute* "CMakeLists.txt"
2207 (("lit.py")
2208 "lit"))))
2209 (add-after 'unpack 'adjust-lit.cfg
2210 ;; See: https://github.com/root-project/cling/issues/435.
2211 (lambda _
2212 (substitute* "test/lit.cfg"
2213 (("config.llvm_tools_dir \\+ '")
2214 "config.cling_obj_root + '/bin"))))
2215 (add-after 'install 'delete-static-libraries
2216 ;; This reduces the size from 17 MiB to 5.4 MiB.
2217 (lambda _
2218 (for-each delete-file (find-files #$output "\\.a$")))))))
2219 (native-inputs
2220 (list python python-lit))
2221 (inputs
2222 (list clang-cling llvm-cling))
2223 (home-page "https://root.cern/cling/")
2224 (synopsis "Interactive C++ interpreter")
2225 (description "Cling is an interactive C++17 standard compliant
2226 interpreter, built on top of LLVM and Clang. Cling can be used as a
2227 read-eval-print loop (REPL) to assist with rapid application development.
2228 Here's how to print @samp{\"Hello World!\"} using @command{cling}:
2229
2230 @example
2231 cling '#include <stdio.h>' 'printf(\"Hello World!\\n\");'
2232 @end example")
2233 (license license:lgpl2.1+)))) ;for the combined work