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>
29 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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
82 (define* (system->llvm-target #:optional
83 (system (or (and=> (%current-target-system)
84 gnu-triplet->nix-system)
86 "Return the LLVM target name that corresponds to SYSTEM, a system type such
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)
95 (error "LLVM target for system is unknown" system)))))
96 (matches ("aarch64" => "AArch64")
98 ("mips64el" => "Mips")
99 ("powerpc" => "PowerPC")
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"))
111 (define %llvm-release-monitoring-url
112 "https://github.com/llvm/llvm-project/releases")
114 (define* (clang-runtime-from-llvm llvm
119 (name "clang-runtime")
120 (version (package-version llvm))
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))
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)
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"))
148 (filter-map (lambda (input)
151 (and (not (member name filters))
154 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
158 (home-page "https://compiler-rt.llvm.org")
159 (synopsis "Runtime library for Clang/LLVM")
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")))
169 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
170 (supported-systems (delete "mips64el-linux" %supported-systems))))
172 (define* (clang-from-llvm llvm clang-runtime
174 #:key (patches '()) tools-extra
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."
185 (version (package-version llvm))
190 (uri (llvm-uri (if (version>=? version "9.0.1")
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
200 (build-system cmake-build-system)
201 (native-inputs (package-native-inputs llvm))
203 `(("libxml2" ,libxml2)
204 ("gcc-lib" ,gcc "lib")
205 ,@(package-inputs llvm)
207 `(("clang-tools-extra" ,tools-extra))
210 (list llvm clang-runtime))
213 (list "-DCLANG_INCLUDE_TESTS=True"
215 ;; Find libgcc_s, crtbegin.o, and crtend.o.
216 (string-append "-DGCC_INSTALL_PREFIX="
217 (assoc-ref %build-inputs "gcc-lib"))
219 ;; Use a sane default include directory.
220 (string-append "-DC_INCLUDE_DIRS="
221 (assoc-ref %build-inputs "libc")
223 ,@(if (target-riscv64?)
224 (list "-DLIBOMP_LIBFLAGS=-latomic"
225 "-DCMAKE_SHARED_LINKER_FLAGS=-latomic")
228 ,@(if (target-riscv64?)
229 `(#:make-flags '("LDFLAGS=-latomic"))
232 ;; Don't use '-g' during the build to save space.
233 #:build-type "Release"
235 #:phases (modify-phases %standard-phases
237 `((add-after 'unpack 'add-tools-extra
238 (lambda* (#:key inputs #:allow-other-keys)
239 ;; Unpack the 'clang-tools-extra' tarball under
241 (let ((extra (assoc-ref inputs
242 "clang-tools-extra")))
243 (invoke "tar" "xf" extra)
244 (rename-file ,(string-append
246 (string-delete #\- (package-version llvm))
249 ;; Build and link to shared libraries.
250 (substitute* "cmake/modules/AddClang.cmake"
251 (("BUILD_SHARED_LIBS") "True"))
254 (add-after 'unpack 'add-missing-triplets
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\", "
265 (("\"arm-linux-gnueabihf\"," all)
267 " \"arm-unknown-linux-gnueabihf\","))
268 (("\"i686-pc-linux-gnu\"," all)
269 (string-append "\"i686-unknown-linux-gnu\", "
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")))
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 "\"")))
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"))
290 ;; Make clang look for libstdc++ in the right
292 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
294 "LibStdCXXIncludePathCandidates[] = { \"" gcc
297 ;; Make sure libc's libdir is on the search path, to
298 ;; allow crt1.o & co. to be found.
300 (string-append libc "/lib")))))
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")
307 ,(glibc-dynamic-linker))))
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 "\"")))))
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"
323 (string-append libc "/lib"))))))
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.
341 "/lib/cmake/clang/ClangTargets-release.cmake")
342 (("list\\(APPEND _IMPORT_CHECK_TARGETS.*" all)
343 (string-append "# Disabled by Guix.\n#" all)))
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/"
352 (compiler-rt (assoc-ref inputs "clang-runtime"))
353 (file-name ,(if (version>=? version "13")
355 "cfi_blacklist.txt"))
356 ;; The location varies between Clang versions.
360 (string-append compiler-rt "/" file-name))
361 (string-append compiler-rt "/" file-name))
362 (else (string-append compiler-rt
363 "/share/" file-name)))))
365 ;; Symlink the ignorelist to where Clang expects
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)))))))
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
382 (when (file-exists? 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")
393 (rename-file "bash-autocomplete.sh"
394 (string-append compl-dir "/clang")))))
397 ;; Clang supports the same environment variables as GCC.
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")))))
412 (home-page "https://clang.llvm.org")
413 (synopsis "C language family frontend for LLVM")
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
424 (define (clang-properties version)
425 "Return package properties for Clang VERSION."
426 `((compiler-cpu-architectures
428 ;; This list was obtained by running:
430 ;; guix shell clang -- llc -march=x86-64 -mattr=help
432 ;; filtered from uninteresting entries such as "i686" and "pentium".
433 ,@(if (version>=? version "10.0") ;TODO: refine
489 (define (make-clang-toolchain clang libomp)
491 (name (string-append (package-name clang) "-toolchain"))
492 (version (package-version clang))
494 (build-system trivial-build-system)
496 '(#:modules ((guix build union))
498 (use-modules (ice-9 match)
502 (let ((out (assoc-ref %outputs "out")))
505 (((names . directories) ...)
506 (union-build out directories)))
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++"))
514 (union-build (assoc-ref %outputs "debug")
515 (list (assoc-ref %build-inputs
517 (union-build (assoc-ref %outputs "static")
518 (list (assoc-ref %build-inputs
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))
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'
543 ("libc-debug" ,glibc "debug")
544 ("libc-static" ,glibc "static")))))
546 (define %llvm-monorepo-hashes
547 '(("14.0.6" . "14f8nlvnmdkp9a9a79wv67jbmafvabczhah8rwnqrgd5g3hfxxxx")))
549 (define %llvm-patches
550 '(("14.0.6" . ("clang-14.0-libc-search-path.patch"))))
552 (define (llvm-monorepo version)
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)))))
562 (define-public llvm-14
566 (source (llvm-monorepo version))
567 (build-system cmake-build-system)
568 (outputs '("out" "opt-viewer"))
570 `(("python" ,python-wrapper)
575 (list zlib)) ;to use output from llvm-config
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
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)))
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"
602 #~(modify-phases %standard-phases
603 (add-after 'unpack 'change-directory
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")
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)))))
627 (define-public clang-runtime-14
628 (let ((template (clang-runtime-from-llvm llvm-14)))
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
637 (chdir "compiler-rt")))))))
639 `(;; FIXME: libfuzzer fails to build with GCC 10.
641 ,@(package-native-inputs template))))))
643 (define-public clang-14
645 (clang-from-llvm llvm-14 clang-runtime-14
649 (uri (llvm-uri "clang-tools-extra"
650 (package-version llvm-14)))
653 "0rhq4wkmvr369nkk059skzzw7jx6qhzqhmiwmqg4sp66avzviwvw"))))))
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
662 (chdir "clang"))))))))))
664 (define-public libomp-14
667 (version (package-version llvm-14))
670 (uri (llvm-uri "openmp" version))
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.)
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"
685 #~(modify-phases %standard-phases
686 (add-after 'unpack 'chdir-to-source-and-install-license
688 (chdir #$(string-append "../openmp-" version ".src"))
689 (install-file "LICENSE.TXT"
690 (string-append #$output "/share/doc")))))))
692 (list clang-14 llvm-14 perl pkg-config python))
694 (list `(,hwloc "lib")))
695 (home-page "https://openmp.llvm.org")
696 (synopsis "OpenMP run-time support library")
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)))
706 (define-public clang-toolchain-14
707 (make-clang-toolchain clang-14 libomp-14))
709 (define-public llvm-13
716 (uri (llvm-uri "llvm" version))
719 "0d681xiixmx9inwvz14vi3xsznrcryk06a8rvk9cljiq5kc80szc"))))
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)))))
727 (define-public clang-runtime-13
728 (clang-runtime-from-llvm
730 "1z2xr9nn4mgc3hn9ark2k5y4wznpk47xppkp63bcbagr6589acvv"))
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")
739 (uri (llvm-uri "clang-tools-extra"
740 (package-version llvm-13)))
743 "1l4jjdqfl9hrh0fwzv27hc263zc6x61h09vs4ni3yla8i1cwhayc")))))
745 (define-public libomp-13
748 (version (package-version llvm-13))
751 (uri (llvm-uri "openmp" version))
754 "0kvbr4j6ldpssiv7chgqra5y77n7jwbyxlwcl7z32v31f49jcybb"))
755 (file-name (string-append "libomp-" version ".tar.xz"))))
757 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
758 "-DOPENMP_TEST_C_COMPILER=clang"
759 "-DOPENMP_TEST_CXX_COMPILER=clang++"
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"))
766 (modify-inputs (package-native-inputs libomp-14)
767 (replace "clang" clang-13)
768 (replace "llvm" llvm-13)))))
770 (define-public clang-toolchain-13
771 (make-clang-toolchain clang-13 libomp-13))
773 (define-public llvm-12
780 (uri (llvm-uri "llvm" version))
783 "1pzx9zrmd7r3481sbhwvkms68fwhffpp4mmz45dgrkjpyl2q96kx"))))
785 ;; TODO(core-updates): Unconditionally use quasiquote
787 ,#~(#$(if (%current-target-system)
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
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)))
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"
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")))))
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
827 (setenv "LD_LIBRARY_PATH"
828 (string-append (getcwd) "/lib"))
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")
841 (define-public clang-runtime-12
842 (clang-runtime-from-llvm
844 "1950rg294izdwkaasi7yjrmadc9mzdd5paf0q63jjcq2m3rdbj5l"))
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")
853 (uri (llvm-uri "clang-tools-extra"
854 (package-version llvm-12)))
857 "1r9a4fdz9ci58b5z2inwvm4z4cdp6scrivnaw05dggkxz7yrwrb5")))))
859 (define-public libomp-12
862 (version (package-version llvm-12))
865 (uri (llvm-uri "openmp" version))
868 "14dh0r6h2xh747ffgnsl4z08h0ri04azi9vf79cbz7ma1r27kzk0"))
869 (file-name (string-append "libomp-" version ".tar.xz"))))
871 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
872 "-DOPENMP_TEST_C_COMPILER=clang"
873 "-DOPENMP_TEST_CXX_COMPILER=clang++")
874 #:test-target "check-libomp"))
876 (modify-inputs (package-native-inputs libomp-13)
877 (replace "clang" clang-12)
878 (replace "llvm" llvm-12)))))
880 (define-public clang-toolchain-12
881 (make-clang-toolchain clang-12 libomp-12))
883 (define-public llvm-11
890 (uri (llvm-uri "llvm" version))
893 "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))))
895 (define-public clang-runtime-11
896 (clang-runtime-from-llvm
898 "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip"))
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")
907 (uri (llvm-uri "clang-tools-extra"
908 (package-version llvm-11)))
911 "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy")))))
913 (define-public libomp-11
916 (version (package-version llvm-11))
919 (uri (llvm-uri "openmp" version))
922 "0k389d0g9zlfyzh1kpb3i5jdawzpn0hrdxzbjinpvdv7rbw4sw1d"))
923 (file-name (string-append "libomp-" version ".tar.xz"))))
925 (modify-inputs (package-native-inputs libomp-12)
926 (replace "clang" clang-11)
927 (replace "llvm" llvm-11)))))
929 (define-public clang-toolchain-11
930 (make-clang-toolchain clang-11 libomp-11))
932 (define-public llvm-10
939 (uri (llvm-uri "llvm" version))
942 "1wydhbp9kyjp5y0rc627imxgkgqiv3dfirbqil9dgpnbaw5y7n65"))))
944 `(("python" ,python-wrapper)
946 ;; In llvm-11 riscv64 support was added manually to config.guess.
947 ,@(if (target-riscv64?)
948 `(("config" ,config))
951 (define-public clang-runtime-10
952 (clang-runtime-from-llvm
954 "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr"))
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")
963 (uri (llvm-uri "clang-tools-extra"
964 (package-version llvm-10)))
967 "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh")))))
969 (define-public libomp-10
972 (version (package-version llvm-10))
975 (uri (llvm-uri "openmp" version))
978 "0i4bn84lkpm5w3qkpvwm5z6jdj8fynp7d3bcasa1xyq4is6757yi"))
979 (file-name (string-append "libomp-" version ".tar.xz"))))
981 (modify-inputs (package-native-inputs libomp-11)
982 (replace "clang" clang-10)
983 (replace "llvm" llvm-10)))))
985 (define-public clang-toolchain-10
986 (make-clang-toolchain clang-10 libomp-10))
988 (define-public llvm-9
995 (uri (llvm-uri "llvm" version))
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"))))
1004 (if (target-riscv64?)
1005 (substitute-keyword-arguments (package-arguments llvm-10)
1007 `(modify-phases ,phases
1008 (add-after 'unpack 'patch-dsymutil-link
1010 (substitute* "tools/dsymutil/CMakeLists.txt"
1011 (("endif\\(APPLE\\)")
1014 "if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES \"riscv64\")\n"
1015 " target_link_libraries(dsymutil PRIVATE atomic)\n"
1017 (package-arguments llvm-10)))))
1019 (define-public clang-runtime-9
1020 (clang-runtime-from-llvm
1022 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
1023 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
1030 (define-public libomp-9
1033 (version (package-version llvm-9))
1036 (uri (llvm-uri "openmp" version))
1039 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
1040 (file-name (string-append "libomp-" version ".tar.xz"))))
1042 (modify-inputs (package-native-inputs libomp-10)
1043 (replace "clang" clang-9)
1044 (replace "llvm" llvm-9)))))
1046 (define-public clang-toolchain-9
1047 (make-clang-toolchain clang-9 libomp-9))
1049 (define-public llvm-8
1055 (uri (llvm-uri "llvm" version))
1058 "1rvm5gqp5v8hfn17kqws3zhk94w4kxndal12bqa0y57p09nply24"))
1059 (patches (search-patches "llvm-8-fix-build-with-gcc-10.patch"))))
1060 (license license:ncsa)))
1062 (define-public clang-runtime-8
1063 (clang-runtime-from-llvm
1065 "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi"
1066 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
1073 (define-public libomp-8
1076 (version (package-version llvm-8))
1079 (uri (llvm-uri "openmp" version))
1082 "0b3jlxhqbpyd1nqkpxjfggm5d9va5qpyf7d4i5y7n4a1mlydv19y"))
1083 (file-name (string-append "libomp-" version ".tar.xz"))))
1085 (modify-inputs (package-native-inputs libomp-9)
1086 (replace "clang" clang-8)
1087 (replace "llvm" llvm-8)))
1088 (license license:ncsa)))
1090 (define-public clang-toolchain-8
1091 (make-clang-toolchain clang-8 libomp-8))
1093 (define-public llvm-7
1099 (uri (llvm-uri "llvm" version))
1102 "0r1p5didv4rkgxyvbkyz671xddg6i3dxvbpsi1xxipkla0l9pk0v"))))))
1104 (define-public clang-runtime-7
1105 (clang-runtime-from-llvm
1107 "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5"
1108 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
1115 (define-public libomp-7
1118 (version (package-version llvm-7))
1121 (uri (llvm-uri "openmp" version))
1124 "1dg53wzsci2kra8lh1y0chh60h2l8h1by93br5spzvzlxshkmrqy"))
1125 (file-name (string-append "libomp-" version ".tar.xz"))))
1127 (modify-inputs (package-native-inputs libomp-8)
1128 (replace "clang" clang-7)
1129 (replace "llvm" llvm-7)))))
1131 (define-public clang-toolchain-7
1132 (make-clang-toolchain clang-7 libomp-7))
1134 (define-public llvm-6
1140 (uri (llvm-uri "llvm" version))
1143 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
1145 (define-public clang-runtime-6
1146 (clang-runtime-from-llvm
1148 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
1149 '("clang-runtime-9-libsanitizer-mode-field.patch")))
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")))
1156 (define-public libomp-6
1159 (version (package-version llvm-6))
1162 (uri (string-append "https://releases.llvm.org/"
1163 version "/openmp-" version
1167 "0nhwfba9c351r16zgyjyfwdayr98nairky3c2f0b2lc360mwmbv6"))
1168 (file-name (string-append "libomp-" version ".tar.xz"))))
1170 (modify-inputs (package-native-inputs libomp-7)
1171 (replace "clang" clang-6)
1172 (replace "llvm" llvm-6)))))
1174 (define-public clang-toolchain-6
1175 (make-clang-toolchain clang-6 libomp-6))
1177 (define-public llvm-3.9.1
1178 (package (inherit llvm-6)
1184 (uri (llvm-uri "llvm" version))
1187 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
1190 (substitute-keyword-arguments (package-arguments llvm)
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
1199 (setenv "LD_LIBRARY_PATH"
1200 (string-append (getcwd) "/lib"))))
1201 (delete 'install-opt-viewer)))))))
1203 (define-public clang-runtime-3.9.1
1204 (clang-runtime-from-llvm
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")))
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")))
1217 (define-public llvm-3.8
1218 (package (inherit llvm-3.9.1)
1224 (uri (llvm-uri "llvm" version))
1227 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))
1228 (patches (search-patches "llvm-3.x.1-fix-build-with-gcc.patch"))))))
1230 (define-public clang-runtime-3.8
1231 (clang-runtime-from-llvm
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")))
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")))
1243 (define-public llvm-3.7
1244 (package (inherit llvm-3.8)
1249 (uri (llvm-uri "llvm" version))
1252 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))
1253 (patches (search-patches "llvm-3.x.1-fix-build-with-gcc.patch"))))))
1255 (define-public clang-runtime-3.7
1256 (clang-runtime-from-llvm
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")))
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")))
1269 (define-public llvm-3.6
1270 (package (inherit llvm-3.7)
1275 (uri (llvm-uri "llvm" version))
1277 (search-patches "llvm-3.6-fix-build-with-gcc-10.patch"))
1280 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
1282 (define-public llvm-3.5
1283 (package (inherit llvm-3.6)
1288 (uri (llvm-uri "llvm" version))
1290 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1293 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1295 (define-public clang-runtime-3.5
1296 (let ((runtime (clang-runtime-from-llvm
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
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
1309 (add-after 'unpack 'find-rpc-includes
1310 (lambda* (#:key inputs #:allow-other-keys)
1313 (search-input-directory inputs "/include/tirpc")
1314 ":" (or (getenv "CPATH") "")))
1315 (setenv "CPLUS_INCLUDE_PATH"
1317 (search-input-directory inputs "/include/tirpc")
1318 ":" (or (getenv "CPLUS_INCLUDE_PATH") "")))))))))
1320 `(("libtirpc" ,libtirpc)
1321 ("llvm" ,llvm-3.5))))))
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")))
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)
1335 (define-public llvm-for-rocm
1337 ;; Based on LLVM 14 as of v5.0.0
1339 (name "llvm-for-rocm")
1340 (version "5.1.3") ;this must match '%rocm-version'
1344 (url "https://github.com/RadeonOpenCompute/llvm-project.git")
1345 (commit (string-append "rocm-" version))))
1346 (file-name (git-file-name name version))
1349 "0j6ydfkwrxwskgnhxc3cmry42n5faqbnwf2747qgf7lz5id8h8g5"))
1351 (search-patches "llvm-roc-5.0.0-linkdl.patch"
1352 "llvm-roc-4.0.0-remove-isystem-usr-include.patch"))))
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)))))
1367 (define-public libunwind-headers
1369 (name "libunwind-headers")
1373 (uri (llvm-uri "libunwind" version))
1376 "1qb5ickp7qims5q7sxacj3fwq1kklvnl94k3v9hpl5qn284iky1n"))))
1377 (build-system cmake-build-system)
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")))
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")
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
1395 (define-public lld-14
1399 (source (llvm-monorepo version))
1400 (build-system cmake-build-system)
1404 '(#:build-type "Release"
1405 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
1408 #:phases (modify-phases %standard-phases
1409 (add-after 'unpack 'change-directory
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
1418 (define-public lld-13
1424 (uri (llvm-uri "lld" version))
1427 "1yscckcszfr234k4svhybdbsnz6w65x8pldl6c2nhyxzx12zfsk6"))))
1429 ;; Note: check <https://bugs.llvm.org/show_bug.cgi?id=49228> to see
1430 ;; whether this is still necessary.
1431 (list libunwind-headers))
1435 '(#:build-type "Release"
1436 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
1439 (properties `((release-monitoring-url . ,%llvm-release-monitoring-url)))))
1441 (define-public lld-12
1447 (uri (llvm-uri "lld" version))
1450 "0qg3fgc7wj34hdkqn21y03zcmsdd01szhhm1hfki63iifrm3y2v9"))))
1451 (inputs (modify-inputs (package-inputs lld)
1452 (replace "llvm" llvm-12)))))
1454 (define-public lld lld-14)
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
1460 (name (if lld-as-ld? "lld-as-ld-wrapper" "lld-wrapper"))
1463 (build-system trivial-build-system)
1464 (inputs (list (make-ld-wrapper "ld.lld-wrapper" #:binutils lld
1466 (make-ld-wrapper "lld-wrapper" #:binutils lld #:linker
1470 #~(let ((ld.lld (string-append #$(this-package-input
1473 (lld (string-append #$(this-package-input "lld-wrapper")
1476 (mkdir (string-append #$output "/bin"))
1477 (symlink ld.lld (string-append #$output "/bin/ld.lld"))
1478 (symlink lld (string-append #$output "/bin/lld"))
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+)))
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))
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))
1500 (source (llvm-monorepo version))
1501 (build-system cmake-build-system)
1504 #:configure-flags #~(list "-DOPENMP_TEST_CXX_COMPILER=clang++")
1506 #~(modify-phases %standard-phases
1507 (add-after 'unpack 'chdir-to-source
1511 (list pkg-config swig))
1515 ;; Optional (but recommended) inputs.
1522 (home-page "https://lldb.llvm.org/")
1523 (synopsis "Low level debugger")
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
1530 (define-public libcxx
1537 (uri (llvm-uri "libcxx" version))
1540 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
1541 (build-system cmake-build-system)
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")
1556 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
1557 (getenv "CPLUS_INCLUDE_PATH"))
1561 (home-page "https://libcxx.llvm.org")
1562 (synopsis "C++ standard library")
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)))
1569 ;; Libcxx files specifically used by PySide2.
1570 (define-public libcxx-6
1573 (version (package-version llvm-6))
1576 (inherit (package-source libcxx))
1577 (uri (llvm-uri "libcxx" version))
1580 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
1582 (list clang-6 llvm-6))))
1584 (define-public libcxxabi-6
1592 (url "https://github.com/llvm/llvm-project")
1593 (commit (string-append "llvmorg-" version))))
1594 (file-name (git-file-name name version))
1597 "0ki6796b5z08kh3a3rbysr5wwb2dkl6wal5dzd03i4li5xfkvx1g"))))
1598 (build-system cmake-build-system)
1601 (list (string-append "-DLIBCXXABI_LIBCXX_INCLUDES="
1602 (assoc-ref %build-inputs "libcxx")
1604 "-DCMAKE_C_COMPILER=clang"
1605 "-DCMAKE_CXX_COMPILER=clang++")
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"
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")
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)))))))
1633 (list clang-6 llvm-6 libcxx-6))
1634 (home-page "https://libcxxabi.llvm.org")
1635 (synopsis "C++ standard library support")
1637 "This package provides an implementation of low level support for a
1638 standard C++ library.")
1639 (license license:expat)))
1641 (define-public libcxx+libcxxabi-6
1644 (name "libcxx+libcxxabi")
1645 (version (package-version libcxx-6))
1648 (list "-DLIBCXX_CXX_ABI=libcxxabi"
1649 (string-append "-DLIBCXX_CXX_ABI_INCLUDE_PATHS="
1650 (assoc-ref %build-inputs "libcxxabi")
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"
1661 (delete (string-append gcc "/include/c++")
1662 (string-split (getenv "CPLUS_INCLUDE_PATH")
1666 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
1667 (getenv "CPLUS_INCLUDE_PATH"))))))))
1669 (list clang-6 llvm-6 libcxxabi-6))))
1671 (define-public libclc
1679 (url "https://github.com/llvm/llvm-project")
1680 (commit (string-append "llvmorg-" version))))
1681 (file-name (git-file-name name version))
1684 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
1685 (build-system cmake-build-system)
1688 (list (string-append "-DLLVM_CLANG="
1689 (assoc-ref %build-inputs "clang")
1691 (string-append "-DPYTHON="
1692 (assoc-ref %build-inputs "python")
1695 (modify-phases %standard-phases
1696 (add-after 'unpack 'chdir
1697 (lambda _ (chdir "libclc") #t)))))
1699 (list clang-9 llvm-9 python))
1700 (home-page "https://libclc.llvm.org")
1701 (synopsis "Libraries for the OpenCL programming language")
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)))
1708 (define-public python-llvmlite
1710 (name "python-llvmlite")
1715 (uri (pypi-uri "llvmlite" version))
1718 "0p4nyic9rm7s2fm3m3wpkh568594p9q9nfyjkqxny49vrxn1d7d9"))))
1719 (build-system python-build-system)
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
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="
1752 (let* ((patches-commit
1753 "a4a19e8af2c5ef9b9901f20193e4be070726da97")
1754 (patch-uri (lambda (name)
1756 "https://raw.githubusercontent.com/numba/"
1761 (patch-origin (lambda (name hash)
1762 (origin (method url-fetch)
1763 (uri (patch-uri name))
1764 (sha256 (base32 hash)))))
1765 (arch-independent-patches
1767 "partial-testing.patch"
1768 "0g3nkci87knvmn7piqhmh4bcc65ff8r921cvfcibyiv65klv3syg")
1770 "0001-Revert-Limit-size-of-non-GlobalValue-name.patch"
1771 "0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295"))))
1776 (inherit (package-source llvm-11))
1777 (patches (if (string=? "aarch64-linux" (%current-system))
1779 "intel-D47188-svml-VF_LLVM9.patch"
1780 "0gnnlfxr8p1a7ls93hzcpfqpa8r0icypfwj8l9cmkslq5sz8p64r")
1781 ,@arch-independent-patches
1782 ,@(origin-patches (package-source llvm-11)))
1784 "intel-D47188-svml-VF.patch"
1785 "0gnnlfxr8p1a7ls93hzcpfqpa8r0icypfwj8l9cmkslq5sz8p64r")
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")
1794 "This package provides a Python binding to LLVM for use in Numba.")
1795 (license license:bsd-3)))
1797 (define-public (clang-python-bindings clang)
1798 "Return a package for the Python bindings of CLANG."
1801 (name "python-clang")
1802 (build-system python-build-system)
1805 '(#:phases (modify-phases %standard-phases
1806 (add-before 'build 'change-directory
1808 (chdir "bindings/python")))
1809 (add-before 'build 'create-setup-py
1811 ;; Generate a basic "setup.py", enough so it can be
1812 ;; built and installed.
1813 (with-output-to-file "setup.py"
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")))
1827 (define-public python-clang-10
1828 (clang-python-bindings clang-10))
1830 (define-public python-clang-11
1831 (clang-python-bindings clang-11))
1833 (define-public python-clang-12
1834 (clang-python-bindings clang-12))
1836 (define-public python-clang-13
1837 (clang-python-bindings clang-13))
1839 (define-public emacs-clang-format
1842 (name "emacs-clang-format")
1843 (build-system emacs-build-system)
1846 (propagated-inputs '())
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}.")))
1863 (define-public emacs-clang-rename
1866 (name "emacs-clang-rename")
1867 (build-system emacs-build-system)
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}.")))
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.
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"))
1907 (modify-phases %standard-phases
1910 (invoke "make" "ocaml_all")))
1913 (invoke "cmake" "-P" "bindings/ocaml/cmake_install.cmake"))))))
1917 (list ocaml ocaml-findlib ocaml-ounit python))
1919 (list ocaml-integers ocaml-ctypes))
1920 (synopsis "OCaml bindings to LLVM")
1921 (description "This package contains the OCaml bindings distributed with
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))
1929 (define-public llvm-julia
1933 (properties `((hidden? . #t)
1934 ,@(package-properties llvm-11)))
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
1944 (julia-patch name hash)))
1946 '("llvm-D27629-AArch64-large_model_6.0.1"
1947 "1qrshmlqvnasdyc158vfn3hnbigqph3lsq7acb9w8lwkpnnm2j4z")
1948 '("llvm8-D34078-vectorize-fdiv"
1949 "19spqc3xsazn1xs9gpcgv9ldadfkv49rmc5khl7sf1dlmhgi4602")
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")
1965 "1gsdwmgmpbignvqyxcnlprj899259p3dvdznlncd84ss445qgq3j")
1967 "0nks9sbk7p0r5gyr0idrmm93a5fmdai8kihz9532dx4zhcvvqbjc")
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"))))
2004 (substitute-keyword-arguments (package-arguments llvm-11)
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)
2020 ;; Build a native compiler and the NVPTX backend (NVIDIA) since
2021 ;; Julia insists on it, nothing more. This reduces build times and
2023 ,(string-append "-DLLVM_TARGETS_TO_BUILD=" (system->llvm-target))
2024 "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=NVPTX"
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"))))
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")))))))
2052 (define %cling-version "0.9")
2054 (define llvm-cling ;LLVM 9 with approximately 10 patches for cling
2055 (let ((base llvm-9))
2056 (package/inherit base
2060 (inherit (package-source base))
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))
2068 "0y3iwv3c9152kybmdrwvadggjs163r25h7rmlxzr3hfpr463pnwf"))
2069 (modules '((guix build utils)))
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"))))))
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))))))))
2094 (define clang-cling-runtime
2095 (let ((base clang-runtime-9))
2096 (package/inherit base
2097 (name "clang-cling-runtime")
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))))))
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")
2116 (inherit (package-source base))
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))
2124 "128mxkwghss6589wvm6amzv183aq88rdrnfxjiyjcji5hx84vpby"))))
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$")))))))))
2135 (modify-inputs (package-propagated-inputs base)
2136 (replace "llvm" llvm-cling)
2137 (replace "clang-runtime" clang-cling-runtime))))))
2139 (define-public cling
2140 ;; The tagged v0.9 release doesn't build, so use the latest commit.
2141 (let ((commit "d78d1a03fedfd2bf6d2b6ff295aca576d98940df")
2146 (version (git-version version* revision commit))
2150 (url "http://root.cern/git/cling.git")
2152 (file-name (git-file-name name version))
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)
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"
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")))
2173 #~(modify-phases %standard-phases
2174 (add-after 'unpack 'set-version
2176 (make-file-writable "VERSION")
2177 (call-with-output-file "VERSION"
2179 (format port "~a~%" #$version)))))
2180 (add-after 'unpack 'patch-paths
2181 (lambda* (#:key inputs #:allow-other-keys)
2182 (substitute* "lib/Interpreter/CIFactory.cpp"
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
2195 ;; https://github.com/root-project/cling/issues/434). Fully
2196 ;; shortcut the logic in this method to return the correct
2198 (("static std::string getResourceDir.*" all)
2200 " return std::string(\""
2201 #$(this-package-input "clang-cling")
2202 "/lib/clang/" #$(package-version clang-cling)
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"
2209 (add-after 'unpack 'adjust-lit.cfg
2210 ;; See: https://github.com/root-project/cling/issues/435.
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.
2218 (for-each delete-file (find-files #$output "\\.a$")))))))
2220 (list python python-lit))
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}:
2231 cling '#include <stdio.h>' 'printf(\"Hello World!\\n\");'
2233 (license license:lgpl2.1+)))) ;for the combined work