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