gnu: Use PACKAGE/INHERIT in more places.
[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 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
19 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
20 ;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
21 ;;;
22 ;;; This file is part of GNU Guix.
23 ;;;
24 ;;; GNU Guix is free software; you can redistribute it and/or modify it
25 ;;; under the terms of the GNU General Public License as published by
26 ;;; the Free Software Foundation; either version 3 of the License, or (at
27 ;;; your option) any later version.
28 ;;;
29 ;;; GNU Guix is distributed in the hope that it will be useful, but
30 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
31 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 ;;; GNU General Public License for more details.
33 ;;;
34 ;;; You should have received a copy of the GNU General Public License
35 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
36
37 (define-module (gnu packages llvm)
38 #:use-module (guix packages)
39 #:use-module ((guix licenses) #:prefix license:)
40 #:use-module (guix download)
41 #:use-module (guix git-download)
42 #:use-module (guix memoization)
43 #:use-module (guix utils)
44 #:use-module (guix build-system gnu)
45 #:use-module (guix build-system cmake)
46 #:use-module (guix build-system emacs)
47 #:use-module (guix build-system python)
48 #:use-module (guix build-system trivial)
49 #:use-module (gnu packages)
50 #:use-module (gnu packages base)
51 #:use-module (gnu packages gcc)
52 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
53 #:use-module (gnu packages compression)
54 #:use-module (gnu packages libedit)
55 #:use-module (gnu packages libffi)
56 #:use-module (gnu packages lua)
57 #:use-module (gnu packages mpi)
58 #:use-module (gnu packages ncurses)
59 #:use-module (gnu packages ocaml)
60 #:use-module (gnu packages onc-rpc)
61 #:use-module (gnu packages perl)
62 #:use-module (gnu packages pkg-config)
63 #:use-module (gnu packages python)
64 #:use-module (gnu packages swig)
65 #:use-module (gnu packages xml)
66 #:export (system->llvm-target))
67
68 (define* (system->llvm-target #:optional
69 (system (or (and=> (%current-target-system)
70 gnu-triplet->nix-system)
71 (%current-system))))
72 "Return the LLVM target name that corresponds to SYSTEM, a system type such
73 as \"x86_64-linux\"."
74 ;; See the 'lib/Target' directory of LLVM for a list of supported targets.
75 (letrec-syntax ((matches (syntax-rules (=>)
76 ((_ (system-prefix => target) rest ...)
77 (if (string-prefix? system-prefix system)
78 target
79 (matches rest ...)))
80 ((_)
81 (error "LLVM target for system is unknown" system)))))
82 (matches ("aarch64" => "AArch64")
83 ("armhf" => "ARM")
84 ("mips64el" => "Mips")
85 ("powerpc" => "PowerPC")
86 ("riscv" => "RISCV")
87 ("x86_64" => "X86")
88 ("i686" => "X86")
89 ("i586" => "X86"))))
90
91 (define (llvm-uri component version)
92 (string-append "https://github.com/llvm/llvm-project/releases/download"
93 "/llvmorg-" version "/" component "-" version ".src.tar.xz"))
94
95 (define* (clang-runtime-from-llvm llvm hash
96 #:optional (patches '()))
97 (package
98 (name "clang-runtime")
99 (version (package-version llvm))
100 (source
101 (origin
102 (method url-fetch)
103 (uri (llvm-uri "compiler-rt" version))
104 (sha256 (base32 hash))
105 (patches (map search-patch patches))))
106 (build-system cmake-build-system)
107 (native-inputs (package-native-inputs llvm))
108 (inputs
109 `(("llvm" ,llvm)))
110 (arguments
111 `(;; Don't use '-g' during the build to save space.
112 #:build-type "Release"
113 #:tests? #f ; Tests require gtest
114 #:modules ((srfi srfi-1)
115 (ice-9 match)
116 ,@%cmake-build-system-modules)
117 #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases)
118 (add-after 'set-paths 'hide-glibc
119 ;; Work around https://issues.guix.info/issue/36882. We need to
120 ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
121 ;; in GCC, at the bottom of GCC include search-path is used.
122 (lambda* (#:key inputs #:allow-other-keys)
123 (let* ((filters '("libc"))
124 (input-directories
125 (filter-map (lambda (input)
126 (match input
127 ((name . dir)
128 (and (not (member name filters))
129 dir))))
130 inputs)))
131 (set-path-environment-variable "CPLUS_INCLUDE_PATH"
132 '("include")
133 input-directories)
134 #t))))))
135 (home-page "https://compiler-rt.llvm.org")
136 (synopsis "Runtime library for Clang/LLVM")
137 (description
138 "The \"clang-runtime\" library provides the implementations of run-time
139 functions for C and C++ programs. It also provides header files that allow C
140 and C++ source code to interface with the \"sanitization\" passes of the clang
141 compiler. In LLVM this library is called \"compiler-rt\".")
142 (license (package-license llvm))
143
144 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
145 (supported-systems (delete "mips64el-linux" %supported-systems))))
146
147 (define* (clang-from-llvm llvm clang-runtime hash
148 #:key (patches '()) tools-extra)
149 "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the
150 given PATCHES. When TOOLS-EXTRA is given, it must point to the
151 'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace',
152 'modularize', and other tools."
153 (package
154 (name "clang")
155 (version (package-version llvm))
156 (source
157 (origin
158 (method url-fetch)
159 (uri (llvm-uri (if (version>=? version "9.0.1")
160 "clang"
161 "cfe")
162 version))
163 (sha256 (base32 hash))
164 (patches (map search-patch patches))))
165 ;; Using cmake allows us to treat llvm as an external library. There
166 ;; doesn't seem to be any way to do this with clang's autotools-based
167 ;; build system.
168 (build-system cmake-build-system)
169 (outputs (if tools-extra '("out" "extra") '("out")))
170 (native-inputs (package-native-inputs llvm))
171 (inputs
172 `(("libxml2" ,libxml2)
173 ("gcc-lib" ,gcc "lib")
174 ,@(package-inputs llvm)
175 ,@(if tools-extra
176 `(("clang-tools-extra" ,tools-extra))
177 '())))
178 (propagated-inputs
179 `(("llvm" ,llvm)
180 ("clang-runtime" ,clang-runtime)))
181 (arguments
182 `(#:configure-flags
183 (list "-DCLANG_INCLUDE_TESTS=True"
184
185 ;; Find libgcc_s, crtbegin.o, and crtend.o.
186 (string-append "-DGCC_INSTALL_PREFIX="
187 (assoc-ref %build-inputs "gcc-lib"))
188
189 ;; Use a sane default include directory.
190 (string-append "-DC_INCLUDE_DIRS="
191 (assoc-ref %build-inputs "libc")
192 "/include"))
193
194 ;; Don't use '-g' during the build to save space.
195 #:build-type "Release"
196
197 #:phases (modify-phases %standard-phases
198 ,@(if tools-extra
199 `((add-after 'unpack 'add-tools-extra
200 (lambda* (#:key inputs #:allow-other-keys)
201 ;; Unpack the 'clang-tools-extra' tarball under
202 ;; tools/.
203 (let ((extra (assoc-ref inputs
204 "clang-tools-extra")))
205 (invoke "tar" "xf" extra)
206 (rename-file ,(string-append
207 "clang-tools-extra-"
208 (package-version llvm)
209 ".src")
210 "tools/extra")
211 #t)))
212 (add-after 'install 'move-extra-tools
213 (lambda* (#:key outputs #:allow-other-keys)
214 ;; Move the extra tools to the "extra" output.
215 ;; These programs alone weigh in at 296 MiB,
216 ;; because they statically-link a whole bunch of
217 ;; Clang libraries.
218 (let* ((out (assoc-ref outputs "out"))
219 (extra (assoc-ref outputs "extra"))
220 (bin (string-append out "/bin"))
221 (bin* (string-append extra "/bin"))
222 (lib (string-append out "/lib")))
223 (define (move program)
224 (rename-file (string-append bin "/" program)
225 (string-append bin* "/"
226 program)))
227
228 (mkdir-p bin*)
229 (for-each move
230 '("clang-apply-replacements"
231 "clang-change-namespace"
232 "clangd"
233 "clang-doc"
234 "clang-include-fixer"
235 "clang-move"
236 "clang-query"
237 "clang-reorder-fields"
238 "clang-tidy"
239 "find-all-symbols"
240 "modularize"
241 "pp-trace"))
242
243 ;; Remove MiBs of .a files coming from
244 ;; 'clang-tools-extra'.
245 (for-each (lambda (component)
246 (delete-file
247 (string-append lib "/libclang"
248 component ".a")))
249 '("ApplyReplacements"
250 "ChangeNamespace"
251 "Daemon"
252 "DaemonTweaks"
253 "Doc"
254 "IncludeFixer"
255 "IncludeFixerPlugin"
256 "Move"))
257 (for-each delete-file
258 (find-files
259 lib
260 "^(libfindAllSymbols|libclangTidy)"))
261 #t))))
262 '())
263 (add-after 'unpack 'add-missing-triplets
264 (lambda _
265 ;; Clang iterates through known triplets to search for
266 ;; GCC's headers, but does not recognize some of the
267 ;; triplets that are used in Guix.
268 (substitute* ,@(if (version>=? version "6.0")
269 '("lib/Driver/ToolChains/Gnu.cpp")
270 '("lib/Driver/ToolChains.cpp"))
271 (("\"aarch64-linux-gnu\"," all)
272 (string-append "\"aarch64-unknown-linux-gnu\", "
273 all))
274 (("\"arm-linux-gnueabihf\"," all)
275 (string-append all
276 " \"arm-unknown-linux-gnueabihf\","))
277 (("\"i686-pc-linux-gnu\"," all)
278 (string-append "\"i686-unknown-linux-gnu\", "
279 all)))
280 #t))
281 (add-after 'unpack 'set-glibc-file-names
282 (lambda* (#:key inputs #:allow-other-keys)
283 (let ((libc (assoc-ref inputs "libc"))
284 (compiler-rt (assoc-ref inputs "clang-runtime"))
285 (gcc (assoc-ref inputs "gcc")))
286 ,@(cond
287 ((version>=? version "6.0")
288 `(;; Link to libclang_rt files from clang-runtime.
289 (substitute* "lib/Driver/ToolChain.cpp"
290 (("getDriver\\(\\)\\.ResourceDir")
291 (string-append "\"" compiler-rt "\"")))
292
293 ;; Make "LibDir" refer to <glibc>/lib so that it
294 ;; uses the right dynamic linker file name.
295 (substitute* "lib/Driver/ToolChains/Linux.cpp"
296 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
297 (string-append declaration "\"" libc "/lib\";\n"))
298
299 ;; Make clang look for libstdc++ in the right
300 ;; location.
301 (("LibStdCXXIncludePathCandidates\\[\\] = \\{")
302 (string-append
303 "LibStdCXXIncludePathCandidates[] = { \"" gcc
304 "/include/c++\","))
305
306 ;; Make sure libc's libdir is on the search path, to
307 ;; allow crt1.o & co. to be found.
308 (("@GLIBC_LIBDIR@")
309 (string-append libc "/lib")))))
310 (else
311 `((substitute* "lib/Driver/Tools.cpp"
312 ;; Patch the 'getLinuxDynamicLinker' function so that
313 ;; it uses the right dynamic linker file name.
314 (("/lib64/ld-linux-x86-64.so.2")
315 (string-append libc
316 ,(glibc-dynamic-linker))))
317
318 ;; Link to libclang_rt files from clang-runtime.
319 ;; This substitution needed slight adjustment in 3.8.
320 ,@(if (version>=? version "3.8")
321 '((substitute* "lib/Driver/Tools.cpp"
322 (("TC\\.getDriver\\(\\)\\.ResourceDir")
323 (string-append "\"" compiler-rt "\""))))
324 '((substitute* "lib/Driver/ToolChain.cpp"
325 (("getDriver\\(\\)\\.ResourceDir")
326 (string-append "\"" compiler-rt "\"")))))
327
328 ;; Make sure libc's libdir is on the search path, to
329 ;; allow crt1.o & co. to be found.
330 (substitute* "lib/Driver/ToolChains.cpp"
331 (("@GLIBC_LIBDIR@")
332 (string-append libc "/lib"))))))
333 #t)))
334 ,@(if (version>=? version "10")
335 `((add-after 'install 'adjust-cmake-file
336 (lambda* (#:key outputs #:allow-other-keys)
337 (let ((out (assoc-ref outputs "out")))
338 ;; Clang generates a CMake file with "targets"
339 ;; for each installed library file. Downstream
340 ;; consumers of the CMake interface can use this
341 ;; to get absolute library locations. Including
342 ;; this file will needlessly assert that _all_
343 ;; libraries are available, which causes problems
344 ;; in Guix because some are removed (see the
345 ;; move-extra-tools phase). Thus, remove the
346 ;; asserts so that the main functionality works.
347 (substitute*
348 (string-append
349 out
350 "/lib/cmake/clang/ClangTargets-release.cmake")
351 (("list\\(APPEND _IMPORT_CHECK_TARGETS.*" all)
352 (string-append "# Disabled by Guix.\n#" all)))
353 #t))))
354 '())
355 ,@(if (version>? version "3.8")
356 `((add-after 'install 'symlink-cfi_blacklist
357 (lambda* (#:key inputs outputs #:allow-other-keys)
358 (let* ((out (assoc-ref outputs "out"))
359 (lib-share (string-append out "/lib/clang/"
360 ,version "/share"))
361 (compiler-rt (assoc-ref inputs "clang-runtime"))
362 ;; The location varies between Clang versions.
363 (cfi-blacklist
364 (cond
365 ((file-exists?
366 (string-append compiler-rt "/cfi_blacklist.txt"))
367 (string-append compiler-rt "/cfi_blacklist.txt"))
368 (else (string-append compiler-rt
369 "/share/cfi_blacklist.txt")))))
370 (mkdir-p lib-share)
371 ;; Symlink cfi_blacklist.txt to where Clang expects
372 ;; to find it.
373 (symlink cfi-blacklist
374 (string-append lib-share "/cfi_blacklist.txt"))
375 #t))))
376 '())
377 (add-after 'install 'install-clean-up-/share/clang
378 (lambda* (#:key outputs #:allow-other-keys)
379 (let* ((out (assoc-ref outputs "out"))
380 (compl-dir (string-append
381 out "/etc/bash_completion.d")))
382 (with-directory-excursion (string-append out
383 "/share/clang")
384 (for-each
385 (lambda (file)
386 (when (file-exists? file)
387 (delete-file file)))
388 ;; Delete extensions for proprietary text editors.
389 '("clang-format-bbedit.applescript"
390 "clang-format-sublime.py"
391 ;; Delete Emacs extensions: see their respective Emacs
392 ;; Guix package instead.
393 "clang-rename.el" "clang-format.el"))
394 ;; Install bash completion.
395 (when (file-exists? "bash-autocomplete.sh")
396 (mkdir-p compl-dir)
397 (rename-file "bash-autocomplete.sh"
398 (string-append compl-dir "/clang")))))
399 #t)))))
400
401 ;; Clang supports the same environment variables as GCC.
402 (native-search-paths
403 (list (search-path-specification
404 (variable "C_INCLUDE_PATH")
405 (files '("include")))
406 (search-path-specification
407 (variable "CPLUS_INCLUDE_PATH")
408 (files '("include/c++" "include")))
409 (search-path-specification
410 (variable "LIBRARY_PATH")
411 (files '("lib" "lib64")))))
412
413 (home-page "https://clang.llvm.org")
414 (synopsis "C language family frontend for LLVM")
415 (description
416 "Clang is a compiler front end for the C, C++, Objective-C and
417 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
418 project includes the Clang front end, the Clang static analyzer, and several
419 code analysis tools.")
420 (license (if (version>=? version "9.0")
421 license:asl2.0 ;with LLVM exceptions
422 license:ncsa))))
423
424 (define (make-clang-toolchain clang)
425 (package
426 (name (string-append (package-name clang) "-toolchain"))
427 (version (package-version clang))
428 (source #f)
429 (build-system trivial-build-system)
430 (arguments
431 '(#:modules ((guix build union))
432 #:builder (begin
433 (use-modules (ice-9 match)
434 (srfi srfi-26)
435 (guix build union))
436
437 (let ((out (assoc-ref %outputs "out")))
438
439 (match %build-inputs
440 (((names . directories) ...)
441 (union-build out directories)))
442
443 ;; Create 'cc' and 'c++' so that one can use it as a
444 ;; drop-in replacement for the default tool chain and
445 ;; have configure scripts find the compiler.
446 (symlink "clang" (string-append out "/bin/cc"))
447 (symlink "clang++" (string-append out "/bin/c++"))
448
449 (union-build (assoc-ref %outputs "debug")
450 (list (assoc-ref %build-inputs
451 "libc-debug")))
452 (union-build (assoc-ref %outputs "static")
453 (list (assoc-ref %build-inputs
454 "libc-static")))
455 #t))))
456
457 (native-search-paths
458 (append (package-native-search-paths clang)
459 (list (search-path-specification ;copied from glibc
460 (variable "GUIX_LOCPATH")
461 (files '("lib/locale"))))))
462 (search-paths (package-search-paths clang))
463
464 (license (package-license clang))
465 (home-page "https://clang.llvm.org")
466 (synopsis "Complete Clang toolchain for C/C++ development")
467 (description "This package provides a complete Clang toolchain for C/C++
468 development to be installed in user profiles. This includes Clang, as well as
469 libc (headers and binaries, plus debugging symbols in the @code{debug}
470 output), and Binutils.")
471 (outputs '("out" "debug" "static"))
472 (inputs `(("clang" ,clang)
473 ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper")))
474 ("binutils" ,binutils)
475 ("libc" ,glibc)
476 ("libc-debug" ,glibc "debug")
477 ("libc-static" ,glibc "static")))))
478
479 (define-public llvm-11
480 (package
481 (name "llvm")
482 (version "11.0.0")
483 (source
484 (origin
485 (method url-fetch)
486 (uri (llvm-uri "llvm" version))
487 (sha256
488 (base32
489 "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi"))))
490 (build-system cmake-build-system)
491 (outputs '("out" "opt-viewer"))
492 (native-inputs
493 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
494 ("perl" ,perl)))
495 (inputs
496 `(("libffi" ,libffi)))
497 (propagated-inputs
498 `(("zlib" ,zlib))) ;to use output from llvm-config
499 (arguments
500 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
501 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
502 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
503 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
504 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
505 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
506
507 ;; Don't use '-g' during the build, to save space.
508 #:build-type "Release"
509 #:phases
510 (modify-phases %standard-phases
511 (add-before 'build 'shared-lib-workaround
512 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
513 ;; doesn't seem to get the correct rpath to be able to run
514 ;; from the build directory. Set LD_LIBRARY_PATH as a
515 ;; workaround.
516 (lambda _
517 (setenv "LD_LIBRARY_PATH"
518 (string-append (getcwd) "/lib"))
519 #t))
520 (add-after 'install 'install-opt-viewer
521 (lambda* (#:key outputs #:allow-other-keys)
522 (let* ((out (assoc-ref outputs "out"))
523 (opt-viewer-out (assoc-ref outputs "opt-viewer"))
524 (opt-viewer-share-dir (string-append opt-viewer-out "/share"))
525 (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer")))
526 (mkdir-p opt-viewer-share-dir)
527 (rename-file (string-append out "/share/opt-viewer")
528 opt-viewer-dir))
529 #t)))))
530 (home-page "https://www.llvm.org")
531 (synopsis "Optimizing compiler infrastructure")
532 (description
533 "LLVM is a compiler infrastructure designed for compile-time, link-time,
534 runtime, and idle-time optimization of programs from arbitrary programming
535 languages. It currently supports compilation of C and C++ programs, using
536 front-ends derived from GCC 4.0.1. A new front-end for the C family of
537 languages is in development. The compiler infrastructure includes mirror sets
538 of programming tools as well as libraries with equivalent functionality.")
539 (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt
540
541 (define-public clang-runtime-11
542 (clang-runtime-from-llvm
543 llvm-11
544 "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip"))
545
546 (define-public clang-11
547 (clang-from-llvm llvm-11 clang-runtime-11
548 "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg"
549 #:patches '("clang-11.0-libc-search-path.patch")
550 #:tools-extra
551 (origin
552 (method url-fetch)
553 (uri (llvm-uri "clang-tools-extra"
554 (package-version llvm-11)))
555 (sha256
556 (base32
557 "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy")))))
558
559 (define-public clang-toolchain-11
560 (make-clang-toolchain clang-11))
561
562 (define-public llvm-10
563 (package
564 (inherit llvm-11)
565 (version "10.0.0")
566 (source
567 (origin
568 (method url-fetch)
569 (uri (llvm-uri "llvm" version))
570 (sha256
571 (base32
572 "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz"))))))
573
574 (define-public clang-runtime-10
575 (clang-runtime-from-llvm
576 llvm-10
577 "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba"))
578
579 (define-public clang-10
580 (clang-from-llvm llvm-10 clang-runtime-10
581 "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8"
582 #:patches '("clang-10.0-libc-search-path.patch")
583 #:tools-extra
584 (origin
585 (method url-fetch)
586 (uri (llvm-uri "clang-tools-extra"
587 (package-version llvm-10)))
588 (sha256
589 (base32
590 "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc")))))
591
592 (define-public clang-toolchain-10
593 (make-clang-toolchain clang-10))
594
595 (define-public llvm-9
596 (package
597 (inherit llvm-10)
598 (version "9.0.1")
599 (source
600 (origin
601 (method url-fetch)
602 (uri (llvm-uri "llvm" version))
603 (sha256
604 (base32
605 "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880"))
606 (patches (search-patches
607 "llvm-9-fix-bitcast-miscompilation.patch"
608 "llvm-9-fix-scev-miscompilation.patch"
609 "llvm-9-fix-lpad-miscompilation.patch"))))))
610
611 (define-public clang-runtime-9
612 (clang-runtime-from-llvm
613 llvm-9
614 "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"
615 '("clang-runtime-9-libsanitizer-mode-field.patch")))
616
617 (define-public clang-9
618 (clang-from-llvm llvm-9 clang-runtime-9
619 "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p"
620 #:patches '("clang-9.0-libc-search-path.patch")))
621
622 (define-public clang-toolchain-9
623 (make-clang-toolchain clang-9))
624
625 (define-public llvm-8
626 (package
627 (inherit llvm-9)
628 (version "8.0.0")
629 (source (origin
630 (method url-fetch)
631 (uri (llvm-uri "llvm" version))
632 (sha256
633 (base32
634 "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8"))))
635 (license license:ncsa)))
636
637 (define-public clang-runtime-8
638 (clang-runtime-from-llvm
639 llvm-8
640 "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl"
641 '("clang-runtime-9-libsanitizer-mode-field.patch")))
642
643 (define-public clang-8
644 (clang-from-llvm llvm-8 clang-runtime-8
645 "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08"
646 #:patches '("clang-7.0-libc-search-path.patch")))
647
648 (define-public clang-toolchain-8
649 (make-clang-toolchain clang-8))
650
651 (define-public llvm-7
652 (package
653 (inherit llvm-8)
654 (version "7.0.1")
655 (source (origin
656 (method url-fetch)
657 (uri (llvm-uri "llvm" version))
658 (sha256
659 (base32
660 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))))
661
662 (define-public clang-runtime-7
663 (clang-runtime-from-llvm
664 llvm-7
665 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"
666 '("clang-runtime-9-libsanitizer-mode-field.patch")))
667
668 (define-public clang-7
669 (clang-from-llvm llvm-7 clang-runtime-7
670 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
671 #:patches '("clang-7.0-libc-search-path.patch")))
672
673 (define-public clang-toolchain-7
674 (make-clang-toolchain clang-7))
675
676 (define-public llvm-6
677 (package
678 (inherit llvm-7)
679 (version "6.0.1")
680 (source (origin
681 (method url-fetch)
682 (uri (llvm-uri "llvm" version))
683 (sha256
684 (base32
685 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
686
687 (define-public clang-runtime-6
688 (clang-runtime-from-llvm
689 llvm-6
690 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"
691 '("clang-runtime-9-libsanitizer-mode-field.patch")))
692
693 (define-public clang-6
694 (clang-from-llvm llvm-6 clang-runtime-6
695 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
696 #:patches '("clang-6.0-libc-search-path.patch")))
697
698 (define-public clang-toolchain-6
699 (make-clang-toolchain clang-6))
700
701 (define-public llvm-3.9.1
702 (package (inherit llvm-6)
703 (name "llvm")
704 (version "3.9.1")
705 (source
706 (origin
707 (method url-fetch)
708 (uri (llvm-uri "llvm" version))
709 (sha256
710 (base32
711 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))
712 (outputs '("out"))
713 (arguments
714 (substitute-keyword-arguments (package-arguments llvm)
715 ((#:phases phases)
716 `(modify-phases ,phases
717 (delete 'install-opt-viewer)))))))
718
719 (define-public clang-runtime-3.9.1
720 (clang-runtime-from-llvm
721 llvm-3.9.1
722 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
723 '("clang-runtime-3.9-libsanitizer-mode-field.patch"
724 "clang-runtime-asan-build-fixes.patch"
725 "clang-runtime-esan-build-fixes.patch"
726 "clang-3.5-libsanitizer-ustat-fix.patch")))
727
728 (define-public clang-3.9.1
729 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
730 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
731 #:patches '("clang-3.8-libc-search-path.patch")))
732
733 (define-public llvm-3.8
734 (package (inherit llvm-3.9.1)
735 (name "llvm")
736 (version "3.8.1")
737 (source
738 (origin
739 (method url-fetch)
740 (uri (llvm-uri "llvm" version))
741 (sha256
742 (base32
743 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
744
745 (define-public clang-runtime-3.8
746 (clang-runtime-from-llvm
747 llvm-3.8
748 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
749 '("clang-runtime-asan-build-fixes.patch"
750 "clang-runtime-3.8-libsanitizer-mode-field.patch"
751 "clang-3.5-libsanitizer-ustat-fix.patch")))
752
753 (define-public clang-3.8
754 (clang-from-llvm llvm-3.8 clang-runtime-3.8
755 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
756 #:patches '("clang-3.8-libc-search-path.patch")))
757
758 (define-public llvm-3.7
759 (package (inherit llvm-3.8)
760 (version "3.7.1")
761 (source
762 (origin
763 (method url-fetch)
764 (uri (llvm-uri "llvm" version))
765 (sha256
766 (base32
767 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
768
769 (define-public clang-runtime-3.7
770 (clang-runtime-from-llvm
771 llvm-3.7
772 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
773 '("clang-runtime-asan-build-fixes.patch"
774 "clang-runtime-3.8-libsanitizer-mode-field.patch"
775 "clang-3.5-libsanitizer-ustat-fix.patch")))
776
777 (define-public clang-3.7
778 (clang-from-llvm llvm-3.7 clang-runtime-3.7
779 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
780 #:patches '("clang-3.5-libc-search-path.patch")))
781
782 (define-public llvm-3.6
783 (package (inherit llvm-3.7)
784 (version "3.6.2")
785 (source
786 (origin
787 (method url-fetch)
788 (uri (llvm-uri "llvm" version))
789 (sha256
790 (base32
791 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
792
793 (define-public clang-runtime-3.6
794 (clang-runtime-from-llvm
795 llvm-3.6
796 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
797 '("clang-runtime-asan-build-fixes.patch")))
798
799 (define-public clang-3.6
800 (clang-from-llvm llvm-3.6 clang-runtime-3.6
801 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
802 #:patches '("clang-3.5-libc-search-path.patch")))
803
804 (define-public llvm-3.5
805 (package (inherit llvm-3.6)
806 (version "3.5.2")
807 (source
808 (origin
809 (method url-fetch)
810 (uri (llvm-uri "llvm" version))
811 (patches
812 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
813 (sha256
814 (base32
815 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
816
817 (define-public clang-runtime-3.5
818 (let ((runtime (clang-runtime-from-llvm
819 llvm-3.5
820 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
821 '("clang-runtime-asan-build-fixes.patch"
822 "clang-runtime-3.5-libsanitizer-mode-field.patch"
823 "clang-3.5-libsanitizer-ustat-fix.patch"))))
824 (package/inherit runtime
825 (arguments
826 (substitute-keyword-arguments (package-arguments runtime)
827 ((#:phases phases '%standard-phases)
828 `(modify-phases ,phases
829 ;; glibc no longer includes rpc/xdr.h, so we use the headers from
830 ;; libtirpc.
831 (add-after 'unpack 'find-rpc-includes
832 (lambda* (#:key inputs #:allow-other-keys)
833 (setenv "CPATH"
834 (string-append (assoc-ref inputs "libtirpc")
835 "/include/tirpc/:"
836 (or (getenv "CPATH") "")))
837 (setenv "CPLUS_INCLUDE_PATH"
838 (string-append (assoc-ref inputs "libtirpc")
839 "/include/tirpc/:"
840 (or (getenv "CPLUS_INCLUDE_PATH") "")))
841 #t))))))
842 (inputs
843 `(("libtirpc" ,libtirpc)
844 ("llvm" ,llvm-3.5))))))
845
846 (define-public clang-3.5
847 (clang-from-llvm llvm-3.5 clang-runtime-3.5
848 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
849 #:patches '("clang-3.5-libc-search-path.patch")))
850
851 ;; Default LLVM and Clang version.
852 (define-public llvm llvm-9)
853 (define-public clang-runtime clang-runtime-9)
854 (define-public clang clang-9)
855 (define-public clang-toolchain clang-toolchain-9)
856
857 (define-public lld
858 (package
859 (name "lld")
860 (version "11.0.0")
861 (source (origin
862 (method url-fetch)
863 (uri (llvm-uri "lld" version))
864 (sha256
865 (base32
866 "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg"))))
867 (build-system cmake-build-system)
868 (inputs
869 `(("llvm" ,llvm-11)))
870 (arguments
871 `(#:build-type "Release"
872 ;; TODO: Tests require the lit tool, which isn't installed by the LLVM
873 ;; package.
874 #:tests? #f))
875 (home-page "https://lld.llvm.org/")
876 (synopsis "Linker from the LLVM project")
877 (description "LLD is a high-performance linker, built as a set of reusable
878 components which highly leverage existing libraries in the larger LLVM Project.")
879 (license license:asl2.0))) ; With LLVM exception
880
881 (define-public lldb
882 (package
883 (name "lldb")
884 (version "11.0.0")
885 (source (origin
886 (method url-fetch)
887 (uri (llvm-uri "lldb" version))
888 (sha256
889 (base32
890 "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45"))))
891 (build-system cmake-build-system)
892 (arguments
893 `(#:configure-flags '("-DCMAKE_CXX_COMPILER=clang++")))
894 (native-inputs
895 `(("pkg-config" ,pkg-config)
896 ("swig" ,swig)))
897 (inputs
898 `(("clang" ,clang-11)
899 ("llvm" ,llvm-11)
900
901 ;; Optional (but recommended) inputs.
902 ("curses" ,ncurses)
903 ("editline" ,libedit)
904 ("liblzma" ,xz)
905 ("libxml2" ,libxml2)
906 ("lua" ,lua)
907 ("python" ,python)))
908 (home-page "https://lldb.llvm.org/")
909 (synopsis "Low level debugger")
910 (description
911 "LLDB is a high performance debugger built as a set of reusable components
912 which highly leverage existing libraries in the larger LLVM project.")
913 (license license:asl2.0))) ;with LLVM exceptions
914
915 (define-public libcxx
916 (package
917 (name "libcxx")
918 (version "9.0.1")
919 (source
920 (origin
921 (method url-fetch)
922 (uri (llvm-uri "libcxx" version))
923 (sha256
924 (base32
925 "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089"))))
926 (build-system cmake-build-system)
927 (arguments
928 `(#:phases
929 (modify-phases (@ (guix build cmake-build-system) %standard-phases)
930 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
931 (lambda* (#:key inputs #:allow-other-keys)
932 (let ((gcc (assoc-ref inputs "gcc")))
933 ;; Hide GCC's C++ headers so that they do not interfere with
934 ;; the ones we are attempting to build.
935 (setenv "CPLUS_INCLUDE_PATH"
936 (string-join (delete (string-append gcc "/include/c++")
937 (string-split (getenv "CPLUS_INCLUDE_PATH")
938 #\:))
939 ":"))
940 (format #t
941 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
942 (getenv "CPLUS_INCLUDE_PATH"))
943 #t))))))
944 (native-inputs
945 `(("clang" ,clang)
946 ("llvm" ,llvm)))
947 (home-page "https://libcxx.llvm.org")
948 (synopsis "C++ standard library")
949 (description
950 "This package provides an implementation of the C++ standard library for
951 use with Clang, targeting C++11, C++14 and above.")
952 (license license:expat)))
953
954 ;; Libcxx files specifically used by PySide2.
955 (define-public libcxx-6
956 (package
957 (inherit libcxx)
958 (version (package-version llvm-6))
959 (source
960 (origin
961 (inherit (package-source libcxx))
962 (uri (llvm-uri "libcxx" version))
963 (sha256
964 (base32
965 "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n"))))
966 (native-inputs
967 `(("clang" ,clang-6)
968 ("llvm" ,llvm-6)))))
969
970 (define-public libclc
971 (package
972 (name "libclc")
973 (version "9.0.1")
974 (source
975 (origin
976 (method git-fetch)
977 (uri (git-reference
978 (url "https://github.com/llvm/llvm-project")
979 (commit (string-append "llvmorg-" version))))
980 (file-name (git-file-name name version))
981 (sha256
982 (base32
983 "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0"))))
984 (build-system cmake-build-system)
985 (arguments
986 `(#:configure-flags
987 (list (string-append "-DLLVM_CLANG="
988 (assoc-ref %build-inputs "clang")
989 "/bin/clang")
990 (string-append "-DPYTHON="
991 (assoc-ref %build-inputs "python")
992 "/bin/python3"))
993 #:phases
994 (modify-phases %standard-phases
995 (add-after 'unpack 'chdir
996 (lambda _ (chdir "libclc") #t)))))
997 (native-inputs
998 `(("clang" ,clang)
999 ("llvm" ,llvm)
1000 ("python" ,python)))
1001 (home-page "https://libclc.llvm.org")
1002 (synopsis "Libraries for the OpenCL programming language")
1003 (description
1004 "This package provides an implementation of the OpenCL library
1005 requirements according to version 1.1 of the OpenCL specification.")
1006 ;; Apache license 2.0 with LLVM exception
1007 (license license:asl2.0)))
1008
1009 (define-public libomp
1010 (package
1011 (name "libomp")
1012 (version "9.0.1")
1013 (source (origin
1014 (method url-fetch)
1015 (uri (llvm-uri "openmp" version))
1016 (sha256
1017 (base32
1018 "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w"))
1019 (file-name (string-append "libomp-" version ".tar.xz"))))
1020 (build-system cmake-build-system)
1021 ;; XXX: Note this gets built with GCC because building with Clang itself
1022 ;; fails (missing <atomic>, even when libcxx is added as an input.)
1023 (arguments
1024 '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON"
1025 "-DOPENMP_TEST_C_COMPILER=clang"
1026 "-DOPENMP_TEST_CXX_COMPILER=clang++")
1027 #:test-target "check-libomp"))
1028 (native-inputs
1029 `(("clang" ,clang)
1030 ("llvm" ,llvm)
1031 ("perl" ,perl)
1032 ("pkg-config" ,pkg-config)))
1033 (inputs
1034 `(("hwloc" ,hwloc "lib")))
1035 (home-page "https://openmp.llvm.org")
1036 (synopsis "OpenMP run-time support library")
1037 (description
1038 "This package provides the run-time support library developed by the LLVM
1039 project for the OpenMP multi-theaded programming extension. This package
1040 notably provides @file{libgomp.so}, which is has a binary interface compatible
1041 with that of libgomp, the GNU Offloading and Multi Processing Library.")
1042 (license license:expat)))
1043
1044 (define-public python-llvmlite
1045 (package
1046 (name "python-llvmlite")
1047 (version "0.34.0")
1048 (source
1049 (origin
1050 (method url-fetch)
1051 (uri (pypi-uri "llvmlite" version))
1052 (sha256
1053 (base32
1054 "0qqzs6h34002ig2jn31vk08q9hh5kn84lhmv4bljz3yakg8y0gph"))))
1055 (build-system python-build-system)
1056 (arguments
1057 `(#:phases
1058 (modify-phases %standard-phases
1059 (add-after 'unpack 'patch-reference-to-llvmlite.so
1060 ;; ctypes.CDLL uses dlopen to load libllvmlite.so, which
1061 ;; fails, so locate it by its absolute path. Change it in
1062 ;; ffi.py, not utils.py, because setup.py relies on the
1063 ;; output of get_library_name for proper installation.
1064 (lambda* (#:key outputs #:allow-other-keys)
1065 (let* ((out (assoc-ref outputs "out"))
1066 (libllvmlite.so (string-append out "/lib/python"
1067 ,(version-major+minor
1068 (package-version python))
1069 "/site-packages/llvmlite/"
1070 "binding/libllvmlite.so")))
1071 (substitute* "llvmlite/binding/ffi.py"
1072 (("_lib_name = get_library_name\\(\\)")
1073 (format #f "_lib_name = ~s" libllvmlite.so)))
1074 #t)))
1075 (add-after 'unpack 'skip-failing-tests
1076 (lambda _
1077 (substitute* "llvmlite/tests/test_binding.py"
1078 ((" def test_libm\\(self\\).*" all)
1079 (string-append " @unittest.skip('Fails on Guix')\n" all)))
1080 #t))
1081 (add-before 'build 'set-compiler/linker-flags
1082 (lambda* (#:key inputs #:allow-other-keys)
1083 (let ((llvm (assoc-ref inputs "llvm")))
1084 ;; Refer to ffi/Makefile.linux.
1085 (setenv "CPPFLAGS" "-fPIC")
1086 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
1087 llvm "/lib"))
1088 #t))))))
1089 (inputs
1090 `(("llvm"
1091 ,(let* ((patches-commit "061ab39e1d4591f3aa842458252a19ad01858167")
1092 (patch-uri (lambda (name)
1093 (string-append
1094 "https://raw.githubusercontent.com/numba/"
1095 "llvmlite/" patches-commit "/conda-recipes/"
1096 name)))
1097 (patch-origin (lambda (name hash)
1098 (origin
1099 (method url-fetch)
1100 (uri (patch-uri name))
1101 (sha256 (base32 hash)))))
1102 (arch-independent-patches
1103 (list
1104 (patch-origin
1105 "partial-testing.patch"
1106 "1cwy4jsmijd838q0bylxl77vrwrb7ksijfly5062ay32303jmj86")
1107 (patch-origin
1108 "0001-Revert-Limit-size-of-non-GlobalValue-name.patch"
1109 "0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295"))))
1110 (if (string=? "aarch64-linux" (%current-system))
1111 (package
1112 (inherit llvm-9)
1113 (source
1114 (origin
1115 (inherit (package-source llvm-9))
1116 (patches
1117 `(,(patch-origin
1118 "intel-D47188-svml-VF_LLVM9.patch"
1119 "1f9ld7wc8bn4gbvdsmk07w1rq371h42vy05rxsq9a22f57rljqbd")
1120 ,@arch-independent-patches
1121 ,@(origin-patches (package-source llvm-9)))))))
1122 (package
1123 (inherit llvm-10)
1124 (source
1125 (origin
1126 (inherit (package-source llvm-10))
1127 (patches
1128 `(,(patch-origin
1129 "intel-D47188-svml-VF.patch"
1130 "0n46qjwfl7i12bl7wp0cyxl277axfvaaz5lxx5kdlgwjcpa582dg")
1131 ,(patch-origin
1132 "expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch"
1133 "0jxhjkkwwi1cy898l2n57l73ckpw0v73lqnrifp7r1mwpsh624nv")
1134 ,@arch-independent-patches
1135 ,@(origin-patches (package-source llvm-10))))))))))))
1136 (home-page "https://llvmlite.pydata.org")
1137 (synopsis "Wrapper around basic LLVM functionality")
1138 (description
1139 "This package provides a Python binding to LLVM for use in Numba.")
1140 (license license:bsd-3)))
1141
1142 (define-public emacs-clang-format
1143 (package
1144 (inherit clang)
1145 (name "emacs-clang-format")
1146 (build-system emacs-build-system)
1147 (inputs
1148 `(("clang" ,clang)))
1149 (arguments
1150 `(#:phases
1151 (modify-phases %standard-phases
1152 (add-after 'unpack 'configure
1153 (lambda* (#:key inputs #:allow-other-keys)
1154 (let ((clang (assoc-ref inputs "clang")))
1155 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
1156 (emacs-substitute-variables "clang-format.el"
1157 ("clang-format-executable"
1158 (string-append clang "/bin/clang-format"))))
1159 #t)))))
1160 (synopsis "Format code using clang-format")
1161 (description "This package filters code through @code{clang-format}
1162 to fix its formatting. @code{clang-format} is a tool that formats
1163 C/C++/Obj-C code according to a set of style options, see
1164 @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
1165
1166 (define-public emacs-clang-rename
1167 (package
1168 (inherit clang)
1169 (name "emacs-clang-rename")
1170 (build-system emacs-build-system)
1171 (inputs
1172 `(("clang" ,clang)))
1173 (arguments
1174 `(#:phases
1175 (modify-phases %standard-phases
1176 (add-after 'unpack 'configure
1177 (lambda* (#:key inputs #:allow-other-keys)
1178 (let ((clang (assoc-ref inputs "clang")))
1179 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
1180 (emacs-substitute-variables "clang-rename.el"
1181 ("clang-rename-binary"
1182 (string-append clang "/bin/clang-rename"))))
1183 #t)))))
1184 (synopsis "Rename every occurrence of a symbol using clang-rename")
1185 (description "This package renames every occurrence of a symbol at point
1186 using @code{clang-rename}.")))
1187
1188 (define make-ocaml-llvm
1189 ;; Make it a memoizing procedure so its callers below don't end up defining
1190 ;; two equal-but-not-eq "ocaml-llvm" packages for the default LLVM.
1191 (mlambdaq (llvm)
1192 (package
1193 (inherit llvm)
1194 (name "ocaml-llvm")
1195 (outputs '("out"))
1196 (arguments
1197 `(#:configure-flags
1198 (list
1199 (string-append "-DLLVM_OCAML_EXTERNAL_LLVM_LIBDIR="
1200 (assoc-ref %build-inputs "llvm") "/lib")
1201 "-DBUILD_SHARED_LIBS=TRUE"
1202 "-DLLVM_OCAML_OUT_OF_TREE=TRUE"
1203 (string-append "-DLLVM_OCAML_INSTALL_PATH="
1204 (assoc-ref %outputs "out") "/lib/ocaml/site-lib"))
1205 #:phases
1206 (modify-phases %standard-phases
1207 (replace 'build
1208 (lambda _
1209 (invoke "make" "ocaml_all")))
1210 (replace 'install
1211 (lambda _
1212 (invoke "cmake" "-P" "bindings/ocaml/cmake_install.cmake"))))))
1213 (inputs
1214 `(("llvm" ,llvm)))
1215 (native-inputs
1216 `(("ocaml" ,ocaml)
1217 ("ocaml-findlib" ,ocaml-findlib)
1218 ("ocaml-ounit" ,ocaml-ounit)
1219 ("python" ,python)))
1220 (propagated-inputs
1221 `(("ocaml-integers" ,ocaml-integers)
1222 ("ocaml-ctypes" ,ocaml-ctypes)))
1223 (synopsis "OCaml bindings to LLVM")
1224 (description "This package contains the OCaml bindings distributed with
1225 LLVM."))))
1226
1227 (define-public ocaml-llvm (make-ocaml-llvm llvm))
1228 (define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9))
1229 (define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10))
1230 (define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11))