gnu: Add llvm-9, clang-9 and clang-toolchain-9.
[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 (native-inputs
92 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
93 ("perl" ,perl)))
94 (inputs
95 `(("libffi" ,libffi)))
96 (propagated-inputs
97 `(("zlib" ,zlib))) ;to use output from llvm-config
98 (arguments
99 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
100 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
101 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
102 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
103 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
104 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
105
106 ;; Don't use '-g' during the build, to save space.
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)))))
118 (home-page "https://www.llvm.org")
119 (synopsis "Optimizing compiler infrastructure")
120 (description
121 "LLVM is a compiler infrastructure designed for compile-time, link-time,
122 runtime, and idle-time optimization of programs from arbitrary programming
123 languages. It currently supports compilation of C and C++ programs, using
124 front-ends derived from GCC 4.0.1. A new front-end for the C family of
125 languages is in development. The compiler infrastructure includes mirror sets
126 of programming tools as well as libraries with equivalent functionality.")
127 (license license:ncsa)))
128
129 (define-public llvm llvm-8)
130
131 (define* (clang-runtime-from-llvm llvm hash
132 #:optional (patches '()))
133 (package
134 (name "clang-runtime")
135 (version (package-version llvm))
136 (source
137 (origin
138 (method url-fetch)
139 (uri (string-append "https://llvm.org/releases/"
140 version "/compiler-rt-" version ".src.tar.xz"))
141 (sha256 (base32 hash))
142 (patches (map search-patch patches))))
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.
149 #:build-type "Release"
150 #:tests? #f)) ; Tests require gtest
151 (home-page "https://compiler-rt.llvm.org")
152 (synopsis "Runtime library for Clang/LLVM")
153 (description
154 "The \"clang-runtime\" library provides the implementations of run-time
155 functions for C and C++ programs. It also provides header files that allow C
156 and C++ source code to interface with the \"sanitization\" passes of the clang
157 compiler. In LLVM this library is called \"compiler-rt\".")
158 (license license:ncsa)
159
160 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
161 (supported-systems (delete "mips64el-linux" %supported-systems))))
162
163 (define* (clang-from-llvm llvm clang-runtime hash
164 #:key (patches '()))
165 (package
166 (name "clang")
167 (version (package-version llvm))
168 (source
169 (origin
170 (method url-fetch)
171 (uri (string-append "https://llvm.org/releases/"
172 version "/cfe-" version ".src.tar.xz"))
173 (sha256 (base32 hash))
174 (patches (map search-patch patches))))
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)
182 ("gcc-lib" ,gcc "lib")
183 ,@(package-inputs llvm)))
184 (propagated-inputs
185 `(("llvm" ,llvm)
186 ("clang-runtime" ,clang-runtime)))
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
200 ;; Don't use '-g' during the build to save space.
201 #:build-type "Release"
202
203 #:phases (modify-phases %standard-phases
204 (add-after
205 'unpack 'set-glibc-file-names
206 (lambda* (#:key inputs #:allow-other-keys)
207 (let ((libc (assoc-ref inputs "libc"))
208 (compiler-rt (assoc-ref inputs "clang-runtime"))
209 (gcc (assoc-ref inputs "gcc"))
210 (version
211 (string->number
212 ,(version-major (package-version clang-runtime)))))
213 (cond
214 ((> version 3)
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
226 ;; Make clang look for libstdc++ in the right
227 ;; location.
228 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
229 (string-append
230 "LibStdCXXIncludePathCandidates[] = { \"" gcc "/include/c++\","))
231
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"))))
236 (else
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")))))
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")
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"))
279 ;; Install bash completion.
280 (when (file-exists? "bash-autocomplete.sh")
281 (mkdir-p compl-dir)
282 (rename-file "bash-autocomplete.sh"
283 (string-append compl-dir "/clang")))))
284 #t)))))
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
295 (home-page "https://clang.llvm.org")
296 (synopsis "C language family frontend for LLVM")
297 (description
298 "Clang is a compiler front end for the C, C++, Objective-C and
299 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
300 project includes the Clang front end, the Clang static analyzer, and several
301 code analysis tools.")
302 (license license:ncsa)))
303
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++
338 development to be installed in user profiles. This includes Clang, as well as
339 libc (headers and binaries, plus debugging symbols in the @code{debug}
340 output), 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
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
360 "1qlx3wlxrnc5cwc1fcfc2vhfsl7j4294hi8y5kxj8hy8wxsjd462"))))
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
369 use with Clang, targeting C++11, C++14 and above.")
370 (license license:expat)))
371
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))))
382 (file-name (git-file-name name version))
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
407 requirements according to version 1.1 of the OpenCL specification.")
408 ;; Apache license 2.0 with LLVM exception
409 (license license:asl2.0)))
410
411 (define-public libomp
412 (package
413 (name "libomp")
414 (version (package-version llvm))
415 (source (origin
416 (method url-fetch)
417 (uri (string-append "https://releases.llvm.org/"
418 version "/openmp-" version
419 ".src.tar.xz"))
420 (sha256
421 (base32
422 "1mf9cpgvix34xlpv0inkgl3qmdvgvp96f7sksqizri0n5xfp1cgp"))
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++")
431 #:test-target "check-libomp"))
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
443 project for the OpenMP multi-theaded programming extension. This package
444 notably provides @file{libgomp.so}, which is has a binary interface compatible
445 with that of libgomp, the GNU Offloading and Multi Processing Library.")
446 (license license:expat)))
447
448 (define-public clang-runtime
449 (clang-runtime-from-llvm
450 llvm
451 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"))
452
453 (define-public clang
454 (clang-from-llvm llvm clang-runtime
455 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
456 #:patches '("clang-7.0-libc-search-path.patch")))
457
458 (define-public clang-toolchain
459 (make-clang-toolchain clang))
460
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
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
508 (define-public clang-toolchain-7
509 (make-clang-toolchain clang-7))
510
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
530 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
531 #:patches '("clang-6.0-libc-search-path.patch")))
532
533 (define-public clang-toolchain-6
534 (make-clang-toolchain clang-6))
535
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
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)
560 (uri (string-append "https://llvm.org/releases/"
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
569 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
570 '("clang-runtime-asan-build-fixes.patch"
571 "clang-runtime-esan-build-fixes.patch"
572 "clang-3.5-libsanitizer-ustat-fix.patch")))
573
574 (define-public clang-3.9.1
575 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
576 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
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"
596 '("clang-runtime-asan-build-fixes.patch"
597 "clang-3.5-libsanitizer-ustat-fix.patch")))
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")))
603
604 (define-public llvm-3.7
605 (package (inherit llvm)
606 (version "3.7.1")
607 (source
608 (origin
609 (method url-fetch)
610 (uri (string-append "https://llvm.org/releases/"
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
619 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
620 '("clang-runtime-asan-build-fixes.patch"
621 "clang-3.5-libsanitizer-ustat-fix.patch")))
622
623 (define-public clang-3.7
624 (clang-from-llvm llvm-3.7 clang-runtime-3.7
625 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
626 #:patches '("clang-3.5-libc-search-path.patch")))
627
628 (define-public llvm-3.6
629 (package (inherit llvm)
630 (version "3.6.2")
631 (source
632 (origin
633 (method url-fetch)
634 (uri (string-append "https://llvm.org/releases/"
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
643 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
644 '("clang-runtime-asan-build-fixes.patch")))
645
646 (define-public clang-3.6
647 (clang-from-llvm llvm-3.6 clang-runtime-3.6
648 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
649 #:patches '("clang-3.5-libc-search-path.patch")))
650
651 (define-public llvm-3.5
652 (package (inherit llvm)
653 (version "3.5.2")
654 (source
655 (origin
656 (method url-fetch)
657 (uri (string-append "https://llvm.org/releases/"
658 version "/llvm-" version ".src.tar.xz"))
659 (patches
660 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
661 (sha256
662 (base32
663 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
664
665 (define-public clang-runtime-3.5
666 (clang-runtime-from-llvm
667 llvm-3.5
668 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
669 '("clang-runtime-asan-build-fixes.patch"
670 "clang-3.5-libsanitizer-ustat-fix.patch")))
671
672 (define-public clang-3.5
673 (clang-from-llvm llvm-3.5 clang-runtime-3.5
674 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
675 #:patches '("clang-3.5-libc-search-path.patch")))
676
677 (define-public llvm-for-extempore
678 (package (inherit llvm-3.7)
679 (name "llvm-for-extempore")
680 (source
681 (origin
682 (inherit (package-source llvm-3.7))
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"))))
686
687 (define-public python-llvmlite
688 (package
689 (name "python-llvmlite")
690 (version "0.27.1")
691 (source
692 (origin
693 (method url-fetch)
694 (uri (pypi-uri "llvmlite" version))
695 (sha256
696 (base32
697 "1aq003zbyjnz4q1118h6qx5lfimc8s5fvgskl75j12gxd6pc78a8"))))
698 (build-system python-build-system)
699 (inputs
700 `(("llvm"
701 ,(package
702 (inherit llvm-7)
703 (source (origin
704 (inherit (package-source llvm-7))
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/"
711 "D47188-svml-VF.patch"))
712 (sha256
713 (base32
714 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
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
722 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
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)))
728
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
732 SOURCE-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
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}
778 to fix its formatting. @code{clang-format} is a tool that formats
779 C/C++/Obj-C code according to a set of style options, see
780 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
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
802 using @code{clang-rename}.")))