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