summaryrefslogtreecommitdiff
path: root/gnu/packages/llvm.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/llvm.scm')
-rw-r--r--gnu/packages/llvm.scm495
1 files changed, 441 insertions, 54 deletions
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 617dfb6974..6e234035e4 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -16,9 +16,12 @@
;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
-;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2021 Lars-Dominik Braun <lars@6xq.net>
+;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -39,6 +42,7 @@
#:use-module (guix packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix download)
+ #:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix memoization)
#:use-module (guix utils)
@@ -51,7 +55,9 @@
#:use-module (gnu packages base)
#:use-module (gnu packages gcc)
#:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
+ #:use-module (gnu packages check) ;python-lit
#:use-module (gnu packages compression)
+ #:use-module (gnu packages julia) ;julia-patch
#:use-module (gnu packages libedit)
#:use-module (gnu packages libffi)
#:use-module (gnu packages lua)
@@ -64,7 +70,10 @@
#:use-module (gnu packages python)
#:use-module (gnu packages swig)
#:use-module (gnu packages xml)
- #:export (system->llvm-target))
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
+ #:export (make-lld-wrapper
+ system->llvm-target))
(define* (system->llvm-target #:optional
(system (or (and=> (%current-target-system)
@@ -492,20 +501,37 @@ output), and Binutils.")
(build-system cmake-build-system)
(outputs '("out" "opt-viewer"))
(native-inputs
- `(("python" ,python)
+ `(("python" ,python-wrapper)
("perl" ,perl)))
(inputs
`(("libffi" ,libffi)))
(propagated-inputs
`(("zlib" ,zlib))) ;to use output from llvm-config
(arguments
- `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
- "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
- "-DBUILD_SHARED_LIBS:BOOL=TRUE"
- "-DLLVM_ENABLE_FFI:BOOL=TRUE"
- "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
- "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
-
+ ;; TODO(core-updates): Unconditionally use quasiquote
+ `(#:configure-flags
+ ,#~(#$(if (%current-target-system)
+ #~quasiquote
+ #~quote)
+ ;; These options are required for cross-compiling LLVM according to
+ ;; https://llvm.org/docs/HowToCrossCompileLLVM.html.
+ (#$@(if (%current-target-system)
+ #~(,(string-append "-DLLVM_TABLEGEN="
+ #+(file-append this-package
+ "/bin/llvm-tblgen"))
+ #$(string-append "-DLLVM_DEFAULT_TARGET_TRIPLE="
+ (%current-target-system))
+ #$(string-append "-DLLVM_TARGET_ARCH="
+ (system->llvm-target))
+ #$(string-append "-DLLVM_TARGETS_TO_BUILD="
+ (system->llvm-target)))
+ #~())
+ "-DCMAKE_SKIP_BUILD_RPATH=FALSE"
+ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
+ "-DBUILD_SHARED_LIBS:BOOL=TRUE"
+ "-DLLVM_ENABLE_FFI:BOOL=TRUE"
+ "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
+ "-DLLVM_INSTALL_UTILS=ON")) ; Needed for rustc.
;; Don't use '-g' during the build, to save space.
#:build-type "Release"
#:phases
@@ -571,11 +597,7 @@ of programming tools as well as libraries with equivalent functionality.")
(uri (llvm-uri "llvm" version))
(sha256
(base32
- "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))
- (native-inputs
- `(;; TODO: Switch to Python 3 in the next rebuild cycle.
- ("python" ,python-2)
- ("perl" ,perl)))))
+ "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))))
(define-public clang-runtime-11
(clang-runtime-from-llvm
@@ -601,23 +623,23 @@ of programming tools as well as libraries with equivalent functionality.")
(define-public llvm-10
(package
(inherit llvm-11)
- (version "10.0.0")
+ (version "10.0.1")
(source
(origin
(method url-fetch)
(uri (llvm-uri "llvm" version))
(sha256
(base32
- "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))))
+ "1wydhbp9kyjp5y0rc627imxgkgqiv3dfirbqil9dgpnbaw5y7n65"))))))
(define-public clang-runtime-10
(clang-runtime-from-llvm
llvm-10
- "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
+ "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr"))
(define-public clang-10
(clang-from-llvm llvm-10 clang-runtime-10
- "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
+ "091bvcny2lh32zy8f3m9viayyhb2zannrndni7325rl85cwgr6pr"
#:patches '("clang-10.0-libc-search-path.patch")
#:tools-extra
(origin
@@ -626,7 +648,7 @@ of programming tools as well as libraries with equivalent functionality.")
(package-version llvm-10)))
(sha256
(base32
- "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
+ "06n1yp638rh24xdxv9v2df0qajxbjz4w59b7dd4ky36drwmpi4yh")))))
(define-public clang-toolchain-10
(make-clang-toolchain clang-10))
@@ -825,6 +847,8 @@ of programming tools as well as libraries with equivalent functionality.")
(origin
(method url-fetch)
(uri (llvm-uri "llvm" version))
+ (patches
+ (search-patches "llvm-3.6-fix-build-with-gcc-10.patch"))
(sha256
(base32
"153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
@@ -859,14 +883,13 @@ of programming tools as well as libraries with equivalent functionality.")
(add-after 'unpack 'find-rpc-includes
(lambda* (#:key inputs #:allow-other-keys)
(setenv "CPATH"
- (string-append (assoc-ref inputs "libtirpc")
- "/include/tirpc/:"
- (or (getenv "CPATH") "")))
+ (string-append
+ (search-input-directory inputs "/include/tirpc")
+ ":" (or (getenv "CPATH") "")))
(setenv "CPLUS_INCLUDE_PATH"
- (string-append (assoc-ref inputs "libtirpc")
- "/include/tirpc/:"
- (or (getenv "CPLUS_INCLUDE_PATH") "")))
- #t))))))
+ (string-append
+ (search-input-directory inputs "/include/tirpc")
+ ":" (or (getenv "CPLUS_INCLUDE_PATH") "")))))))))
(inputs
`(("libtirpc" ,libtirpc)
("llvm" ,llvm-3.5))))))
@@ -975,6 +998,48 @@ of programming tools as well as libraries with equivalent functionality.")
components which highly leverage existing libraries in the larger LLVM Project.")
(license license:asl2.0))) ; With LLVM exception
+(define* (make-lld-wrapper lld #:key lld-as-ld?)
+ "Return a LLD wrapper. When LLD-AS-LD? is true, create a 'ld' symlink that
+points to 'lld'."
+ (package
+ (name (if lld-as-ld? "lld-as-ld-wrapper" "lld-wrapper"))
+ (version "0")
+ (source #f)
+ (build-system trivial-build-system)
+ (inputs `(("ld.lld-wrapper" ,(make-ld-wrapper "ld.lld-wrapper"
+ #:binutils lld
+ #:linker "ld.lld"))
+ ("lld-wrapper" ,(make-ld-wrapper "lld-wrapper"
+ #:binutils lld
+ #:linker "lld"))))
+ (arguments
+ (list #:builder
+ #~(let ((ld.lld (string-append #$(this-package-input
+ "ld.lld-wrapper")
+ "/bin/ld.lld"))
+ (lld (string-append #$(this-package-input "lld-wrapper")
+ "/bin/lld")))
+ (mkdir #$output)
+ (mkdir (string-append #$output "/bin"))
+ (symlink ld.lld (string-append #$output "/bin/ld.lld"))
+ (symlink lld (string-append #$output "/bin/lld"))
+ (when #$lld-as-ld?
+ (symlink ld.lld (string-append #$output "/bin/ld"))))))
+ (synopsis "LLD linker wrapper")
+ (description "This is a linker wrapper for LLD; like @code{ld-wrapper}, it
+wraps the linker to add any missing @code{-rpath} flags, and to detect any
+misuse of libraries outside of the store.")
+ (home-page "https://www.gnu.org/software/guix/")
+ (license license:gpl3+)))
+
+;;; A LLD wrapper suitable to use with -fuse-ld and GCC or with Clang.
+(define-public lld-wrapper
+ (make-lld-wrapper lld))
+
+;;; A LLD wrapper that can be used as a (near) drop-in replacement to GNU ld.
+(define-public lld-as-ld-wrapper
+ (make-lld-wrapper lld #:lld-as-ld? #t))
+
(define-public lldb
(package
(name "lldb")
@@ -1232,14 +1297,14 @@ with that of libgomp, the GNU Offloading and Multi Processing Library.")
(define-public python-llvmlite
(package
(name "python-llvmlite")
- (version "0.34.0")
+ (version "0.37.0")
(source
(origin
(method url-fetch)
(uri (pypi-uri "llvmlite" version))
(sha256
(base32
- "0qqzs6h34002ig2jn31vk08q9hh5kn84lhmv4bljz3yakg8y0gph"))))
+ "05avhsvdcqh8wfpblx16qslfq3masqcbkfyn8p3c13h1rmqbi4k3"))))
(build-system python-build-system)
(arguments
`(#:phases
@@ -1258,25 +1323,22 @@ with that of libgomp, the GNU Offloading and Multi Processing Library.")
"binding/libllvmlite.so")))
(substitute* "llvmlite/binding/ffi.py"
(("_lib_name = get_library_name\\(\\)")
- (format #f "_lib_name = ~s" libllvmlite.so)))
- #t)))
+ (format #f "_lib_name = ~s" libllvmlite.so))))))
(add-after 'unpack 'skip-failing-tests
(lambda _
(substitute* "llvmlite/tests/test_binding.py"
((" def test_libm\\(self\\).*" all)
- (string-append " @unittest.skip('Fails on Guix')\n" all)))
- #t))
+ (string-append " @unittest.skip('Fails on Guix')\n" all)))))
(add-before 'build 'set-compiler/linker-flags
(lambda* (#:key inputs #:allow-other-keys)
(let ((llvm (assoc-ref inputs "llvm")))
;; Refer to ffi/Makefile.linux.
(setenv "CPPFLAGS" "-fPIC")
(setenv "LDFLAGS" (string-append "-Wl,-rpath="
- llvm "/lib"))
- #t))))))
+ llvm "/lib"))))))))
(inputs
`(("llvm"
- ,(let* ((patches-commit "061ab39e1d4591f3aa842458252a19ad01858167")
+ ,(let* ((patches-commit "a4a19e8af2c5ef9b9901f20193e4be070726da97")
(patch-uri (lambda (name)
(string-append
"https://raw.githubusercontent.com/numba/"
@@ -1291,36 +1353,47 @@ with that of libgomp, the GNU Offloading and Multi Processing Library.")
(list
(patch-origin
"partial-testing.patch"
- "1cwy4jsmijd838q0bylxl77vrwrb7ksijfly5062ay32303jmj86")
+ "0g3nkci87knvmn7piqhmh4bcc65ff8r921cvfcibyiv65klv3syg")
(patch-origin
"0001-Revert-Limit-size-of-non-GlobalValue-name.patch"
"0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295"))))
- (if (string=? "aarch64-linux" (%current-system))
- (package
- (inherit llvm-9)
- (source
- (origin
- (inherit (package-source llvm-9))
- (patches
+ (package
+ (inherit llvm-11)
+ (source
+ (origin
+ (inherit (package-source llvm-11))
+ (patches
+ (if (string=? "aarch64-linux" (%current-system))
`(,(patch-origin
"intel-D47188-svml-VF_LLVM9.patch"
- "1f9ld7wc8bn4gbvdsmk07w1rq371h42vy05rxsq9a22f57rljqbd")
+ "0gnnlfxr8p1a7ls93hzcpfqpa8r0icypfwj8l9cmkslq5sz8p64r")
,@arch-independent-patches
- ,@(origin-patches (package-source llvm-9)))))))
- (package
- (inherit llvm-10)
- (source
- (origin
- (inherit (package-source llvm-10))
- (patches
+ ,@(origin-patches (package-source llvm-11)))
`(,(patch-origin
"intel-D47188-svml-VF.patch"
- "0n46qjwfl7i12bl7wp0cyxl277axfvaaz5lxx5kdlgwjcpa582dg")
+ "0gnnlfxr8p1a7ls93hzcpfqpa8r0icypfwj8l9cmkslq5sz8p64r")
,(patch-origin
"expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch"
"0jxhjkkwwi1cy898l2n57l73ckpw0v73lqnrifp7r1mwpsh624nv")
,@arch-independent-patches
- ,@(origin-patches (package-source llvm-10))))))))))))
+ ,@(origin-patches (package-source llvm-11)))))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments llvm-11)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'unpack 'patch-round-two
+ ;; We have to do the patching in two rounds because we can't
+ ;; pass '-p1' and '-p2' in the source field.
+ (lambda* (#:key inputs #:allow-other-keys)
+ (invoke "patch"
+ (assoc-ref inputs "llvm_11_consecutive_registers")
+ "-p2")))))))
+ (native-inputs
+ `(("llvm_11_consecutive_registers"
+ ,(patch-origin
+ "llvm_11_consecutive_registers.patch"
+ "04msd34dnpr3lpss0pam3mckwnvzrab266z6sml1hya0akv0m3f3"))
+ ,@(package-native-inputs llvm-11))))))))
(home-page "https://llvmlite.pydata.org")
(synopsis "Wrapper around basic LLVM functionality")
(description
@@ -1412,6 +1485,11 @@ C/C++/Obj-C code according to a set of style options, see
(description "This package renames every occurrence of a symbol at point
using @code{clang-rename}.")))
+
+;;;
+;;; LLVM variants.
+;;;
+
(define make-ocaml-llvm
;; Make it a memoizing procedure so its callers below don't end up defining
;; two equal-but-not-eq "ocaml-llvm" packages for the default LLVM.
@@ -1455,3 +1533,312 @@ LLVM."))))
(define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9))
(define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10))
(define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11))
+
+(define-public llvm-julia
+ (package
+ (inherit llvm-11)
+ (name "llvm-julia")
+ (properties `((hidden? . #t)
+ ,@(package-properties llvm-11)))
+ (source (origin
+ (inherit (package-source llvm-11))
+ ;; Those patches are inside the Julia source repo.
+ ;; They are _not_ Julia specific (https://github.com/julialang/julia#llvm)
+ ;; but they are required to build Julia.
+ ;; Discussion: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919628
+ (patches
+ (map (match-lambda
+ ((name hash)
+ (julia-patch name hash)))
+ (list
+ '("llvm-D27629-AArch64-large_model_6.0.1"
+ "1qrshmlqvnasdyc158vfn3hnbigqph3lsq7acb9w8lwkpnnm2j4z")
+ '("llvm8-D34078-vectorize-fdiv"
+ "19spqc3xsazn1xs9gpcgv9ldadfkv49rmc5khl7sf1dlmhgi4602")
+ '("llvm-7.0-D44650"
+ "1h55kkmkiisfj6sk956if2bcj9s0v6n5czn8dxb870vp5nccj3ir")
+ '("llvm7-symver-jlprefix"
+ "00ng32x6xhm9czczirn5r1q1mc1myad44fqhi061hwh1vb46dwgm")
+ '("llvm-6.0-DISABLE_ABI_CHECKS"
+ "014fawd1ba7yckalypfld22zgic87x9nx3cim42zrwygywd36pyg")
+ '("llvm9-D50010-VNCoercion-ni"
+ "1s1d3sjsiq4vxg7ncy5cz56zgy5vcq6ls3iqaiqkvr23wyryqmdx")
+ '("llvm7-revert-D44485"
+ "0f59kq3p3mpwsbmskypbi4zn01l6ig0x7v2rjp08k2r8z8m6fa8n")
+ '("llvm-11-D75072-SCEV-add-type"
+ "176xi1lnbnv2rcs05ywhyb7pd0xgmibayvwzksksg44wg2dh8mbx")
+ '("llvm-julia-tsan-custom-as"
+ "0awh40kf6lm4wn1nsjd1bmhfwq7rqj811szanp2xkpspykw9hg9s")
+ '("llvm-D80101"
+ "1gsdwmgmpbignvqyxcnlprj899259p3dvdznlncd84ss445qgq3j")
+ '("llvm-D84031"
+ "0nks9sbk7p0r5gyr0idrmm93a5fmdai8kihz9532dx4zhcvvqbjc")
+ '("llvm-10-D85553"
+ "1zjq7j9q2qp56hwkc8yc8f0z7kvam3j7hj8sb7qyd77r255ff78l")
+ '("llvm-10-unique_function_clang-sa"
+ "1jys9w2zqk3dasnxqh0qz5ij7rxi6mkgq9pqjsclmamr5169zyan")
+ ;'("llvm-D88630-clang-cmake"
+ ; "0rs6s71nqnjkny7i69gqazhqj5jqfdr0bkxs2v5a55sfx8fa1k54")
+ '("llvm-11-D85313-debuginfo-empty-arange"
+ "1f672d5385xpgb8yrim8d3b7wg2z1l81agnshm1q61kdvjixqx32")
+ '("llvm-11-D90722-rtdyld-absolute-relocs"
+ "0kmnai229yyxkmpk9lxd180mcnhk2i8d87k2sg89gc8as18w10r6")
+ '("llvm-invalid-addrspacecast-sink"
+ "1n1b7j4s80vj7x5377aj9vyphmxx1q6bm0chhkxp6zsy3mx3g2ry")
+ '("llvm-11-D92906-ppc-setjmp"
+ "0cmd4dsblp7a8m03j16dqxws0ijh55zf4jzzxmj341qxa1gamdp9")
+ '("llvm-11-PR48458-X86ISelDAGToDAG"
+ "0vwzvlhsdazhxg4gj8g2f00a4f8qc5cgac23w575xk3pgba1jh6y")
+ '("llvm-11-D93092-ppc-knownbits"
+ "1748bypsc7c9lbs3fnkv0kwvch6bn85kj98j4jdaz254ig0wa6xj")
+ '("llvm-11-D93154-globalisel-as"
+ "1k5wd4z3pa7zj0gyjkif7viqj906dhqlbb7dc95gig40nbxv6zpj")
+ '("llvm-11-ppc-half-ctr"
+ "0piywisfz6cmw3133kz7vzhiqflq2y7igakqxlym0gi8pqylv7w9")
+ '("llvm-11-ppc-sp-from-bp"
+ "1wmg3485cx5f9pbykyl3jibk1wwv4w1x30hl4jyfndzr2yh8azf9")
+ '("llvm-rGb498303066a6-gcc11-header-fix"
+ "0hkd4rwhvh8g2yh13g29wiwnjpv2yd1hdyiv1ryw8izl25bz9c67")
+ '("llvm-11-D94813-mergeicmps"
+ "0cmy0ywkgyrdcvr9bd6pd912lyd4gcsrib4z0v05dwgcdxhk7y29")
+ '("llvm-11-D94980-CTR-half"
+ "1yf8cxib3z8hz7zi9n6v2g2c6vpfr4slq9hpx8m8yq8f1jbyw3fw")
+ '("llvm-11-D94058-sext-atomic-ops"
+ "1x6p6k6q651z5jcqxx8vj17cxnv196mka7mwn7dpp6c23lwgfdpb")
+ '("llvm-11-D96283-dagcombine-half"
+ "0lv4iq2f8qrcz1xyxfic3bcr5p0aqam3a7c6pp6fnw3riixm096k"))))
+ (patch-flags '("-p1"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments llvm-11)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'unpack 'patch-round-two
+ ;; We have to do the patching in two rounds because we can't
+ ;; pass '-p1' and '-p2' in the source field.
+ (lambda* (#:key inputs #:allow-other-keys)
+ (map (lambda (patchname)
+ (invoke "patch" patchname "-p2"))
+ (list "llvm-11-AArch64-FastIsel-bug"
+ "llvm-11-D97435-AArch64-movaddrreg"
+ "llvm-11-D97571-AArch64-loh"
+ "llvm-11-aarch64-addrspace"))))))
+ ((#:build-type _) "Release")
+ ((#:configure-flags flags)
+ `(list
+ ;; Build a native compiler and the NVPTX backend (NVIDIA) since
+ ;; Julia insists on it, nothing more. This reduces build times and
+ ;; disk usage.
+ ,(string-append "-DLLVM_TARGETS_TO_BUILD=" (system->llvm-target))
+ "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=NVPTX"
+
+ "-DLLVM_INSTALL_UTILS=ON"
+ "-DLLVM_BUILD_TESTS=ON"
+ "-DLLVM_ENABLE_FFI=ON"
+ "-DLLVM_ENABLE_RTTI=ON"
+ ;; "-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
+ ;; "-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
+ ;; "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly"
+ "-DLLVM_ENABLE_DUMP=ON"
+ "-DLLVM_LINK_LLVM_DYLIB=ON"
+ "-DLLVM_VERSION_SUFFIX:STRING=jl"))))
+ (inputs
+ (append
+ (package-inputs llvm-11)
+ `(("llvm-11-AArch64-FastIsel-bug"
+ ,(julia-patch "llvm-11-AArch64-FastIsel-bug"
+ "1m2vddj1mw4kbij8hbrx82piyy6bvr2x7wwdnlxfaqcm72ipzyh9"))
+ ("llvm-11-D97435-AArch64-movaddrreg"
+ ,(julia-patch "llvm-11-D97435-AArch64-movaddrreg"
+ "10jnavq9ljkj7j2gqj2zd1pwqpqb5zs3zp9h96pmz0djbmxwa86y"))
+ ("llvm-11-D97571-AArch64-loh"
+ ,(julia-patch "llvm-11-D97571-AArch64-loh"
+ "128zcbg1w1j7hngsf7z1a7alc6lig6l2rqgjp6i8nk3k3f842v6n"))
+ ("llvm-11-aarch64-addrspace"
+ ,(julia-patch "llvm-11-aarch64-addrspace"
+ "0ckbzgfirxrf2d5bpinpngp7gnilbjrk0cbdfyl3h6f5v6i6xj6m")))))))
+
+(define %cling-version "0.9")
+
+(define llvm-cling ;LLVM 9 with approximately 10 patches for cling
+ (let ((base llvm-9))
+ (package/inherit base
+ (name "llvm-cling")
+ (source
+ (origin
+ (inherit (package-source base))
+ (method git-fetch)
+ (uri (git-reference
+ (url "http://root.cern/git/llvm.git")
+ (commit (string-append "cling-v" %cling-version))))
+ (file-name (git-file-name "llvm-cling" %cling-version))
+ (sha256
+ (base32
+ "0y3iwv3c9152kybmdrwvadggjs163r25h7rmlxzr3hfpr463pnwf"))
+ (modules '((guix build utils)))
+ (snippet
+ ;; The source is missing an include directive (see:
+ ;; https://github.com/vgvassilev/cling/issues/219).
+ '(substitute* "utils/benchmark/src/benchmark_register.h"
+ (("^#include <vector>.*" all)
+ (string-append all "#include <limits>\n"))))))
+ (outputs '("out"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:configure-flags _ ''())
+ '(list "-DLLVM_PARALLEL_LINK_JOBS=1" ;cater to smaller build machines
+ ;; Only enable compiler support for the host architecture to
+ ;; save on build time.
+ "-DLLVM_TARGETS_TO_BUILD=host;NVPTX"
+ "-DLLVM_INSTALL_UTILS=ON"
+ "-DLLVM_ENABLE_RTTI=ON"
+ "-DLLVM_ENABLE_FFI=ON"
+ "-DLLVM_BUILD_LLVM_DYLIB=ON"
+ "-DLLVM_LINK_LLVM_DYLIB=ON"))
+ ((#:phases phases '%standard-phases)
+ `(modify-phases ,phases
+ (delete 'shared-lib-workaround)
+ (delete 'install-opt-viewer))))))))
+
+(define clang-cling-runtime
+ (let ((base clang-runtime-9))
+ (package/inherit base
+ (name "clang-cling-runtime")
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:phases phases '%standard-phases)
+ `(modify-phases ,phases
+ (add-after 'install 'delete-static-libraries
+ ;; This reduces the size from 22 MiB to 4 MiB.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (for-each delete-file (find-files out "\\.a$")))))))))
+ (inputs (modify-inputs (package-inputs base)
+ (replace "llvm" llvm-cling))))))
+
+(define clang-cling ;modified clang 9 with ~ 60 patches for cling
+ (let ((base clang-9))
+ (package/inherit base
+ (name "clang-cling")
+ (source
+ (origin
+ (inherit (package-source base))
+ (method git-fetch)
+ (uri (git-reference
+ (url "http://root.cern/git/clang.git")
+ (commit (string-append "cling-v" %cling-version))))
+ (file-name (git-file-name "clang-cling" %cling-version))
+ (sha256
+ (base32
+ "128mxkwghss6589wvm6amzv183aq88rdrnfxjiyjcji5hx84vpby"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:phases phases '%standard-phases)
+ `(modify-phases ,phases
+ (add-after 'install 'delete-static-libraries
+ ;; This reduces the size by half, from 220 MiB to 112 MiB.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (for-each delete-file (find-files out "\\.a$")))))))))
+ (propagated-inputs
+ (modify-inputs (package-propagated-inputs base)
+ (replace "llvm" llvm-cling)
+ (replace "clang-runtime" clang-cling-runtime))))))
+
+(define-public cling
+ ;; The tagged v0.9 release doesn't build, so use the latest commit.
+ (let ((commit "d78d1a03fedfd2bf6d2b6ff295aca576d98940df")
+ (revision "1")
+ (version* "0.9"))
+ (package
+ (name "cling")
+ (version (git-version version* revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "http://root.cern/git/cling.git")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0lsbxv21b4qw11xkw9iipdpca64jjwwqxm0qf5v2cgdlibf8m8n9"))
+ ;; Patch submitted upstream here:
+ ;; https://github.com/root-project/cling/pull/433.
+ (patches (search-patches "cling-use-shared-library.patch"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:build-type "Release" ;keep the build as lean as possible
+ #:tests? #f ;FIXME: 78 tests fail (out of ~200)
+ #:test-target "check-cling"
+ #:configure-flags
+ (list (string-append "-DCLING_CXX_PATH="
+ (assoc-ref %build-inputs "gcc") "/bin/g++")
+ ;; XXX: The AddLLVM.cmake module expects LLVM_EXTERNAL_LIT to
+ ;; be a Python script, not a shell executable.
+ (string-append "-DLLVM_EXTERNAL_LIT="
+ (assoc-ref %build-inputs "python-lit")
+ "/bin/.lit-real"))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'set-version
+ (lambda _
+ (make-file-writable "VERSION")
+ (call-with-output-file "VERSION"
+ (lambda (port)
+ (format port "~a~%" ,version)))))
+ (add-after 'unpack 'patch-paths
+ (lambda* (#:key inputs #:allow-other-keys)
+ (substitute* "lib/Interpreter/CIFactory.cpp"
+ (("\bsed\b")
+ (which "sed"))
+ ;; This ensures that the default C++ library used by Cling is
+ ;; that of the compiler that was used to build it, rather
+ ;; than that of whatever g++ happens to be on PATH.
+ (("ReadCompilerIncludePaths\\(CLING_CXX_RLTV")
+ (string-append "ReadCompilerIncludePaths(\""
+ (assoc-ref inputs "gcc") "/bin/g++\""))
+ ;; Cling uses libclang's CompilerInvocation::GetResourcesPath
+ ;; to resolve Clang's library prefix, but this fails on Guix
+ ;; because it is relative to the output of cling rather than
+ ;; clang (see:
+ ;; https://github.com/root-project/cling/issues/434). Fully
+ ;; shortcut the logic in this method to return the correct
+ ;; static location.
+ (("static std::string getResourceDir.*" all)
+ (string-append all
+ " return std::string(\""
+ (assoc-ref inputs "clang-cling")
+ "/lib/clang/" ,(package-version clang-cling)
+ "\");")))
+ ;; Check for the 'lit' command for the tests, not 'lit.py'
+ ;; (see: https://github.com/root-project/cling/issues/432).
+ (substitute* "CMakeLists.txt"
+ (("lit.py")
+ "lit"))))
+ (add-after 'unpack 'adjust-lit.cfg
+ ;; See: https://github.com/root-project/cling/issues/435.
+ (lambda _
+ (substitute* "test/lit.cfg"
+ (("config.llvm_tools_dir \\+ '")
+ "config.cling_obj_root + '/bin"))))
+ (add-after 'install 'delete-static-libraries
+ ;; This reduces the size from 17 MiB to 5.4 MiB.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (for-each delete-file (find-files out "\\.a$"))))))))
+ (native-inputs
+ `(("python" ,python)
+ ("python-lit" ,python-lit)))
+ (inputs
+ `(("clang-cling" ,clang-cling)
+ ("llvm-cling" ,llvm-cling)))
+ (home-page "https://root.cern/cling/")
+ (synopsis "Interactive C++ interpreter")
+ (description "Cling is an interactive C++17 standard compliant
+interpreter, built on top of LLVM and Clang. Cling can be used as a
+read-eval-print loop (REPL) to assist with rapid application development.
+Here's how to print @samp{\"Hello World!\"} using @command{cling}:
+
+@example
+cling '#include <stdio.h>' 'printf(\"Hello World!\\n\");'
+@end example")
+ (license license:lgpl2.1+)))) ;for the combined work