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