gnu: clang@9: Fix search path handling.
[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, 2020 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 ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
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)
35 #:use-module ((guix licenses) #:prefix license:)
36 #:use-module (guix download)
37 #:use-module (guix git-download)
38 #:use-module (guix utils)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system cmake)
41 #:use-module (guix build-system emacs)
42 #:use-module (guix build-system python)
43 #:use-module (guix build-system trivial)
44 #:use-module (gnu packages)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages gcc)
47 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages libffi)
50 #:use-module (gnu packages mpi)
51 #:use-module (gnu packages perl)
52 #:use-module (gnu packages pkg-config)
53 #:use-module (gnu packages python)
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
62 as \"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"))))
78
79 (define-public llvm-8
80 (package
81 (name "llvm")
82 (version "8.0.0")
83 (source
84 (origin
85 (method url-fetch)
86 (uri (string-append "https://llvm.org/releases/"
87 version "/llvm-" version ".src.tar.xz"))
88 (sha256
89 (base32
90 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
91 (build-system cmake-build-system)
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 (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)))))
119 (home-page "https://www.llvm.org")
120 (synopsis "Optimizing compiler infrastructure")
121 (description
122 "LLVM is a compiler infrastructure designed for compile-time, link-time,
123 runtime, and idle-time optimization of programs from arbitrary programming
124 languages. It currently supports compilation of C and C++ programs, using
125 front-ends derived from GCC 4.0.1. A new front-end for the C family of
126 languages is in development. The compiler infrastructure includes mirror sets
127 of programming tools as well as libraries with equivalent functionality.")
128 (license license:ncsa)))
129
130 (define-public llvm llvm-8)
131
132 (define* (clang-runtime-from-llvm llvm hash
133 #:optional (patches '()))
134 (package
135 (name "clang-runtime")
136 (version (package-version llvm))
137 (source
138 (origin
139 (method url-fetch)
140 (uri (string-append "https://llvm.org/releases/"
141 version "/compiler-rt-" version ".src.tar.xz"))
142 (sha256 (base32 hash))
143 (patches (map search-patch patches))))
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.
150 #:build-type "Release"
151 #:tests? #f)) ; Tests require gtest
152 (home-page "https://compiler-rt.llvm.org")
153 (synopsis "Runtime library for Clang/LLVM")
154 (description
155 "The \"clang-runtime\" library provides the implementations of run-time
156 functions for C and C++ programs. It also provides header files that allow C
157 and C++ source code to interface with the \"sanitization\" passes of the clang
158 compiler. In LLVM this library is called \"compiler-rt\".")
159 (license license:ncsa)
160
161 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
162 (supported-systems (delete "mips64el-linux" %supported-systems))))
163
164 (define* (clang-from-llvm llvm clang-runtime hash
165 #:key (patches '()))
166 (package
167 (name "clang")
168 (version (package-version llvm))
169 (source
170 (origin
171 (method url-fetch)
172 (uri (string-append "https://llvm.org/releases/"
173 version "/cfe-" version ".src.tar.xz"))
174 (sha256 (base32 hash))
175 (patches (map search-patch patches))))
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)
183 ("gcc-lib" ,gcc "lib")
184 ,@(package-inputs llvm)))
185 (propagated-inputs
186 `(("llvm" ,llvm)
187 ("clang-runtime" ,clang-runtime)))
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
201 ;; Don't use '-g' during the build to save space.
202 #:build-type "Release"
203
204 #:phases (modify-phases %standard-phases
205 (add-after
206 'unpack 'set-glibc-file-names
207 (lambda* (#:key inputs #:allow-other-keys)
208 (let ((libc (assoc-ref inputs "libc"))
209 (compiler-rt (assoc-ref inputs "clang-runtime"))
210 (gcc (assoc-ref inputs "gcc"))
211 (version
212 (string->number
213 ,(version-major (package-version clang-runtime)))))
214 (cond
215 ((> version 3)
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
227 ;; Make clang look for libstdc++ in the right
228 ;; location.
229 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
230 (string-append
231 "LibStdCXXIncludePathCandidates[] = { \"" gcc "/include/c++\","))
232
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"))))
237 (else
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")))))
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")
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"))
280 ;; Install bash completion.
281 (when (file-exists? "bash-autocomplete.sh")
282 (mkdir-p compl-dir)
283 (rename-file "bash-autocomplete.sh"
284 (string-append compl-dir "/clang")))))
285 #t)))))
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
296 (home-page "https://clang.llvm.org")
297 (synopsis "C language family frontend for LLVM")
298 (description
299 "Clang is a compiler front end for the C, C++, Objective-C and
300 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
301 project includes the Clang front end, the Clang static analyzer, and several
302 code analysis tools.")
303 (license license:ncsa)))
304
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++
339 development to be installed in user profiles. This includes Clang, as well as
340 libc (headers and binaries, plus debugging symbols in the @code{debug}
341 output), 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
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
361 "1qlx3wlxrnc5cwc1fcfc2vhfsl7j4294hi8y5kxj8hy8wxsjd462"))))
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
370 use with Clang, targeting C++11, C++14 and above.")
371 (license license:expat)))
372
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))))
383 (file-name (git-file-name name version))
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
408 requirements according to version 1.1 of the OpenCL specification.")
409 ;; Apache license 2.0 with LLVM exception
410 (license license:asl2.0)))
411
412 (define-public libomp
413 (package
414 (name "libomp")
415 (version (package-version llvm))
416 (source (origin
417 (method url-fetch)
418 (uri (string-append "https://releases.llvm.org/"
419 version "/openmp-" version
420 ".src.tar.xz"))
421 (sha256
422 (base32
423 "1mf9cpgvix34xlpv0inkgl3qmdvgvp96f7sksqizri0n5xfp1cgp"))
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++")
432 #:test-target "check-libomp"))
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
444 project for the OpenMP multi-theaded programming extension. This package
445 notably provides @file{libgomp.so}, which is has a binary interface compatible
446 with that of libgomp, the GNU Offloading and Multi Processing Library.")
447 (license license:expat)))
448
449 (define-public clang-runtime
450 (clang-runtime-from-llvm
451 llvm
452 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"))
453
454 (define-public clang
455 (clang-from-llvm llvm clang-runtime
456 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
457 #:patches '("clang-7.0-libc-search-path.patch")))
458
459 (define-public clang-toolchain
460 (make-clang-toolchain clang))
461
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 #:patches '("clang-9.0-libc-search-path.patch")))
484
485 (define-public clang-toolchain-9
486 (make-clang-toolchain clang-9))
487
488 (define-public llvm-7
489 (package
490 (inherit llvm)
491 (version "7.0.1")
492 (source (origin
493 (method url-fetch)
494 (uri (string-append "https://llvm.org/releases/"
495 version "/llvm-" version ".src.tar.xz"))
496 (sha256
497 (base32
498 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
499
500 (define-public clang-runtime-7
501 (clang-runtime-from-llvm
502 llvm-7
503 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"))
504
505 (define-public clang-7
506 (clang-from-llvm llvm-7 clang-runtime
507 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
508 #:patches '("clang-7.0-libc-search-path.patch")))
509
510 (define-public clang-toolchain-7
511 (make-clang-toolchain clang-7))
512
513 (define-public llvm-6
514 (package
515 (inherit llvm)
516 (version "6.0.1")
517 (source (origin
518 (method url-fetch)
519 (uri (string-append "https://llvm.org/releases/"
520 version "/llvm-" version ".src.tar.xz"))
521 (sha256
522 (base32
523 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
524
525 (define-public clang-runtime-6
526 (clang-runtime-from-llvm
527 llvm-6
528 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"))
529
530 (define-public clang-6
531 (clang-from-llvm llvm-6 clang-runtime
532 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
533 #:patches '("clang-6.0-libc-search-path.patch")))
534
535 (define-public clang-toolchain-6
536 (make-clang-toolchain clang-6))
537
538 ;; Libcxx files specifically used by PySide2.
539 (define-public libcxx-6
540 (package
541 (inherit libcxx)
542 (version (package-version llvm-6))
543 (source
544 (origin
545 (inherit (package-source libcxx))
546 (uri (string-append "http://llvm.org/releases/"
547 version "/libcxx-" version ".src.tar.xz"))
548 (sha256
549 (base32
550 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
551 (native-inputs
552 `(("clang" ,clang-6)
553 ("llvm" ,llvm-6)))))
554
555 (define-public llvm-3.9.1
556 (package (inherit llvm)
557 (name "llvm")
558 (version "3.9.1")
559 (source
560 (origin
561 (method url-fetch)
562 (uri (string-append "https://llvm.org/releases/"
563 version "/llvm-" version ".src.tar.xz"))
564 (sha256
565 (base32
566 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
567
568 (define-public clang-runtime-3.9.1
569 (clang-runtime-from-llvm
570 llvm-3.9.1
571 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
572 '("clang-runtime-asan-build-fixes.patch"
573 "clang-runtime-esan-build-fixes.patch"
574 "clang-3.5-libsanitizer-ustat-fix.patch")))
575
576 (define-public clang-3.9.1
577 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
578 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
579 #:patches '("clang-3.8-libc-search-path.patch")))
580
581 (define-public llvm-3.8
582 (package (inherit llvm)
583 (name "llvm")
584 (version "3.8.1")
585 (source
586 (origin
587 (method url-fetch)
588 (uri (string-append "https://llvm.org/releases/"
589 version "/llvm-" version ".src.tar.xz"))
590 (sha256
591 (base32
592 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
593
594 (define-public clang-runtime-3.8
595 (clang-runtime-from-llvm
596 llvm-3.8
597 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
598 '("clang-runtime-asan-build-fixes.patch"
599 "clang-3.5-libsanitizer-ustat-fix.patch")))
600
601 (define-public clang-3.8
602 (clang-from-llvm llvm-3.8 clang-runtime-3.8
603 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
604 #:patches '("clang-3.8-libc-search-path.patch")))
605
606 (define-public llvm-3.7
607 (package (inherit llvm)
608 (version "3.7.1")
609 (source
610 (origin
611 (method url-fetch)
612 (uri (string-append "https://llvm.org/releases/"
613 version "/llvm-" version ".src.tar.xz"))
614 (sha256
615 (base32
616 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
617
618 (define-public clang-runtime-3.7
619 (clang-runtime-from-llvm
620 llvm-3.7
621 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
622 '("clang-runtime-asan-build-fixes.patch"
623 "clang-3.5-libsanitizer-ustat-fix.patch")))
624
625 (define-public clang-3.7
626 (clang-from-llvm llvm-3.7 clang-runtime-3.7
627 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
628 #:patches '("clang-3.5-libc-search-path.patch")))
629
630 (define-public llvm-3.6
631 (package (inherit llvm)
632 (version "3.6.2")
633 (source
634 (origin
635 (method url-fetch)
636 (uri (string-append "https://llvm.org/releases/"
637 version "/llvm-" version ".src.tar.xz"))
638 (sha256
639 (base32
640 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
641
642 (define-public clang-runtime-3.6
643 (clang-runtime-from-llvm
644 llvm-3.6
645 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
646 '("clang-runtime-asan-build-fixes.patch")))
647
648 (define-public clang-3.6
649 (clang-from-llvm llvm-3.6 clang-runtime-3.6
650 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
651 #:patches '("clang-3.5-libc-search-path.patch")))
652
653 (define-public llvm-3.5
654 (package (inherit llvm)
655 (version "3.5.2")
656 (source
657 (origin
658 (method url-fetch)
659 (uri (string-append "https://llvm.org/releases/"
660 version "/llvm-" version ".src.tar.xz"))
661 (patches
662 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
663 (sha256
664 (base32
665 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
666
667 (define-public clang-runtime-3.5
668 (clang-runtime-from-llvm
669 llvm-3.5
670 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
671 '("clang-runtime-asan-build-fixes.patch"
672 "clang-3.5-libsanitizer-ustat-fix.patch")))
673
674 (define-public clang-3.5
675 (clang-from-llvm llvm-3.5 clang-runtime-3.5
676 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
677 #:patches '("clang-3.5-libc-search-path.patch")))
678
679 (define-public llvm-for-extempore
680 (package (inherit llvm-3.7)
681 (name "llvm-for-extempore")
682 (source
683 (origin
684 (inherit (package-source llvm-3.7))
685 (patches (list (search-patch "llvm-for-extempore.patch")))))
686 ;; Extempore refuses to build on architectures other than x86_64
687 (supported-systems '("x86_64-linux"))))
688
689 (define-public python-llvmlite
690 (package
691 (name "python-llvmlite")
692 (version "0.30.0")
693 (source
694 (origin
695 (method url-fetch)
696 (uri (pypi-uri "llvmlite" version))
697 (sha256
698 (base32
699 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
700 (build-system python-build-system)
701 (arguments
702 ;; FIXME: One test fails unable to find libm.so
703 ;; https://github.com/numba/llvmlite/issues/537
704 `(#:tests? #f))
705 (inputs
706 `(("llvm"
707 ,(package
708 (inherit llvm-7)
709 (source (origin
710 (inherit (package-source llvm-7))
711 (patches
712 (list
713 (origin
714 (method url-fetch)
715 (uri (string-append "https://raw.githubusercontent.com/numba/"
716 "llvmlite/v" version "/conda-recipes/"
717 "D47188-svml-VF.patch"))
718 (sha256
719 (base32
720 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
721 (origin
722 (method url-fetch)
723 (uri (string-append "https://raw.githubusercontent.com/numba/"
724 "llvmlite/v" version "/conda-recipes/"
725 "twine_cfg_undefined_behavior.patch"))
726 (sha256
727 (base32
728 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
729 (home-page "http://llvmlite.pydata.org")
730 (synopsis "Wrapper around basic LLVM functionality")
731 (description
732 "This package provides a Python binding to LLVM for use in Numba.")
733 (license license:bsd-3)))
734
735 (define (package-elisp-from-package source-package package-name
736 source-files)
737 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
738 SOURCE-FILES found in SOURCE-PACKAGE."
739 (let ((orig (package-source source-package)))
740 (package
741 (inherit source-package)
742 (name package-name)
743 (build-system emacs-build-system)
744 (source (origin
745 (method (origin-method orig))
746 (uri (origin-uri orig))
747 (sha256 (origin-sha256 orig))
748 (file-name (string-append package-name "-"
749 (package-version source-package)))
750 (modules '((guix build utils)
751 (srfi srfi-1)
752 (ice-9 ftw)))
753 (snippet
754 `(let* ((source-files (quote ,source-files))
755 (basenames (map basename source-files)))
756 (map copy-file
757 source-files basenames)
758 (map delete-file-recursively
759 (fold delete
760 (scandir ".")
761 (append '("." "..") basenames)))
762 #t)))))))
763
764 (define-public emacs-clang-format
765 (package
766 (inherit clang)
767 (name "emacs-clang-format")
768 (build-system emacs-build-system)
769 (inputs
770 `(("clang" ,clang)))
771 (arguments
772 `(#:phases
773 (modify-phases %standard-phases
774 (add-after 'unpack 'configure
775 (lambda* (#:key inputs #:allow-other-keys)
776 (let ((clang (assoc-ref inputs "clang")))
777 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
778 (emacs-substitute-variables "clang-format.el"
779 ("clang-format-executable"
780 (string-append clang "/bin/clang-format"))))
781 #t)))))
782 (synopsis "Format code using clang-format")
783 (description "This package allows to filter code through @code{clang-format}
784 to fix its formatting. @code{clang-format} is a tool that formats
785 C/C++/Obj-C code according to a set of style options, see
786 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
787
788 (define-public emacs-clang-rename
789 (package
790 (inherit clang)
791 (name "emacs-clang-rename")
792 (build-system emacs-build-system)
793 (inputs
794 `(("clang" ,clang)))
795 (arguments
796 `(#:phases
797 (modify-phases %standard-phases
798 (add-after 'unpack 'configure
799 (lambda* (#:key inputs #:allow-other-keys)
800 (let ((clang (assoc-ref inputs "clang")))
801 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
802 (emacs-substitute-variables "clang-rename.el"
803 ("clang-rename-binary"
804 (string-append clang "/bin/clang-rename"))))
805 #t)))))
806 (synopsis "Rename every occurrence of a symbol using clang-rename")
807 (description "This package renames every occurrence of a symbol at point
808 using @code{clang-rename}.")))