gnu: mumi: Update to 0.0.0-12.bb2fe92.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
CommitLineData
3e4249ce 1;;; GNU Guix --- Functional package management for GNU
fc9dbf41 2;;; Copyright © 2014, 2016, 2018 Eric Bavier <bavier@member.fsf.org>
1204c510 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
286bea0d 4;;; Copyright © 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
ee077430 5;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
290b55c5 6;;; Copyright © 2016, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
584da12d 7;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
233deb82 8;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
e2170c31 9;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
0627f93d 10;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
7628ff1f
TG
11;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
12;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
c5296e20 13;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
5dea5cbc 14;;; Copyright © 2019 Arm Ltd <David.Truby@arm.com>
57c7bfec 15;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
66087272 16;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
3e4249ce
EB
17;;;
18;;; This file is part of GNU Guix.
19;;;
20;;; GNU Guix is free software; you can redistribute it and/or modify it
21;;; under the terms of the GNU General Public License as published by
22;;; the Free Software Foundation; either version 3 of the License, or (at
23;;; your option) any later version.
24;;;
25;;; GNU Guix is distributed in the hope that it will be useful, but
26;;; WITHOUT ANY WARRANTY; without even the implied warranty of
27;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28;;; GNU General Public License for more details.
29;;;
30;;; You should have received a copy of the GNU General Public License
31;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
32
33(define-module (gnu packages llvm)
34 #:use-module (guix packages)
ac00973c 35 #:use-module ((guix licenses) #:prefix license:)
3e4249ce 36 #:use-module (guix download)
a2cc25ab 37 #:use-module (guix git-download)
3e4249ce
EB
38 #:use-module (guix utils)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system cmake)
7628ff1f 41 #:use-module (guix build-system emacs)
8892cac3 42 #:use-module (guix build-system python)
57c7bfec 43 #:use-module (guix build-system trivial)
3e4249ce 44 #:use-module (gnu packages)
57c7bfec 45 #:use-module (gnu packages base)
fd6ae1b9
LC
46 #:use-module (gnu packages gcc)
47 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
ee077430
EB
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages libffi)
698e91f0 50 #:use-module (gnu packages mpi)
290b55c5 51 #:use-module (gnu packages onc-rpc)
3e4249ce 52 #:use-module (gnu packages perl)
698e91f0 53 #:use-module (gnu packages pkg-config)
3e4249ce 54 #:use-module (gnu packages python)
96a9a8d3
LC
55 #:use-module (gnu packages xml)
56 #:export (system->llvm-target))
57
58(define* (system->llvm-target #:optional
59 (system (or (and=> (%current-target-system)
60 gnu-triplet->nix-system)
61 (%current-system))))
62 "Return the LLVM target name that corresponds to SYSTEM, a system type such
63as \"x86_64-linux\"."
64 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
65 (letrec-syntax ((matches (syntax-rules (=>)
66 ((_ (system-prefix => target) rest ...)
67 (if (string-prefix? system-prefix system)
68 target
69 (matches rest ...)))
70 ((_)
71 (error "LLVM target for system is unknown" system)))))
72 (matches ("aarch64" => "AArch64")
73 ("armhf" => "ARM")
74 ("mips64el" => "Mips")
75 ("powerpc" => "PowerPC")
76 ("riscv" => "RISCV")
77 ("x86_64" => "X86")
78 ("i686" => "X86"))))
3e4249ce 79
cd16014f
MB
80(define (llvm-download-uri component version)
81 (if (version>=? version "9.0.1")
82 (string-append "https://github.com/llvm/llvm-project/releases/download"
83 "/llvmorg-" version "/" component "-" version ".src.tar.xz")
84 (string-append "https://releases.llvm.org/" version "/" component "-"
85 version ".src.tar.xz")))
86
00ede157 87(define-public llvm
3e4249ce
EB
88 (package
89 (name "llvm")
00ede157 90 (version "9.0.1")
3e4249ce
EB
91 (source
92 (origin
93 (method url-fetch)
cd16014f 94 (uri (llvm-download-uri "llvm" version))
3e4249ce
EB
95 (sha256
96 (base32
00ede157 97 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))))
3e4249ce
EB
98 (build-system cmake-build-system)
99 (native-inputs
3ebc0905 100 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
3e4249ce 101 ("perl" ,perl)))
ee077430 102 (inputs
44e8559d
EB
103 `(("libffi" ,libffi)))
104 (propagated-inputs
105 `(("zlib" ,zlib))) ;to use output from llvm-config
3e4249ce 106 (arguments
22d0e9b7 107 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
ee077430 108 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
ab78618f 109 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
22897187 110 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
fc9dbf41 111 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
22897187 112 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
0935fb27
EB
113
114 ;; Don't use '-g' during the build, to save space.
ab78618f
EB
115 #:build-type "Release"
116 #:phases (modify-phases %standard-phases
117 (add-before 'build 'shared-lib-workaround
118 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
119 ;; doesn't seem to get the correct rpath to be able to run
120 ;; from the build directory. Set LD_LIBRARY_PATH as a
121 ;; workaround.
122 (lambda _
123 (setenv "LD_LIBRARY_PATH"
124 (string-append (getcwd) "/lib"))
125 #t)))))
ac97dce1 126 (home-page "https://www.llvm.org")
3e4249ce
EB
127 (synopsis "Optimizing compiler infrastructure")
128 (description
e881752c
AK
129 "LLVM is a compiler infrastructure designed for compile-time, link-time,
130runtime, and idle-time optimization of programs from arbitrary programming
131languages. It currently supports compilation of C and C++ programs, using
132front-ends derived from GCC 4.0.1. A new front-end for the C family of
133languages is in development. The compiler infrastructure includes mirror sets
134of programming tools as well as libraries with equivalent functionality.")
00ede157 135 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
f5de2b9a 136
6b26f915
LC
137(define* (clang-runtime-from-llvm llvm hash
138 #:optional (patches '()))
b81f5693
AW
139 (package
140 (name "clang-runtime")
141 (version (package-version llvm))
142 (source
143 (origin
144 (method url-fetch)
cd16014f 145 (uri (llvm-download-uri "compiler-rt" version))
6b26f915
LC
146 (sha256 (base32 hash))
147 (patches (map search-patch patches))))
b81f5693
AW
148 (build-system cmake-build-system)
149 (native-inputs (package-native-inputs llvm))
150 (inputs
151 `(("llvm" ,llvm)))
152 (arguments
153 `(;; Don't use '-g' during the build to save space.
3b956a33
EB
154 #:build-type "Release"
155 #:tests? #f)) ; Tests require gtest
ac97dce1 156 (home-page "https://compiler-rt.llvm.org")
b81f5693
AW
157 (synopsis "Runtime library for Clang/LLVM")
158 (description
159 "The \"clang-runtime\" library provides the implementations of run-time
160functions for C and C++ programs. It also provides header files that allow C
161and C++ source code to interface with the \"sanitization\" passes of the clang
162compiler. In LLVM this library is called \"compiler-rt\".")
00ede157 163 (license (package-license llvm))
9e6b9ea4 164
ac97dce1 165 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
9e6b9ea4 166 (supported-systems (delete "mips64el-linux" %supported-systems))))
b81f5693 167
3b956a33 168(define* (clang-from-llvm llvm clang-runtime hash
9bdbabe9 169 #:key (patches '()))
3e4249ce
EB
170 (package
171 (name "clang")
172 (version (package-version llvm))
173 (source
174 (origin
175 (method url-fetch)
cd16014f
MB
176 (uri (llvm-download-uri (if (version>=? version "9.0.1")
177 "clang"
178 "cfe")
179 version))
fd6ae1b9 180 (sha256 (base32 hash))
3b956a33 181 (patches (map search-patch patches))))
3e4249ce
EB
182 ;; Using cmake allows us to treat llvm as an external library. There
183 ;; doesn't seem to be any way to do this with clang's autotools-based
184 ;; build system.
185 (build-system cmake-build-system)
186 (native-inputs (package-native-inputs llvm))
187 (inputs
188 `(("libxml2" ,libxml2)
c92f1c0a 189 ("gcc-lib" ,gcc "lib")
3e4249ce
EB
190 ,@(package-inputs llvm)))
191 (propagated-inputs
b81f5693
AW
192 `(("llvm" ,llvm)
193 ("clang-runtime" ,clang-runtime)))
fd6ae1b9
LC
194 (arguments
195 `(#:configure-flags
196 (list "-DCLANG_INCLUDE_TESTS=True"
197
198 ;; Find libgcc_s, crtbegin.o, and crtend.o.
199 (string-append "-DGCC_INSTALL_PREFIX="
200 (assoc-ref %build-inputs "gcc-lib"))
201
202 ;; Use a sane default include directory.
203 (string-append "-DC_INCLUDE_DIRS="
204 (assoc-ref %build-inputs "libc")
205 "/include"))
206
94585e88
LC
207 ;; Don't use '-g' during the build to save space.
208 #:build-type "Release"
209
fd6ae1b9 210 #:phases (modify-phases %standard-phases
f5cc5de8
MB
211 (add-after 'unpack 'add-missing-triplets
212 (lambda _
213 ;; Clang iterates through known triplets to search for
214 ;; GCC's headers, but does not recognize some of the
215 ;; triplets that are used in Guix.
216 (substitute* ,@(if (version>=? version "6.0")
217 '("lib/Driver/ToolChains/Gnu.cpp")
218 '("lib/Driver/ToolChains.cpp"))
219 (("\"aarch64-linux-gnu\"," all)
220 (string-append "\"aarch64-unknown-linux-gnu\", "
221 all))
222 (("\"arm-linux-gnueabihf\"," all)
223 (string-append all
224 " \"arm-unknown-linux-gnueabihf\","))
225 (("\"i686-pc-linux-gnu\"," all)
226 (string-append "\"i686-unknown-linux-gnu\", "
227 all)))
228 #t))
5041cc28
MB
229 (add-after 'unpack 'set-glibc-file-names
230 (lambda* (#:key inputs #:allow-other-keys)
231 (let ((libc (assoc-ref inputs "libc"))
232 (compiler-rt (assoc-ref inputs "clang-runtime"))
233 (gcc (assoc-ref inputs "gcc")))
234 ,@(cond
235 ((version>=? version "6.0")
236 `(;; Link to libclang_rt files from clang-runtime.
237 (substitute* "lib/Driver/ToolChain.cpp"
238 (("getDriver\\(\\)\\.ResourceDir")
239 (string-append "\"" compiler-rt "\"")))
9bdbabe9 240
5041cc28
MB
241 ;; Make "LibDir" refer to <glibc>/lib so that it
242 ;; uses the right dynamic linker file name.
243 (substitute* "lib/Driver/ToolChains/Linux.cpp"
244 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
245 (string-append declaration "\"" libc "/lib\";\n"))
9bdbabe9 246
5041cc28
MB
247 ;; Make clang look for libstdc++ in the right
248 ;; location.
249 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
250 (string-append
251 "LibStdCXXIncludePathCandidates[] = { \"" gcc
252 "/include/c++\","))
496bbeee 253
5041cc28
MB
254 ;; Make sure libc's libdir is on the search path, to
255 ;; allow crt1.o & co. to be found.
256 (("@GLIBC_LIBDIR@")
257 (string-append libc "/lib")))))
258 (else
259 `((substitute* "lib/Driver/Tools.cpp"
260 ;; Patch the 'getLinuxDynamicLinker' function so that
261 ;; it uses the right dynamic linker file name.
262 (("/lib64/ld-linux-x86-64.so.2")
263 (string-append libc
264 ,(glibc-dynamic-linker))))
9bdbabe9 265
5041cc28
MB
266 ;; Link to libclang_rt files from clang-runtime.
267 ;; This substitution needed slight adjustment in 3.8.
268 ,@(if (version>=? version "3.8")
269 '((substitute* "lib/Driver/Tools.cpp"
270 (("TC\\.getDriver\\(\\)\\.ResourceDir")
271 (string-append "\"" compiler-rt "\""))))
272 '((substitute* "lib/Driver/ToolChain.cpp"
273 (("getDriver\\(\\)\\.ResourceDir")
274 (string-append "\"" compiler-rt "\"")))))
9bdbabe9 275
5041cc28
MB
276 ;; Make sure libc's libdir is on the search path, to
277 ;; allow crt1.o & co. to be found.
278 (substitute* "lib/Driver/ToolChains.cpp"
279 (("@GLIBC_LIBDIR@")
280 (string-append libc "/lib"))))))
281 #t)))
1c7372a5
PN
282 (add-after 'install 'install-clean-up-/share/clang
283 (lambda* (#:key outputs #:allow-other-keys)
284 (let* ((out (assoc-ref outputs "out"))
285 (compl-dir (string-append
286 out "/etc/bash_completion.d")))
287 (with-directory-excursion (string-append out
288 "/share/clang")
ad8a4a66
PN
289 (for-each
290 (lambda (file)
291 (when (file-exists? file)
292 (delete-file file)))
293 ;; Delete extensions for proprietary text editors.
294 '("clang-format-bbedit.applescript"
295 "clang-format-sublime.py"
296 ;; Delete Emacs extensions: see their respective Emacs
297 ;; Guix package instead.
298 "clang-rename.el" "clang-format.el"))
1c7372a5 299 ;; Install bash completion.
ad8a4a66
PN
300 (when (file-exists? "bash-autocomplete.sh")
301 (mkdir-p compl-dir)
302 (rename-file "bash-autocomplete.sh"
303 (string-append compl-dir "/clang")))))
1c7372a5 304 #t)))))
ef11ac87
LC
305
306 ;; Clang supports the same environment variables as GCC.
307 (native-search-paths
308 (list (search-path-specification
309 (variable "CPATH")
310 (files '("include")))
311 (search-path-specification
312 (variable "LIBRARY_PATH")
313 (files '("lib" "lib64")))))
314
ac97dce1 315 (home-page "https://clang.llvm.org")
3e4249ce
EB
316 (synopsis "C language family frontend for LLVM")
317 (description
318 "Clang is a compiler front end for the C, C++, Objective-C and
319Objective-C++ programming languages. It uses LLVM as its back end. The Clang
320project includes the Clang front end, the Clang static analyzer, and several
321code analysis tools.")
00ede157
MB
322 (license (if (version>=? version "9.0")
323 license:asl2.0 ;with LLVM exceptions
324 license:ncsa))))
1204c510 325
57c7bfec
MO
326(define (make-clang-toolchain clang)
327 (package
328 (name (string-append (package-name clang) "-toolchain"))
329 (version (package-version clang))
330 (source #f)
331 (build-system trivial-build-system)
332 (arguments
333 '(#:modules ((guix build union))
334 #:builder (begin
335 (use-modules (ice-9 match)
336 (srfi srfi-26)
337 (guix build union))
338
339 (let ((out (assoc-ref %outputs "out")))
340
341 (match %build-inputs
342 (((names . directories) ...)
343 (union-build out directories)))
344
345 (union-build (assoc-ref %outputs "debug")
346 (list (assoc-ref %build-inputs
347 "libc-debug")))
348 (union-build (assoc-ref %outputs "static")
349 (list (assoc-ref %build-inputs
350 "libc-static")))
351 #t))))
352
353 (native-search-paths (package-native-search-paths clang))
354 (search-paths (package-search-paths clang))
355
356 (license (package-license clang))
357 (home-page "https://clang.llvm.org")
358 (synopsis "Complete Clang toolchain for C/C++ development")
359 (description "This package provides a complete Clang toolchain for C/C++
360development to be installed in user profiles. This includes Clang, as well as
361libc (headers and binaries, plus debugging symbols in the @code{debug}
362output), and Binutils.")
363 (outputs '("out" "debug" "static"))
364 (inputs `(("clang" ,clang)
365 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
366 ("binutils" ,binutils)
367 ("libc" ,glibc)
368 ("libc-debug" ,glibc "debug")
369 ("libc-static" ,glibc "static")))))
370
b81f5693
AW
371(define-public clang-runtime
372 (clang-runtime-from-llvm
373 llvm
00ede157 374 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"))
b81f5693 375
1204c510 376(define-public clang
b81f5693 377 (clang-from-llvm llvm clang-runtime
00ede157
MB
378 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
379 #:patches '("clang-9.0-libc-search-path.patch")))
d199a4c7 380
57c7bfec
MO
381(define-public clang-toolchain
382 (make-clang-toolchain clang))
383
00ede157
MB
384(define-public llvm-9 llvm)
385(define-public clang-runtime-9 clang-runtime)
386(define-public clang-9 clang)
387(define-public clang-toolchain-9 clang-toolchain)
388
389(define-public llvm-8
96d5a206
DT
390 (package
391 (inherit llvm)
00ede157 392 (version "8.0.0")
96d5a206
DT
393 (source (origin
394 (method url-fetch)
cd16014f 395 (uri (llvm-download-uri "llvm" version))
96d5a206
DT
396 (sha256
397 (base32
00ede157
MB
398 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
399 (license license:ncsa)))
96d5a206 400
00ede157 401(define-public clang-runtime-8
96d5a206 402 (clang-runtime-from-llvm
00ede157
MB
403 llvm-8
404 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"))
96d5a206 405
00ede157
MB
406(define-public clang-8
407 (clang-from-llvm llvm-8 clang-runtime-8
408 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
409 #:patches '("clang-7.0-libc-search-path.patch")))
96d5a206 410
00ede157
MB
411(define-public clang-toolchain-8
412 (make-clang-toolchain clang-8))
96d5a206 413
4289d1d7
MB
414(define-public llvm-7
415 (package
00ede157 416 (inherit llvm-8)
4289d1d7
MB
417 (version "7.0.1")
418 (source (origin
419 (method url-fetch)
cd16014f 420 (uri (llvm-download-uri "llvm" version))
4289d1d7
MB
421 (sha256
422 (base32
423 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
424
425(define-public clang-runtime-7
426 (clang-runtime-from-llvm
427 llvm-7
428 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"))
429
430(define-public clang-7
501672d7 431 (clang-from-llvm llvm-7 clang-runtime-7
4289d1d7
MB
432 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
433 #:patches '("clang-7.0-libc-search-path.patch")))
434
57c7bfec
MO
435(define-public clang-toolchain-7
436 (make-clang-toolchain clang-7))
437
d199a4c7
MB
438(define-public llvm-6
439 (package
00ede157 440 (inherit llvm-7)
d199a4c7
MB
441 (version "6.0.1")
442 (source (origin
443 (method url-fetch)
cd16014f 444 (uri (llvm-download-uri "llvm" version))
d199a4c7
MB
445 (sha256
446 (base32
447 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
448
449(define-public clang-runtime-6
450 (clang-runtime-from-llvm
451 llvm-6
452 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"))
453
454(define-public clang-6
501672d7 455 (clang-from-llvm llvm-6 clang-runtime-6
148df605 456 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
9bdbabe9 457 #:patches '("clang-6.0-libc-search-path.patch")))
3b956a33 458
57c7bfec
MO
459(define-public clang-toolchain-6
460 (make-clang-toolchain clang-6))
461
584da12d 462(define-public llvm-3.9.1
00ede157 463 (package (inherit llvm-6)
584da12d
RJ
464 (name "llvm")
465 (version "3.9.1")
466 (source
467 (origin
468 (method url-fetch)
cd16014f 469 (uri (llvm-download-uri "llvm" version))
584da12d
RJ
470 (sha256
471 (base32
472 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
473
474(define-public clang-runtime-3.9.1
475 (clang-runtime-from-llvm
476 llvm-3.9.1
6b26f915
LC
477 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
478 '("clang-runtime-asan-build-fixes.patch"
0627f93d 479 "clang-runtime-esan-build-fixes.patch"
1a2d8d06 480 "clang-3.5-libsanitizer-ustat-fix.patch")))
584da12d
RJ
481
482(define-public clang-3.9.1
483 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
484 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
9bdbabe9
MB
485 #:patches '("clang-3.8-libc-search-path.patch")))
486
487(define-public llvm-3.8
00ede157 488 (package (inherit llvm-3.9.1)
9bdbabe9
MB
489 (name "llvm")
490 (version "3.8.1")
491 (source
492 (origin
493 (method url-fetch)
cd16014f 494 (uri (llvm-download-uri "llvm" version))
9bdbabe9
MB
495 (sha256
496 (base32
497 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
498
499(define-public clang-runtime-3.8
500 (clang-runtime-from-llvm
501 llvm-3.8
502 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
0627f93d 503 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 504 "clang-3.5-libsanitizer-ustat-fix.patch")))
9bdbabe9
MB
505
506(define-public clang-3.8
507 (clang-from-llvm llvm-3.8 clang-runtime-3.8
508 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
509 #:patches '("clang-3.8-libc-search-path.patch")))
584da12d 510
3b956a33 511(define-public llvm-3.7
00ede157 512 (package (inherit llvm-3.8)
3b956a33
EB
513 (version "3.7.1")
514 (source
515 (origin
516 (method url-fetch)
cd16014f 517 (uri (llvm-download-uri "llvm" version))
3b956a33
EB
518 (sha256
519 (base32
520 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
521
522(define-public clang-runtime-3.7
523 (clang-runtime-from-llvm
524 llvm-3.7
6b26f915 525 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
0627f93d 526 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 527 "clang-3.5-libsanitizer-ustat-fix.patch")))
3b956a33
EB
528
529(define-public clang-3.7
530 (clang-from-llvm llvm-3.7 clang-runtime-3.7
9bdbabe9
MB
531 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
532 #:patches '("clang-3.5-libc-search-path.patch")))
3ebc0905
EB
533
534(define-public llvm-3.6
00ede157 535 (package (inherit llvm-3.7)
3ebc0905
EB
536 (version "3.6.2")
537 (source
538 (origin
539 (method url-fetch)
cd16014f 540 (uri (llvm-download-uri "llvm" version))
3ebc0905
EB
541 (sha256
542 (base32
543 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
544
545(define-public clang-runtime-3.6
546 (clang-runtime-from-llvm
547 llvm-3.6
6b26f915
LC
548 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
549 '("clang-runtime-asan-build-fixes.patch")))
3ebc0905
EB
550
551(define-public clang-3.6
552 (clang-from-llvm llvm-3.6 clang-runtime-3.6
9bdbabe9
MB
553 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
554 #:patches '("clang-3.5-libc-search-path.patch")))
1204c510
MW
555
556(define-public llvm-3.5
00ede157 557 (package (inherit llvm-3.6)
a53c486d 558 (version "3.5.2")
1204c510
MW
559 (source
560 (origin
561 (method url-fetch)
cd16014f 562 (uri (llvm-download-uri "llvm" version))
6ba4eca2
RW
563 (patches
564 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1204c510
MW
565 (sha256
566 (base32
a53c486d 567 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1204c510 568
b81f5693 569(define-public clang-runtime-3.5
290b55c5
RW
570 (let ((runtime (clang-runtime-from-llvm
571 llvm-3.5
572 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
573 '("clang-runtime-asan-build-fixes.patch"
574 "clang-3.5-libsanitizer-ustat-fix.patch"))))
575 (package
576 (inherit runtime)
577 (arguments
578 (substitute-keyword-arguments (package-arguments runtime)
579 ((#:phases phases '%standard-phases)
580 `(modify-phases ,phases
581 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
582 ;; libtirpc.
583 (add-after 'unpack 'find-rpc-includes
584 (lambda* (#:key inputs #:allow-other-keys)
585 (setenv "CPATH"
586 (string-append (assoc-ref inputs "libtirpc")
587 "/include/tirpc/:"
588 (or (getenv "CPATH") "")))
589 (setenv "CPLUS_INCLUDE_PATH"
590 (string-append (assoc-ref inputs "libtirpc")
591 "/include/tirpc/:"
592 (or (getenv "CPLUS_INCLUDE_PATH") "")))
593 #t))))))
594 (inputs
595 `(("libtirpc" ,libtirpc)
596 ("llvm" ,llvm-3.5))))))
b81f5693 597
1204c510 598(define-public clang-3.5
b81f5693 599 (clang-from-llvm llvm-3.5 clang-runtime-3.5
9bdbabe9
MB
600 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
601 #:patches '("clang-3.5-libc-search-path.patch")))
921cb13a
RW
602
603(define-public llvm-for-extempore
604 (package (inherit llvm-3.7)
7355634d 605 (name "llvm-for-extempore")
921cb13a
RW
606 (source
607 (origin
608 (inherit (package-source llvm-3.7))
39162ee4
RW
609 (patches (list (search-patch "llvm-for-extempore.patch")))))
610 ;; Extempore refuses to build on architectures other than x86_64
611 (supported-systems '("x86_64-linux"))))
8892cac3 612
52f9c3b8
MB
613(define-public libcxx
614 (package
615 (name "libcxx")
00ede157 616 (version "9.0.1")
52f9c3b8
MB
617 (source
618 (origin
619 (method url-fetch)
620 (uri (llvm-download-uri "libcxx" version))
621 (sha256
622 (base32
00ede157 623 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
52f9c3b8
MB
624 (build-system cmake-build-system)
625 (native-inputs
626 `(("clang" ,clang)
627 ("llvm" ,llvm)))
628 (home-page "https://libcxx.llvm.org")
629 (synopsis "C++ standard library")
630 (description
631 "This package provides an implementation of the C++ standard library for
632use with Clang, targeting C++11, C++14 and above.")
633 (license license:expat)))
634
635;; Libcxx files specifically used by PySide2.
636(define-public libcxx-6
637 (package
638 (inherit libcxx)
639 (version (package-version llvm-6))
640 (source
641 (origin
642 (inherit (package-source libcxx))
643 (uri (llvm-download-uri "libcxx" version))
644 (sha256
645 (base32
646 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
647 (native-inputs
648 `(("clang" ,clang-6)
649 ("llvm" ,llvm-6)))))
650
651(define-public libclc
652 (package
653 (name "libclc")
00ede157 654 (version "9.0.1")
52f9c3b8
MB
655 (source
656 (origin
657 (method git-fetch)
658 (uri (git-reference
659 (url "https://github.com/llvm/llvm-project.git")
660 (commit (string-append "llvmorg-" version))))
661 (file-name (git-file-name name version))
662 (sha256
663 (base32
00ede157 664 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
52f9c3b8
MB
665 (build-system cmake-build-system)
666 (arguments
667 `(#:configure-flags
668 (list (string-append "-DLLVM_CLANG="
669 (assoc-ref %build-inputs "clang")
670 "/bin/clang")
671 (string-append "-DPYTHON="
672 (assoc-ref %build-inputs "python")
673 "/bin/python3"))
674 #:phases
675 (modify-phases %standard-phases
676 (add-after 'unpack 'chdir
677 (lambda _ (chdir "libclc") #t)))))
678 (native-inputs
679 `(("clang" ,clang)
680 ("llvm" ,llvm)
681 ("python" ,python)))
682 (home-page "https://libclc.llvm.org")
683 (synopsis "Libraries for the OpenCL programming language")
684 (description
685 "This package provides an implementation of the OpenCL library
686requirements according to version 1.1 of the OpenCL specification.")
687 ;; Apache license 2.0 with LLVM exception
688 (license license:asl2.0)))
689
690(define-public libomp
691 (package
692 (name "libomp")
00ede157 693 (version "9.0.1")
52f9c3b8
MB
694 (source (origin
695 (method url-fetch)
696 (uri (llvm-download-uri "openmp" version))
697 (sha256
698 (base32
00ede157 699 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
52f9c3b8
MB
700 (file-name (string-append "libomp-" version ".tar.xz"))))
701 (build-system cmake-build-system)
702 ;; XXX: Note this gets built with GCC because building with Clang itself
703 ;; fails (missing <atomic>, even when libcxx is added as an input.)
704 (arguments
705 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
706 "-DOPENMP_TEST_C_COMPILER=clang"
707 "-DOPENMP_TEST_CXX_COMPILER=clang++")
708 #:test-target "check-libomp"))
709 (native-inputs
710 `(("clang" ,clang)
711 ("llvm" ,llvm)
712 ("perl" ,perl)
713 ("pkg-config" ,pkg-config)))
714 (inputs
715 `(("hwloc" ,hwloc "lib")))
716 (home-page "https://openmp.llvm.org")
717 (synopsis "OpenMP run-time support library")
718 (description
719 "This package provides the run-time support library developed by the LLVM
720project for the OpenMP multi-theaded programming extension. This package
721notably provides @file{libgomp.so}, which is has a binary interface compatible
722with that of libgomp, the GNU Offloading and Multi Processing Library.")
723 (license license:expat)))
724
8892cac3
RW
725(define-public python-llvmlite
726 (package
727 (name "python-llvmlite")
66087272 728 (version "0.30.0")
8892cac3
RW
729 (source
730 (origin
731 (method url-fetch)
732 (uri (pypi-uri "llvmlite" version))
733 (sha256
734 (base32
66087272 735 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
8892cac3 736 (build-system python-build-system)
66087272
BG
737 (arguments
738 ;; FIXME: One test fails unable to find libm.so
739 ;; https://github.com/numba/llvmlite/issues/537
740 `(#:tests? #f))
8892cac3
RW
741 (inputs
742 `(("llvm"
743 ,(package
4289d1d7 744 (inherit llvm-7)
8892cac3 745 (source (origin
4289d1d7 746 (inherit (package-source llvm-7))
8892cac3
RW
747 (patches
748 (list
749 (origin
750 (method url-fetch)
751 (uri (string-append "https://raw.githubusercontent.com/numba/"
752 "llvmlite/v" version "/conda-recipes/"
f9325407 753 "D47188-svml-VF.patch"))
8892cac3
RW
754 (sha256
755 (base32
f9325407 756 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
8892cac3
RW
757 (origin
758 (method url-fetch)
759 (uri (string-append "https://raw.githubusercontent.com/numba/"
760 "llvmlite/v" version "/conda-recipes/"
761 "twine_cfg_undefined_behavior.patch"))
762 (sha256
763 (base32
7a20877a 764 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
8892cac3
RW
765 (home-page "http://llvmlite.pydata.org")
766 (synopsis "Wrapper around basic LLVM functionality")
767 (description
768 "This package provides a Python binding to LLVM for use in Numba.")
769 (license license:bsd-3)))
7628ff1f 770
67eebb19
LC
771(define (package-elisp-from-package source-package package-name
772 source-files)
773 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
774SOURCE-FILES found in SOURCE-PACKAGE."
775 (let ((orig (package-source source-package)))
776 (package
777 (inherit source-package)
778 (name package-name)
779 (build-system emacs-build-system)
780 (source (origin
781 (method (origin-method orig))
782 (uri (origin-uri orig))
783 (sha256 (origin-sha256 orig))
784 (file-name (string-append package-name "-"
785 (package-version source-package)))
786 (modules '((guix build utils)
787 (srfi srfi-1)
788 (ice-9 ftw)))
789 (snippet
790 `(let* ((source-files (quote ,source-files))
791 (basenames (map basename source-files)))
792 (map copy-file
793 source-files basenames)
794 (map delete-file-recursively
795 (fold delete
796 (scandir ".")
797 (append '("." "..") basenames)))
798 #t)))))))
799
7628ff1f
TG
800(define-public emacs-clang-format
801 (package
802 (inherit clang)
803 (name "emacs-clang-format")
804 (build-system emacs-build-system)
805 (inputs
806 `(("clang" ,clang)))
807 (arguments
808 `(#:phases
809 (modify-phases %standard-phases
810 (add-after 'unpack 'configure
811 (lambda* (#:key inputs #:allow-other-keys)
812 (let ((clang (assoc-ref inputs "clang")))
813 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
814 (emacs-substitute-variables "clang-format.el"
815 ("clang-format-executable"
816 (string-append clang "/bin/clang-format"))))
817 #t)))))
818 (synopsis "Format code using clang-format")
819 (description "This package allows to filter code through @code{clang-format}
820to fix its formatting. @code{clang-format} is a tool that formats
821C/C++/Obj-C code according to a set of style options, see
3bdcc668 822@url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
51002b72
PN
823
824(define-public emacs-clang-rename
825 (package
826 (inherit clang)
827 (name "emacs-clang-rename")
828 (build-system emacs-build-system)
829 (inputs
830 `(("clang" ,clang)))
831 (arguments
832 `(#:phases
833 (modify-phases %standard-phases
834 (add-after 'unpack 'configure
835 (lambda* (#:key inputs #:allow-other-keys)
836 (let ((clang (assoc-ref inputs "clang")))
837 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
838 (emacs-substitute-variables "clang-rename.el"
839 ("clang-rename-binary"
840 (string-append clang "/bin/clang-rename"))))
841 #t)))))
842 (synopsis "Rename every occurrence of a symbol using clang-rename")
843 (description "This package renames every occurrence of a symbol at point
844using @code{clang-rename}.")))