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