gnu: Add python-doc8.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
CommitLineData
3e4249ce 1;;; GNU Guix --- Functional package management for GNU
fc9dbf41 2;;; Copyright © 2014, 2016, 2018 Eric Bavier <bavier@member.fsf.org>
1204c510 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
193192ca 4;;; Copyright © 2015, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
ee077430 5;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
290b55c5 6;;; Copyright © 2016, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
584da12d 7;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
233deb82 8;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
e2170c31 9;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
0627f93d 10;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
7628ff1f
TG
11;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
12;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
c5296e20 13;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com>
5dea5cbc 14;;; Copyright © 2019 Arm Ltd <David.Truby@arm.com>
57c7bfec 15;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
66087272 16;;; Copyright © 2019 Brett Gilio <brettg@gnu.org>
3e4249ce
EB
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)
ac00973c 35 #:use-module ((guix licenses) #:prefix license:)
3e4249ce 36 #:use-module (guix download)
a2cc25ab 37 #:use-module (guix git-download)
3e4249ce
EB
38 #:use-module (guix utils)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system cmake)
7628ff1f 41 #:use-module (guix build-system emacs)
8892cac3 42 #:use-module (guix build-system python)
57c7bfec 43 #:use-module (guix build-system trivial)
3e4249ce 44 #:use-module (gnu packages)
57c7bfec 45 #:use-module (gnu packages base)
fd6ae1b9
LC
46 #:use-module (gnu packages gcc)
47 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
ee077430
EB
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages libffi)
698e91f0 50 #:use-module (gnu packages mpi)
290b55c5 51 #:use-module (gnu packages onc-rpc)
3e4249ce 52 #:use-module (gnu packages perl)
698e91f0 53 #:use-module (gnu packages pkg-config)
3e4249ce 54 #:use-module (gnu packages python)
96a9a8d3
LC
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
63as \"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"))))
3e4249ce 79
cd16014f
MB
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
193192ca 87(define-public llvm-10
3e4249ce
EB
88 (package
89 (name "llvm")
193192ca 90 (version "10.0.0")
3e4249ce
EB
91 (source
92 (origin
93 (method url-fetch)
cd16014f 94 (uri (llvm-download-uri "llvm" version))
3e4249ce
EB
95 (sha256
96 (base32
193192ca 97 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))
3e4249ce
EB
98 (build-system cmake-build-system)
99 (native-inputs
3ebc0905 100 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
3e4249ce 101 ("perl" ,perl)))
ee077430 102 (inputs
44e8559d
EB
103 `(("libffi" ,libffi)))
104 (propagated-inputs
105 `(("zlib" ,zlib))) ;to use output from llvm-config
3e4249ce 106 (arguments
22d0e9b7 107 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
ee077430 108 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
ab78618f 109 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
22897187 110 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
fc9dbf41 111 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
22897187 112 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
0935fb27
EB
113
114 ;; Don't use '-g' during the build, to save space.
ab78618f
EB
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)))))
ac97dce1 126 (home-page "https://www.llvm.org")
3e4249ce
EB
127 (synopsis "Optimizing compiler infrastructure")
128 (description
e881752c
AK
129 "LLVM is a compiler infrastructure designed for compile-time, link-time,
130runtime, and idle-time optimization of programs from arbitrary programming
131languages. It currently supports compilation of C and C++ programs, using
132front-ends derived from GCC 4.0.1. A new front-end for the C family of
133languages is in development. The compiler infrastructure includes mirror sets
134of programming tools as well as libraries with equivalent functionality.")
00ede157 135 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
f5de2b9a 136
6b26f915
LC
137(define* (clang-runtime-from-llvm llvm hash
138 #:optional (patches '()))
b81f5693
AW
139 (package
140 (name "clang-runtime")
141 (version (package-version llvm))
142 (source
143 (origin
144 (method url-fetch)
cd16014f 145 (uri (llvm-download-uri "compiler-rt" version))
6b26f915
LC
146 (sha256 (base32 hash))
147 (patches (map search-patch patches))))
b81f5693
AW
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.
3b956a33
EB
154 #:build-type "Release"
155 #:tests? #f)) ; Tests require gtest
ac97dce1 156 (home-page "https://compiler-rt.llvm.org")
b81f5693
AW
157 (synopsis "Runtime library for Clang/LLVM")
158 (description
159 "The \"clang-runtime\" library provides the implementations of run-time
160functions for C and C++ programs. It also provides header files that allow C
161and C++ source code to interface with the \"sanitization\" passes of the clang
162compiler. In LLVM this library is called \"compiler-rt\".")
00ede157 163 (license (package-license llvm))
9e6b9ea4 164
ac97dce1 165 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
9e6b9ea4 166 (supported-systems (delete "mips64el-linux" %supported-systems))))
b81f5693 167
3b956a33 168(define* (clang-from-llvm llvm clang-runtime hash
9bdbabe9 169 #:key (patches '()))
3e4249ce
EB
170 (package
171 (name "clang")
172 (version (package-version llvm))
173 (source
174 (origin
175 (method url-fetch)
cd16014f
MB
176 (uri (llvm-download-uri (if (version>=? version "9.0.1")
177 "clang"
178 "cfe")
179 version))
fd6ae1b9 180 (sha256 (base32 hash))
3b956a33 181 (patches (map search-patch patches))))
3e4249ce
EB
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)
c92f1c0a 189 ("gcc-lib" ,gcc "lib")
3e4249ce
EB
190 ,@(package-inputs llvm)))
191 (propagated-inputs
b81f5693
AW
192 `(("llvm" ,llvm)
193 ("clang-runtime" ,clang-runtime)))
fd6ae1b9
LC
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
94585e88
LC
207 ;; Don't use '-g' during the build to save space.
208 #:build-type "Release"
209
fd6ae1b9 210 #:phases (modify-phases %standard-phases
f5cc5de8
MB
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))
5041cc28
MB
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 "\"")))
9bdbabe9 240
5041cc28
MB
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"))
9bdbabe9 246
5041cc28
MB
247 ;; Make clang look for libstdc++ in the right
248 ;; location.
249 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
250 (string-append
251 "LibStdCXXIncludePathCandidates[] = { \"" gcc
252 "/include/c++\","))
496bbeee 253
5041cc28
MB
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))))
9bdbabe9 265
5041cc28
MB
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 "\"")))))
9bdbabe9 275
5041cc28
MB
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)))
1c7372a5
PN
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")
ad8a4a66
PN
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"))
1c7372a5 299 ;; Install bash completion.
ad8a4a66
PN
300 (when (file-exists? "bash-autocomplete.sh")
301 (mkdir-p compl-dir)
302 (rename-file "bash-autocomplete.sh"
303 (string-append compl-dir "/clang")))))
1c7372a5 304 #t)))))
ef11ac87
LC
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
ac97dce1 315 (home-page "https://clang.llvm.org")
3e4249ce
EB
316 (synopsis "C language family frontend for LLVM")
317 (description
318 "Clang is a compiler front end for the C, C++, Objective-C and
319Objective-C++ programming languages. It uses LLVM as its back end. The Clang
320project includes the Clang front end, the Clang static analyzer, and several
321code analysis tools.")
00ede157
MB
322 (license (if (version>=? version "9.0")
323 license:asl2.0 ;with LLVM exceptions
324 license:ncsa))))
1204c510 325
57c7bfec
MO
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++
360development to be installed in user profiles. This includes Clang, as well as
361libc (headers and binaries, plus debugging symbols in the @code{debug}
362output), 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
193192ca
LC
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
b81f5693 397 (clang-runtime-from-llvm
193192ca 398 llvm-9
00ede157 399 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"))
b81f5693 400
193192ca
LC
401(define-public clang-9
402 (clang-from-llvm llvm-9 clang-runtime-9
00ede157
MB
403 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
404 #:patches '("clang-9.0-libc-search-path.patch")))
d199a4c7 405
193192ca
LC
406(define-public clang-toolchain-9
407 (make-clang-toolchain clang-9))
57c7bfec 408
193192ca
LC
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)
00ede157
MB
414
415(define-public llvm-8
96d5a206
DT
416 (package
417 (inherit llvm)
00ede157 418 (version "8.0.0")
96d5a206
DT
419 (source (origin
420 (method url-fetch)
cd16014f 421 (uri (llvm-download-uri "llvm" version))
96d5a206
DT
422 (sha256
423 (base32
00ede157
MB
424 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
425 (license license:ncsa)))
96d5a206 426
00ede157 427(define-public clang-runtime-8
96d5a206 428 (clang-runtime-from-llvm
00ede157
MB
429 llvm-8
430 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"))
96d5a206 431
00ede157
MB
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")))
96d5a206 436
00ede157
MB
437(define-public clang-toolchain-8
438 (make-clang-toolchain clang-8))
96d5a206 439
4289d1d7
MB
440(define-public llvm-7
441 (package
00ede157 442 (inherit llvm-8)
4289d1d7
MB
443 (version "7.0.1")
444 (source (origin
445 (method url-fetch)
cd16014f 446 (uri (llvm-download-uri "llvm" version))
4289d1d7
MB
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
501672d7 457 (clang-from-llvm llvm-7 clang-runtime-7
4289d1d7
MB
458 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
459 #:patches '("clang-7.0-libc-search-path.patch")))
460
57c7bfec
MO
461(define-public clang-toolchain-7
462 (make-clang-toolchain clang-7))
463
d199a4c7
MB
464(define-public llvm-6
465 (package
00ede157 466 (inherit llvm-7)
d199a4c7
MB
467 (version "6.0.1")
468 (source (origin
469 (method url-fetch)
cd16014f 470 (uri (llvm-download-uri "llvm" version))
d199a4c7
MB
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
501672d7 481 (clang-from-llvm llvm-6 clang-runtime-6
148df605 482 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
9bdbabe9 483 #:patches '("clang-6.0-libc-search-path.patch")))
3b956a33 484
57c7bfec
MO
485(define-public clang-toolchain-6
486 (make-clang-toolchain clang-6))
487
584da12d 488(define-public llvm-3.9.1
00ede157 489 (package (inherit llvm-6)
584da12d
RJ
490 (name "llvm")
491 (version "3.9.1")
492 (source
493 (origin
494 (method url-fetch)
cd16014f 495 (uri (llvm-download-uri "llvm" version))
584da12d
RJ
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
6b26f915
LC
503 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
504 '("clang-runtime-asan-build-fixes.patch"
0627f93d 505 "clang-runtime-esan-build-fixes.patch"
1a2d8d06 506 "clang-3.5-libsanitizer-ustat-fix.patch")))
584da12d
RJ
507
508(define-public clang-3.9.1
509 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
510 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
9bdbabe9
MB
511 #:patches '("clang-3.8-libc-search-path.patch")))
512
513(define-public llvm-3.8
00ede157 514 (package (inherit llvm-3.9.1)
9bdbabe9
MB
515 (name "llvm")
516 (version "3.8.1")
517 (source
518 (origin
519 (method url-fetch)
cd16014f 520 (uri (llvm-download-uri "llvm" version))
9bdbabe9
MB
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"
0627f93d 529 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 530 "clang-3.5-libsanitizer-ustat-fix.patch")))
9bdbabe9
MB
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")))
584da12d 536
3b956a33 537(define-public llvm-3.7
00ede157 538 (package (inherit llvm-3.8)
3b956a33
EB
539 (version "3.7.1")
540 (source
541 (origin
542 (method url-fetch)
cd16014f 543 (uri (llvm-download-uri "llvm" version))
3b956a33
EB
544 (sha256
545 (base32
546 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
547
548(define-public clang-runtime-3.7
549 (clang-runtime-from-llvm
550 llvm-3.7
6b26f915 551 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
0627f93d 552 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 553 "clang-3.5-libsanitizer-ustat-fix.patch")))
3b956a33
EB
554
555(define-public clang-3.7
556 (clang-from-llvm llvm-3.7 clang-runtime-3.7
9bdbabe9
MB
557 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
558 #:patches '("clang-3.5-libc-search-path.patch")))
3ebc0905
EB
559
560(define-public llvm-3.6
00ede157 561 (package (inherit llvm-3.7)
3ebc0905
EB
562 (version "3.6.2")
563 (source
564 (origin
565 (method url-fetch)
cd16014f 566 (uri (llvm-download-uri "llvm" version))
3ebc0905
EB
567 (sha256
568 (base32
569 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
570
571(define-public clang-runtime-3.6
572 (clang-runtime-from-llvm
573 llvm-3.6
6b26f915
LC
574 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
575 '("clang-runtime-asan-build-fixes.patch")))
3ebc0905
EB
576
577(define-public clang-3.6
578 (clang-from-llvm llvm-3.6 clang-runtime-3.6
9bdbabe9
MB
579 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
580 #:patches '("clang-3.5-libc-search-path.patch")))
1204c510
MW
581
582(define-public llvm-3.5
00ede157 583 (package (inherit llvm-3.6)
a53c486d 584 (version "3.5.2")
1204c510
MW
585 (source
586 (origin
587 (method url-fetch)
cd16014f 588 (uri (llvm-download-uri "llvm" version))
6ba4eca2
RW
589 (patches
590 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1204c510
MW
591 (sha256
592 (base32
a53c486d 593 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1204c510 594
b81f5693 595(define-public clang-runtime-3.5
290b55c5
RW
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))))))
b81f5693 623
1204c510 624(define-public clang-3.5
b81f5693 625 (clang-from-llvm llvm-3.5 clang-runtime-3.5
9bdbabe9
MB
626 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
627 #:patches '("clang-3.5-libc-search-path.patch")))
921cb13a
RW
628
629(define-public llvm-for-extempore
630 (package (inherit llvm-3.7)
7355634d 631 (name "llvm-for-extempore")
921cb13a
RW
632 (source
633 (origin
634 (inherit (package-source llvm-3.7))
39162ee4
RW
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"))))
8892cac3 638
52f9c3b8
MB
639(define-public libcxx
640 (package
641 (name "libcxx")
00ede157 642 (version "9.0.1")
52f9c3b8
MB
643 (source
644 (origin
645 (method url-fetch)
646 (uri (llvm-download-uri "libcxx" version))
647 (sha256
648 (base32
00ede157 649 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
52f9c3b8
MB
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
658use 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")
00ede157 680 (version "9.0.1")
52f9c3b8
MB
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
00ede157 690 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
52f9c3b8
MB
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
712requirements 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")
00ede157 719 (version "9.0.1")
52f9c3b8
MB
720 (source (origin
721 (method url-fetch)
722 (uri (llvm-download-uri "openmp" version))
723 (sha256
724 (base32
00ede157 725 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
52f9c3b8
MB
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
746project for the OpenMP multi-theaded programming extension. This package
747notably provides @file{libgomp.so}, which is has a binary interface compatible
748with that of libgomp, the GNU Offloading and Multi Processing Library.")
749 (license license:expat)))
750
8892cac3
RW
751(define-public python-llvmlite
752 (package
753 (name "python-llvmlite")
66087272 754 (version "0.30.0")
8892cac3
RW
755 (source
756 (origin
757 (method url-fetch)
758 (uri (pypi-uri "llvmlite" version))
759 (sha256
760 (base32
66087272 761 "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf"))))
8892cac3 762 (build-system python-build-system)
66087272
BG
763 (arguments
764 ;; FIXME: One test fails unable to find libm.so
765 ;; https://github.com/numba/llvmlite/issues/537
766 `(#:tests? #f))
8892cac3
RW
767 (inputs
768 `(("llvm"
769 ,(package
4289d1d7 770 (inherit llvm-7)
8892cac3 771 (source (origin
4289d1d7 772 (inherit (package-source llvm-7))
8892cac3
RW
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/"
f9325407 779 "D47188-svml-VF.patch"))
8892cac3
RW
780 (sha256
781 (base32
f9325407 782 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
8892cac3
RW
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
7a20877a 790 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
8892cac3
RW
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)))
7628ff1f 796
67eebb19
LC
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
800SOURCE-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
7628ff1f
TG
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")
3bb22e54 845 (description "This package filters code through @code{clang-format}
7628ff1f
TG
846to fix its formatting. @code{clang-format} is a tool that formats
847C/C++/Obj-C code according to a set of style options, see
3bdcc668 848@url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
51002b72
PN
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
870using @code{clang-rename}.")))