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