gnu: emacs-sly: Update to 20200228.
[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, 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
88 (package
89 (name "llvm")
90 (version "9.0.1")
91 (source
92 (origin
93 (method url-fetch)
94 (uri (llvm-download-uri "llvm" version))
95 (sha256
96 (base32
97 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))))
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
372 (clang-runtime-from-llvm
373 llvm
374 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"))
375
376 (define-public clang
377 (clang-from-llvm llvm clang-runtime
378 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
379 #:patches '("clang-9.0-libc-search-path.patch")))
380
381 (define-public clang-toolchain
382 (make-clang-toolchain clang))
383
384 (define-public llvm-9 llvm)
385 (define-public clang-runtime-9 clang-runtime)
386 (define-public clang-9 clang)
387 (define-public clang-toolchain-9 clang-toolchain)
388
389 (define-public llvm-8
390 (package
391 (inherit llvm)
392 (version "8.0.0")
393 (source (origin
394 (method url-fetch)
395 (uri (llvm-download-uri "llvm" version))
396 (sha256
397 (base32
398 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
399 (license license:ncsa)))
400
401 (define-public clang-runtime-8
402 (clang-runtime-from-llvm
403 llvm-8
404 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"))
405
406 (define-public clang-8
407 (clang-from-llvm llvm-8 clang-runtime-8
408 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
409 #:patches '("clang-7.0-libc-search-path.patch")))
410
411 (define-public clang-toolchain-8
412 (make-clang-toolchain clang-8))
413
414 (define-public llvm-7
415 (package
416 (inherit llvm-8)
417 (version "7.0.1")
418 (source (origin
419 (method url-fetch)
420 (uri (llvm-download-uri "llvm" version))
421 (sha256
422 (base32
423 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
424
425 (define-public clang-runtime-7
426 (clang-runtime-from-llvm
427 llvm-7
428 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"))
429
430 (define-public clang-7
431 (clang-from-llvm llvm-7 clang-runtime-7
432 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
433 #:patches '("clang-7.0-libc-search-path.patch")))
434
435 (define-public clang-toolchain-7
436 (make-clang-toolchain clang-7))
437
438 (define-public llvm-6
439 (package
440 (inherit llvm-7)
441 (version "6.0.1")
442 (source (origin
443 (method url-fetch)
444 (uri (llvm-download-uri "llvm" version))
445 (sha256
446 (base32
447 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
448
449 (define-public clang-runtime-6
450 (clang-runtime-from-llvm
451 llvm-6
452 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"))
453
454 (define-public clang-6
455 (clang-from-llvm llvm-6 clang-runtime-6
456 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
457 #:patches '("clang-6.0-libc-search-path.patch")))
458
459 (define-public clang-toolchain-6
460 (make-clang-toolchain clang-6))
461
462 (define-public llvm-3.9.1
463 (package (inherit llvm-6)
464 (name "llvm")
465 (version "3.9.1")
466 (source
467 (origin
468 (method url-fetch)
469 (uri (llvm-download-uri "llvm" version))
470 (sha256
471 (base32
472 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
473
474 (define-public clang-runtime-3.9.1
475 (clang-runtime-from-llvm
476 llvm-3.9.1
477 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
478 '("clang-runtime-asan-build-fixes.patch"
479 "clang-runtime-esan-build-fixes.patch"
480 "clang-3.5-libsanitizer-ustat-fix.patch")))
481
482 (define-public clang-3.9.1
483 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
484 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
485 #:patches '("clang-3.8-libc-search-path.patch")))
486
487 (define-public llvm-3.8
488 (package (inherit llvm-3.9.1)
489 (name "llvm")
490 (version "3.8.1")
491 (source
492 (origin
493 (method url-fetch)
494 (uri (llvm-download-uri "llvm" version))
495 (sha256
496 (base32
497 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
498
499 (define-public clang-runtime-3.8
500 (clang-runtime-from-llvm
501 llvm-3.8
502 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
503 '("clang-runtime-asan-build-fixes.patch"
504 "clang-3.5-libsanitizer-ustat-fix.patch")))
505
506 (define-public clang-3.8
507 (clang-from-llvm llvm-3.8 clang-runtime-3.8
508 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
509 #:patches '("clang-3.8-libc-search-path.patch")))
510
511 (define-public llvm-3.7
512 (package (inherit llvm-3.8)
513 (version "3.7.1")
514 (source
515 (origin
516 (method url-fetch)
517 (uri (llvm-download-uri "llvm" version))
518 (sha256
519 (base32
520 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
521
522 (define-public clang-runtime-3.7
523 (clang-runtime-from-llvm
524 llvm-3.7
525 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
526 '("clang-runtime-asan-build-fixes.patch"
527 "clang-3.5-libsanitizer-ustat-fix.patch")))
528
529 (define-public clang-3.7
530 (clang-from-llvm llvm-3.7 clang-runtime-3.7
531 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
532 #:patches '("clang-3.5-libc-search-path.patch")))
533
534 (define-public llvm-3.6
535 (package (inherit llvm-3.7)
536 (version "3.6.2")
537 (source
538 (origin
539 (method url-fetch)
540 (uri (llvm-download-uri "llvm" version))
541 (sha256
542 (base32
543 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
544
545 (define-public clang-runtime-3.6
546 (clang-runtime-from-llvm
547 llvm-3.6
548 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
549 '("clang-runtime-asan-build-fixes.patch")))
550
551 (define-public clang-3.6
552 (clang-from-llvm llvm-3.6 clang-runtime-3.6
553 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
554 #:patches '("clang-3.5-libc-search-path.patch")))
555
556 (define-public llvm-3.5
557 (package (inherit llvm-3.6)
558 (version "3.5.2")
559 (source
560 (origin
561 (method url-fetch)
562 (uri (llvm-download-uri "llvm" version))
563 (patches
564 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
565 (sha256
566 (base32
567 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
568
569 (define-public clang-runtime-3.5
570 (let ((runtime (clang-runtime-from-llvm
571 llvm-3.5
572 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
573 '("clang-runtime-asan-build-fixes.patch"
574 "clang-3.5-libsanitizer-ustat-fix.patch"))))
575 (package
576 (inherit runtime)
577 (arguments
578 (substitute-keyword-arguments (package-arguments runtime)
579 ((#:phases phases '%standard-phases)
580 `(modify-phases ,phases
581 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
582 ;; libtirpc.
583 (add-after 'unpack 'find-rpc-includes
584 (lambda* (#:key inputs #:allow-other-keys)
585 (setenv "CPATH"
586 (string-append (assoc-ref inputs "libtirpc")
587 "/include/tirpc/:"
588 (or (getenv "CPATH") "")))
589 (setenv "CPLUS_INCLUDE_PATH"
590 (string-append (assoc-ref inputs "libtirpc")
591 "/include/tirpc/:"
592 (or (getenv "CPLUS_INCLUDE_PATH") "")))
593 #t))))))
594 (inputs
595 `(("libtirpc" ,libtirpc)
596 ("llvm" ,llvm-3.5))))))
597
598 (define-public clang-3.5
599 (clang-from-llvm llvm-3.5 clang-runtime-3.5
600 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
601 #:patches '("clang-3.5-libc-search-path.patch")))
602
603 (define-public llvm-for-extempore
604 (package (inherit llvm-3.7)
605 (name "llvm-for-extempore")
606 (source
607 (origin
608 (inherit (package-source llvm-3.7))
609 (patches (list (search-patch "llvm-for-extempore.patch")))))
610 ;; Extempore refuses to build on architectures other than x86_64
611 (supported-systems '("x86_64-linux"))))
612
613 (define-public libcxx
614 (package
615 (name "libcxx")
616 (version "9.0.1")
617 (source
618 (origin
619 (method url-fetch)
620 (uri (llvm-download-uri "libcxx" version))
621 (sha256
622 (base32
623 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
624 (build-system cmake-build-system)
625 (native-inputs
626 `(("clang" ,clang)
627 ("llvm" ,llvm)))
628 (home-page "https://libcxx.llvm.org")
629 (synopsis "C++ standard library")
630 (description
631 "This package provides an implementation of the C++ standard library for
632 use with Clang, targeting C++11, C++14 and above.")
633 (license license:expat)))
634
635 ;; Libcxx files specifically used by PySide2.
636 (define-public libcxx-6
637 (package
638 (inherit libcxx)
639 (version (package-version llvm-6))
640 (source
641 (origin
642 (inherit (package-source libcxx))
643 (uri (llvm-download-uri "libcxx" version))
644 (sha256
645 (base32
646 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
647 (native-inputs
648 `(("clang" ,clang-6)
649 ("llvm" ,llvm-6)))))
650
651 (define-public libclc
652 (package
653 (name "libclc")
654 (version "9.0.1")
655 (source
656 (origin
657 (method git-fetch)
658 (uri (git-reference
659 (url "https://github.com/llvm/llvm-project.git")
660 (commit (string-append "llvmorg-" version))))
661 (file-name (git-file-name name version))
662 (sha256
663 (base32
664 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
665 (build-system cmake-build-system)
666 (arguments
667 `(#:configure-flags
668 (list (string-append "-DLLVM_CLANG="
669 (assoc-ref %build-inputs "clang")
670 "/bin/clang")
671 (string-append "-DPYTHON="
672 (assoc-ref %build-inputs "python")
673 "/bin/python3"))
674 #:phases
675 (modify-phases %standard-phases
676 (add-after 'unpack 'chdir
677 (lambda _ (chdir "libclc") #t)))))
678 (native-inputs
679 `(("clang" ,clang)
680 ("llvm" ,llvm)
681 ("python" ,python)))
682 (home-page "https://libclc.llvm.org")
683 (synopsis "Libraries for the OpenCL programming language")
684 (description
685 "This package provides an implementation of the OpenCL library
686 requirements according to version 1.1 of the OpenCL specification.")
687 ;; Apache license 2.0 with LLVM exception
688 (license license:asl2.0)))
689
690 (define-public libomp
691 (package
692 (name "libomp")
693 (version "9.0.1")
694 (source (origin
695 (method url-fetch)
696 (uri (llvm-download-uri "openmp" version))
697 (sha256
698 (base32
699 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
700 (file-name (string-append "libomp-" version ".tar.xz"))))
701 (build-system cmake-build-system)
702 ;; XXX: Note this gets built with GCC because building with Clang itself
703 ;; fails (missing <atomic>, even when libcxx is added as an input.)
704 (arguments
705 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
706 "-DOPENMP_TEST_C_COMPILER=clang"
707 "-DOPENMP_TEST_CXX_COMPILER=clang++")
708 #:test-target "check-libomp"))
709 (native-inputs
710 `(("clang" ,clang)
711 ("llvm" ,llvm)
712 ("perl" ,perl)
713 ("pkg-config" ,pkg-config)))
714 (inputs
715 `(("hwloc" ,hwloc "lib")))
716 (home-page "https://openmp.llvm.org")
717 (synopsis "OpenMP run-time support library")
718 (description
719 "This package provides the run-time support library developed by the LLVM
720 project for the OpenMP multi-theaded programming extension. This package
721 notably provides @file{libgomp.so}, which is has a binary interface compatible
722 with that of libgomp, the GNU Offloading and Multi Processing Library.")
723 (license license:expat)))
724
725 (define-public python-llvmlite
726 (package
727 (name "python-llvmlite")
728 (version "0.30.0")
729 (source
730 (origin
731 (method url-fetch)
732 (uri (pypi-uri "llvmlite" version))
733 (sha256
734 (base32
735 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
736 (build-system python-build-system)
737 (arguments
738 ;; FIXME: One test fails unable to find libm.so
739 ;; https://github.com/numba/llvmlite/issues/537
740 `(#:tests? #f))
741 (inputs
742 `(("llvm"
743 ,(package
744 (inherit llvm-7)
745 (source (origin
746 (inherit (package-source llvm-7))
747 (patches
748 (list
749 (origin
750 (method url-fetch)
751 (uri (string-append "https://raw.githubusercontent.com/numba/"
752 "llvmlite/v" version "/conda-recipes/"
753 "D47188-svml-VF.patch"))
754 (sha256
755 (base32
756 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
757 (origin
758 (method url-fetch)
759 (uri (string-append "https://raw.githubusercontent.com/numba/"
760 "llvmlite/v" version "/conda-recipes/"
761 "twine_cfg_undefined_behavior.patch"))
762 (sha256
763 (base32
764 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
765 (home-page "http://llvmlite.pydata.org")
766 (synopsis "Wrapper around basic LLVM functionality")
767 (description
768 "This package provides a Python binding to LLVM for use in Numba.")
769 (license license:bsd-3)))
770
771 (define (package-elisp-from-package source-package package-name
772 source-files)
773 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
774 SOURCE-FILES found in SOURCE-PACKAGE."
775 (let ((orig (package-source source-package)))
776 (package
777 (inherit source-package)
778 (name package-name)
779 (build-system emacs-build-system)
780 (source (origin
781 (method (origin-method orig))
782 (uri (origin-uri orig))
783 (sha256 (origin-sha256 orig))
784 (file-name (string-append package-name "-"
785 (package-version source-package)))
786 (modules '((guix build utils)
787 (srfi srfi-1)
788 (ice-9 ftw)))
789 (snippet
790 `(let* ((source-files (quote ,source-files))
791 (basenames (map basename source-files)))
792 (map copy-file
793 source-files basenames)
794 (map delete-file-recursively
795 (fold delete
796 (scandir ".")
797 (append '("." "..") basenames)))
798 #t)))))))
799
800 (define-public emacs-clang-format
801 (package
802 (inherit clang)
803 (name "emacs-clang-format")
804 (build-system emacs-build-system)
805 (inputs
806 `(("clang" ,clang)))
807 (arguments
808 `(#:phases
809 (modify-phases %standard-phases
810 (add-after 'unpack 'configure
811 (lambda* (#:key inputs #:allow-other-keys)
812 (let ((clang (assoc-ref inputs "clang")))
813 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
814 (emacs-substitute-variables "clang-format.el"
815 ("clang-format-executable"
816 (string-append clang "/bin/clang-format"))))
817 #t)))))
818 (synopsis "Format code using clang-format")
819 (description "This package allows to filter code through @code{clang-format}
820 to fix its formatting. @code{clang-format} is a tool that formats
821 C/C++/Obj-C code according to a set of style options, see
822 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
823
824 (define-public emacs-clang-rename
825 (package
826 (inherit clang)
827 (name "emacs-clang-rename")
828 (build-system emacs-build-system)
829 (inputs
830 `(("clang" ,clang)))
831 (arguments
832 `(#:phases
833 (modify-phases %standard-phases
834 (add-after 'unpack 'configure
835 (lambda* (#:key inputs #:allow-other-keys)
836 (let ((clang (assoc-ref inputs "clang")))
837 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
838 (emacs-substitute-variables "clang-rename.el"
839 ("clang-rename-binary"
840 (string-append clang "/bin/clang-rename"))))
841 #t)))))
842 (synopsis "Rename every occurrence of a symbol using clang-rename")
843 (description "This package renames every occurrence of a symbol at point
844 using @code{clang-rename}.")))