Commit | Line | Data |
---|---|---|
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> |
a6046f24 | 8 | ;;; Copyright © 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com> |
225c5ea0 | 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> |
b1cb8b5d | 17 | ;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org> |
851a7caf | 18 | ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> |
8a34f292 | 19 | ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
97f8b22f | 20 | ;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu> |
3e4249ce EB |
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) | |
ac00973c | 39 | #:use-module ((guix licenses) #:prefix license:) |
3e4249ce | 40 | #:use-module (guix download) |
a2cc25ab | 41 | #:use-module (guix git-download) |
97f8b22f | 42 | #:use-module (guix memoization) |
3e4249ce EB |
43 | #:use-module (guix utils) |
44 | #:use-module (guix build-system gnu) | |
45 | #:use-module (guix build-system cmake) | |
7628ff1f | 46 | #:use-module (guix build-system emacs) |
8892cac3 | 47 | #:use-module (guix build-system python) |
57c7bfec | 48 | #:use-module (guix build-system trivial) |
3e4249ce | 49 | #:use-module (gnu packages) |
57c7bfec | 50 | #:use-module (gnu packages base) |
fd6ae1b9 LC |
51 | #:use-module (gnu packages gcc) |
52 | #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker | |
ee077430 | 53 | #:use-module (gnu packages compression) |
f11733bd | 54 | #:use-module (gnu packages libedit) |
ee077430 | 55 | #:use-module (gnu packages libffi) |
f11733bd | 56 | #:use-module (gnu packages lua) |
698e91f0 | 57 | #:use-module (gnu packages mpi) |
f11733bd | 58 | #:use-module (gnu packages ncurses) |
97f8b22f | 59 | #:use-module (gnu packages ocaml) |
290b55c5 | 60 | #:use-module (gnu packages onc-rpc) |
3e4249ce | 61 | #:use-module (gnu packages perl) |
698e91f0 | 62 | #:use-module (gnu packages pkg-config) |
3e4249ce | 63 | #:use-module (gnu packages python) |
f11733bd | 64 | #:use-module (gnu packages swig) |
96a9a8d3 LC |
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") | |
3a1c3642 JN |
88 | ("i686" => "X86") |
89 | ("i586" => "X86")))) | |
3e4249ce | 90 | |
abcdf6bf | 91 | (define (llvm-uri component version) |
4c4d1f69 MB |
92 | (string-append "https://github.com/llvm/llvm-project/releases/download" |
93 | "/llvmorg-" version "/" component "-" version ".src.tar.xz")) | |
cd16014f | 94 | |
6b26f915 LC |
95 | (define* (clang-runtime-from-llvm llvm hash |
96 | #:optional (patches '())) | |
b81f5693 AW |
97 | (package |
98 | (name "clang-runtime") | |
99 | (version (package-version llvm)) | |
100 | (source | |
101 | (origin | |
102 | (method url-fetch) | |
abcdf6bf | 103 | (uri (llvm-uri "compiler-rt" version)) |
6b26f915 LC |
104 | (sha256 (base32 hash)) |
105 | (patches (map search-patch patches)))) | |
b81f5693 AW |
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. | |
3b956a33 | 112 | #:build-type "Release" |
3fd9c90c MB |
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)))))) | |
ac97dce1 | 135 | (home-page "https://compiler-rt.llvm.org") |
b81f5693 AW |
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\".") | |
00ede157 | 142 | (license (package-license llvm)) |
9e6b9ea4 | 143 | |
ac97dce1 | 144 | ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported. |
9e6b9ea4 | 145 | (supported-systems (delete "mips64el-linux" %supported-systems)))) |
b81f5693 | 146 | |
3b956a33 | 147 | (define* (clang-from-llvm llvm clang-runtime hash |
77a87ad4 LC |
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." | |
3e4249ce EB |
153 | (package |
154 | (name "clang") | |
155 | (version (package-version llvm)) | |
156 | (source | |
157 | (origin | |
158 | (method url-fetch) | |
abcdf6bf | 159 | (uri (llvm-uri (if (version>=? version "9.0.1") |
cd16014f MB |
160 | "clang" |
161 | "cfe") | |
162 | version)) | |
fd6ae1b9 | 163 | (sha256 (base32 hash)) |
3b956a33 | 164 | (patches (map search-patch patches)))) |
3e4249ce EB |
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) | |
77a87ad4 | 169 | (outputs (if tools-extra '("out" "extra") '("out"))) |
3e4249ce EB |
170 | (native-inputs (package-native-inputs llvm)) |
171 | (inputs | |
172 | `(("libxml2" ,libxml2) | |
c92f1c0a | 173 | ("gcc-lib" ,gcc "lib") |
77a87ad4 LC |
174 | ,@(package-inputs llvm) |
175 | ,@(if tools-extra | |
176 | `(("clang-tools-extra" ,tools-extra)) | |
177 | '()))) | |
3e4249ce | 178 | (propagated-inputs |
b81f5693 AW |
179 | `(("llvm" ,llvm) |
180 | ("clang-runtime" ,clang-runtime))) | |
fd6ae1b9 LC |
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 | ||
94585e88 LC |
194 | ;; Don't use '-g' during the build to save space. |
195 | #:build-type "Release" | |
196 | ||
fd6ae1b9 | 197 | #:phases (modify-phases %standard-phases |
77a87ad4 LC |
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 | '()) | |
f5cc5de8 MB |
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)) | |
5041cc28 MB |
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. | |
9bdbabe9 MB |
289 | (substitute* "lib/Driver/ToolChain.cpp" |
290 | (("getDriver\\(\\)\\.ResourceDir") | |
5041cc28 | 291 | (string-append "\"" compiler-rt "\""))) |
9bdbabe9 | 292 | |
5041cc28 MB |
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")) | |
9bdbabe9 | 298 | |
5041cc28 MB |
299 | ;; Make clang look for libstdc++ in the right |
300 | ;; location. | |
301 | (("LibStdCXXIncludePathCandidates\\[\\] = \\{") | |
302 | (string-append | |
303 | "LibStdCXXIncludePathCandidates[] = { \"" gcc | |
304 | "/include/c++\",")) | |
496bbeee | 305 | |
5041cc28 MB |
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)))) | |
9bdbabe9 | 317 | |
5041cc28 MB |
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 "\""))))) | |
9bdbabe9 | 327 | |
5041cc28 MB |
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))) | |
f91046ce MB |
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 | '()) | |
0d3063f4 MB |
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 | '()) | |
1c7372a5 PN |
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") | |
ad8a4a66 PN |
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")) | |
1c7372a5 | 394 | ;; Install bash completion. |
ad8a4a66 PN |
395 | (when (file-exists? "bash-autocomplete.sh") |
396 | (mkdir-p compl-dir) | |
397 | (rename-file "bash-autocomplete.sh" | |
398 | (string-append compl-dir "/clang"))))) | |
1c7372a5 | 399 | #t))))) |
ef11ac87 LC |
400 | |
401 | ;; Clang supports the same environment variables as GCC. | |
402 | (native-search-paths | |
403 | (list (search-path-specification | |
f42bfc7a | 404 | (variable "C_INCLUDE_PATH") |
ef11ac87 | 405 | (files '("include"))) |
f42bfc7a MB |
406 | (search-path-specification |
407 | (variable "CPLUS_INCLUDE_PATH") | |
408 | (files '("include/c++" "include"))) | |
ef11ac87 LC |
409 | (search-path-specification |
410 | (variable "LIBRARY_PATH") | |
411 | (files '("lib" "lib64"))))) | |
412 | ||
ac97dce1 | 413 | (home-page "https://clang.llvm.org") |
3e4249ce EB |
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.") | |
00ede157 MB |
420 | (license (if (version>=? version "9.0") |
421 | license:asl2.0 ;with LLVM exceptions | |
422 | license:ncsa)))) | |
1204c510 | 423 | |
57c7bfec MO |
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 | ||
b6684507 LC |
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 | ||
57c7bfec MO |
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 | ||
61a5380b LC |
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")))))) | |
57c7bfec MO |
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 | ||
7f79358d | 479 | (define-public llvm-11 |
f1db068a MB |
480 | (package |
481 | (name "llvm") | |
225c5ea0 | 482 | (version "11.0.0") |
f1db068a MB |
483 | (source |
484 | (origin | |
485 | (method url-fetch) | |
486 | (uri (llvm-uri "llvm" version)) | |
487 | (sha256 | |
225c5ea0 TGR |
488 | (base32 |
489 | "0s94lwil98w7zb7cjrbnxli0z7gklb312pkw74xs1d6zk346hgwi")))) | |
f1db068a MB |
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 | ||
7f79358d MB |
541 | (define-public clang-runtime-11 |
542 | (clang-runtime-from-llvm | |
543 | llvm-11 | |
225c5ea0 | 544 | "0d5j5l8phwqjjscmk8rmqn0i2i0abl537gdbkagl8fjpzy1gyjip")) |
7f79358d MB |
545 | |
546 | (define-public clang-11 | |
547 | (clang-from-llvm llvm-11 clang-runtime-11 | |
225c5ea0 | 548 | "02ajkij85966vd150iy246mv16dsaph1kfi0y8wnncp8w6nar5hg" |
7f79358d MB |
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 | |
225c5ea0 | 557 | "02bcwwn54661madhq4nxc069s7p7pj5gpqi8ww50w3anbpviilzy"))))) |
7f79358d MB |
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 | ||
193192ca LC |
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" | |
77a87ad4 LC |
582 | #:patches '("clang-10.0-libc-search-path.patch") |
583 | #:tools-extra | |
584 | (origin | |
585 | (method url-fetch) | |
abcdf6bf | 586 | (uri (llvm-uri "clang-tools-extra" |
77a87ad4 LC |
587 | (package-version llvm-10))) |
588 | (sha256 | |
589 | (base32 | |
590 | "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc"))))) | |
193192ca LC |
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) | |
abcdf6bf | 602 | (uri (llvm-uri "llvm" version)) |
193192ca LC |
603 | (sha256 |
604 | (base32 | |
851a7caf | 605 | "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880")) |
851a7caf | 606 | (patches (search-patches |
9e4c24ef MC |
607 | "llvm-9-fix-bitcast-miscompilation.patch" |
608 | "llvm-9-fix-scev-miscompilation.patch" | |
609 | "llvm-9-fix-lpad-miscompilation.patch")))))) | |
193192ca LC |
610 | |
611 | (define-public clang-runtime-9 | |
b81f5693 | 612 | (clang-runtime-from-llvm |
193192ca | 613 | llvm-9 |
af88972b MB |
614 | "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2" |
615 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
b81f5693 | 616 | |
193192ca LC |
617 | (define-public clang-9 |
618 | (clang-from-llvm llvm-9 clang-runtime-9 | |
00ede157 MB |
619 | "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p" |
620 | #:patches '("clang-9.0-libc-search-path.patch"))) | |
d199a4c7 | 621 | |
193192ca LC |
622 | (define-public clang-toolchain-9 |
623 | (make-clang-toolchain clang-9)) | |
57c7bfec | 624 | |
00ede157 | 625 | (define-public llvm-8 |
96d5a206 | 626 | (package |
f1db068a | 627 | (inherit llvm-9) |
00ede157 | 628 | (version "8.0.0") |
96d5a206 DT |
629 | (source (origin |
630 | (method url-fetch) | |
abcdf6bf | 631 | (uri (llvm-uri "llvm" version)) |
96d5a206 DT |
632 | (sha256 |
633 | (base32 | |
00ede157 MB |
634 | "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8")))) |
635 | (license license:ncsa))) | |
96d5a206 | 636 | |
00ede157 | 637 | (define-public clang-runtime-8 |
96d5a206 | 638 | (clang-runtime-from-llvm |
00ede157 | 639 | llvm-8 |
af88972b MB |
640 | "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl" |
641 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
96d5a206 | 642 | |
00ede157 MB |
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"))) | |
96d5a206 | 647 | |
00ede157 MB |
648 | (define-public clang-toolchain-8 |
649 | (make-clang-toolchain clang-8)) | |
96d5a206 | 650 | |
4289d1d7 MB |
651 | (define-public llvm-7 |
652 | (package | |
00ede157 | 653 | (inherit llvm-8) |
4289d1d7 MB |
654 | (version "7.0.1") |
655 | (source (origin | |
656 | (method url-fetch) | |
abcdf6bf | 657 | (uri (llvm-uri "llvm" version)) |
4289d1d7 MB |
658 | (sha256 |
659 | (base32 | |
660 | "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3")))))) | |
661 | ||
662 | (define-public clang-runtime-7 | |
663 | (clang-runtime-from-llvm | |
664 | llvm-7 | |
af88972b MB |
665 | "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq" |
666 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
4289d1d7 MB |
667 | |
668 | (define-public clang-7 | |
501672d7 | 669 | (clang-from-llvm llvm-7 clang-runtime-7 |
4289d1d7 MB |
670 | "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4" |
671 | #:patches '("clang-7.0-libc-search-path.patch"))) | |
672 | ||
57c7bfec MO |
673 | (define-public clang-toolchain-7 |
674 | (make-clang-toolchain clang-7)) | |
675 | ||
d199a4c7 MB |
676 | (define-public llvm-6 |
677 | (package | |
00ede157 | 678 | (inherit llvm-7) |
d199a4c7 MB |
679 | (version "6.0.1") |
680 | (source (origin | |
681 | (method url-fetch) | |
abcdf6bf | 682 | (uri (llvm-uri "llvm" version)) |
d199a4c7 MB |
683 | (sha256 |
684 | (base32 | |
685 | "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn")))))) | |
686 | ||
687 | (define-public clang-runtime-6 | |
688 | (clang-runtime-from-llvm | |
689 | llvm-6 | |
af88972b MB |
690 | "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl" |
691 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
d199a4c7 MB |
692 | |
693 | (define-public clang-6 | |
501672d7 | 694 | (clang-from-llvm llvm-6 clang-runtime-6 |
148df605 | 695 | "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w" |
9bdbabe9 | 696 | #:patches '("clang-6.0-libc-search-path.patch"))) |
3b956a33 | 697 | |
57c7bfec MO |
698 | (define-public clang-toolchain-6 |
699 | (make-clang-toolchain clang-6)) | |
700 | ||
584da12d | 701 | (define-public llvm-3.9.1 |
00ede157 | 702 | (package (inherit llvm-6) |
584da12d RJ |
703 | (name "llvm") |
704 | (version "3.9.1") | |
705 | (source | |
706 | (origin | |
707 | (method url-fetch) | |
abcdf6bf | 708 | (uri (llvm-uri "llvm" version)) |
584da12d RJ |
709 | (sha256 |
710 | (base32 | |
a6046f24 MB |
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))))))) | |
584da12d RJ |
718 | |
719 | (define-public clang-runtime-3.9.1 | |
720 | (clang-runtime-from-llvm | |
721 | llvm-3.9.1 | |
6b26f915 | 722 | "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk" |
af88972b MB |
723 | '("clang-runtime-3.9-libsanitizer-mode-field.patch" |
724 | "clang-runtime-asan-build-fixes.patch" | |
0627f93d | 725 | "clang-runtime-esan-build-fixes.patch" |
1a2d8d06 | 726 | "clang-3.5-libsanitizer-ustat-fix.patch"))) |
584da12d RJ |
727 | |
728 | (define-public clang-3.9.1 | |
729 | (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1 | |
730 | "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76" | |
9bdbabe9 MB |
731 | #:patches '("clang-3.8-libc-search-path.patch"))) |
732 | ||
733 | (define-public llvm-3.8 | |
a6046f24 | 734 | (package (inherit llvm-3.9.1) |
9bdbabe9 MB |
735 | (name "llvm") |
736 | (version "3.8.1") | |
737 | (source | |
738 | (origin | |
739 | (method url-fetch) | |
abcdf6bf | 740 | (uri (llvm-uri "llvm" version)) |
9bdbabe9 MB |
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" | |
0627f93d | 749 | '("clang-runtime-asan-build-fixes.patch" |
af88972b | 750 | "clang-runtime-3.8-libsanitizer-mode-field.patch" |
1a2d8d06 | 751 | "clang-3.5-libsanitizer-ustat-fix.patch"))) |
9bdbabe9 MB |
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"))) | |
584da12d | 757 | |
3b956a33 | 758 | (define-public llvm-3.7 |
00ede157 | 759 | (package (inherit llvm-3.8) |
3b956a33 EB |
760 | (version "3.7.1") |
761 | (source | |
762 | (origin | |
763 | (method url-fetch) | |
abcdf6bf | 764 | (uri (llvm-uri "llvm" version)) |
3b956a33 EB |
765 | (sha256 |
766 | (base32 | |
767 | "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy")))))) | |
768 | ||
769 | (define-public clang-runtime-3.7 | |
770 | (clang-runtime-from-llvm | |
771 | llvm-3.7 | |
6b26f915 | 772 | "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx" |
0627f93d | 773 | '("clang-runtime-asan-build-fixes.patch" |
af88972b | 774 | "clang-runtime-3.8-libsanitizer-mode-field.patch" |
1a2d8d06 | 775 | "clang-3.5-libsanitizer-ustat-fix.patch"))) |
3b956a33 EB |
776 | |
777 | (define-public clang-3.7 | |
778 | (clang-from-llvm llvm-3.7 clang-runtime-3.7 | |
9bdbabe9 MB |
779 | "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn" |
780 | #:patches '("clang-3.5-libc-search-path.patch"))) | |
3ebc0905 EB |
781 | |
782 | (define-public llvm-3.6 | |
00ede157 | 783 | (package (inherit llvm-3.7) |
3ebc0905 EB |
784 | (version "3.6.2") |
785 | (source | |
786 | (origin | |
787 | (method url-fetch) | |
abcdf6bf | 788 | (uri (llvm-uri "llvm" version)) |
3ebc0905 EB |
789 | (sha256 |
790 | (base32 | |
791 | "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn")))))) | |
792 | ||
1204c510 | 793 | (define-public llvm-3.5 |
00ede157 | 794 | (package (inherit llvm-3.6) |
a53c486d | 795 | (version "3.5.2") |
1204c510 MW |
796 | (source |
797 | (origin | |
798 | (method url-fetch) | |
abcdf6bf | 799 | (uri (llvm-uri "llvm" version)) |
6ba4eca2 RW |
800 | (patches |
801 | (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch")) | |
1204c510 MW |
802 | (sha256 |
803 | (base32 | |
a53c486d | 804 | "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4")))))) |
1204c510 | 805 | |
b81f5693 | 806 | (define-public clang-runtime-3.5 |
290b55c5 RW |
807 | (let ((runtime (clang-runtime-from-llvm |
808 | llvm-3.5 | |
809 | "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal" | |
810 | '("clang-runtime-asan-build-fixes.patch" | |
5f022a51 | 811 | "clang-runtime-3.5-libsanitizer-mode-field.patch" |
290b55c5 | 812 | "clang-3.5-libsanitizer-ustat-fix.patch")))) |
1a265842 | 813 | (package/inherit runtime |
290b55c5 RW |
814 | (arguments |
815 | (substitute-keyword-arguments (package-arguments runtime) | |
816 | ((#:phases phases '%standard-phases) | |
817 | `(modify-phases ,phases | |
818 | ;; glibc no longer includes rpc/xdr.h, so we use the headers from | |
819 | ;; libtirpc. | |
820 | (add-after 'unpack 'find-rpc-includes | |
821 | (lambda* (#:key inputs #:allow-other-keys) | |
822 | (setenv "CPATH" | |
823 | (string-append (assoc-ref inputs "libtirpc") | |
824 | "/include/tirpc/:" | |
825 | (or (getenv "CPATH") ""))) | |
826 | (setenv "CPLUS_INCLUDE_PATH" | |
827 | (string-append (assoc-ref inputs "libtirpc") | |
828 | "/include/tirpc/:" | |
829 | (or (getenv "CPLUS_INCLUDE_PATH") ""))) | |
830 | #t)))))) | |
831 | (inputs | |
832 | `(("libtirpc" ,libtirpc) | |
833 | ("llvm" ,llvm-3.5)))))) | |
b81f5693 | 834 | |
1204c510 | 835 | (define-public clang-3.5 |
b81f5693 | 836 | (clang-from-llvm llvm-3.5 clang-runtime-3.5 |
9bdbabe9 MB |
837 | "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg" |
838 | #:patches '("clang-3.5-libc-search-path.patch"))) | |
921cb13a | 839 | |
f1db068a MB |
840 | ;; Default LLVM and Clang version. |
841 | (define-public llvm llvm-9) | |
842 | (define-public clang-runtime clang-runtime-9) | |
843 | (define-public clang clang-9) | |
844 | (define-public clang-toolchain clang-toolchain-9) | |
845 | ||
846 | (define-public lld | |
847 | (package | |
848 | (name "lld") | |
8937cd05 | 849 | (version "11.0.0") |
f1db068a MB |
850 | (source (origin |
851 | (method url-fetch) | |
852 | (uri (llvm-uri "lld" version)) | |
853 | (sha256 | |
854 | (base32 | |
8937cd05 | 855 | "077xyh7sij6mhp4dc4kdcmp9whrpz332fa12rwxnzp3wgd5bxrzg")))) |
f1db068a MB |
856 | (build-system cmake-build-system) |
857 | (inputs | |
8937cd05 | 858 | `(("llvm" ,llvm-11))) |
f1db068a MB |
859 | (arguments |
860 | `(#:build-type "Release" | |
861 | ;; TODO: Tests require the lit tool, which isn't installed by the LLVM | |
862 | ;; package. | |
863 | #:tests? #f)) | |
864 | (home-page "https://lld.llvm.org/") | |
865 | (synopsis "Linker from the LLVM project") | |
866 | (description "LLD is a high-performance linker, built as a set of reusable | |
867 | components which highly leverage existing libraries in the larger LLVM Project.") | |
868 | (license license:asl2.0))) ; With LLVM exception | |
869 | ||
f11733bd MB |
870 | (define-public lldb |
871 | (package | |
872 | (name "lldb") | |
873 | (version "11.0.0") | |
874 | (source (origin | |
875 | (method url-fetch) | |
876 | (uri (llvm-uri "lldb" version)) | |
877 | (sha256 | |
878 | (base32 | |
879 | "0wic9lyb2la9bkzdc13szkm4f793w1mddp50xvh237iraygw0w45")))) | |
880 | (build-system cmake-build-system) | |
881 | (arguments | |
882 | `(#:configure-flags '("-DCMAKE_CXX_COMPILER=clang++"))) | |
883 | (native-inputs | |
884 | `(("pkg-config" ,pkg-config) | |
885 | ("swig" ,swig))) | |
886 | (inputs | |
887 | `(("clang" ,clang-11) | |
888 | ("llvm" ,llvm-11) | |
889 | ||
890 | ;; Optional (but recommended) inputs. | |
891 | ("curses" ,ncurses) | |
892 | ("editline" ,libedit) | |
893 | ("liblzma" ,xz) | |
894 | ("libxml2" ,libxml2) | |
895 | ("lua" ,lua) | |
896 | ("python" ,python))) | |
897 | (home-page "https://lldb.llvm.org/") | |
898 | (synopsis "Low level debugger") | |
899 | (description | |
900 | "LLDB is a high performance debugger built as a set of reusable components | |
901 | which highly leverage existing libraries in the larger LLVM project.") | |
902 | (license license:asl2.0))) ;with LLVM exceptions | |
903 | ||
52f9c3b8 MB |
904 | (define-public libcxx |
905 | (package | |
906 | (name "libcxx") | |
00ede157 | 907 | (version "9.0.1") |
52f9c3b8 MB |
908 | (source |
909 | (origin | |
910 | (method url-fetch) | |
abcdf6bf | 911 | (uri (llvm-uri "libcxx" version)) |
52f9c3b8 MB |
912 | (sha256 |
913 | (base32 | |
00ede157 | 914 | "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089")))) |
52f9c3b8 | 915 | (build-system cmake-build-system) |
40a461fd MB |
916 | (arguments |
917 | `(#:phases | |
918 | (modify-phases (@ (guix build cmake-build-system) %standard-phases) | |
919 | (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH | |
920 | (lambda* (#:key inputs #:allow-other-keys) | |
921 | (let ((gcc (assoc-ref inputs "gcc"))) | |
922 | ;; Hide GCC's C++ headers so that they do not interfere with | |
923 | ;; the ones we are attempting to build. | |
924 | (setenv "CPLUS_INCLUDE_PATH" | |
925 | (string-join (delete (string-append gcc "/include/c++") | |
926 | (string-split (getenv "CPLUS_INCLUDE_PATH") | |
927 | #\:)) | |
928 | ":")) | |
929 | (format #t | |
930 | "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" | |
931 | (getenv "CPLUS_INCLUDE_PATH")) | |
932 | #t)))))) | |
52f9c3b8 MB |
933 | (native-inputs |
934 | `(("clang" ,clang) | |
935 | ("llvm" ,llvm))) | |
936 | (home-page "https://libcxx.llvm.org") | |
937 | (synopsis "C++ standard library") | |
938 | (description | |
939 | "This package provides an implementation of the C++ standard library for | |
940 | use with Clang, targeting C++11, C++14 and above.") | |
941 | (license license:expat))) | |
942 | ||
943 | ;; Libcxx files specifically used by PySide2. | |
944 | (define-public libcxx-6 | |
945 | (package | |
946 | (inherit libcxx) | |
947 | (version (package-version llvm-6)) | |
948 | (source | |
949 | (origin | |
950 | (inherit (package-source libcxx)) | |
abcdf6bf | 951 | (uri (llvm-uri "libcxx" version)) |
52f9c3b8 MB |
952 | (sha256 |
953 | (base32 | |
954 | "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) | |
955 | (native-inputs | |
956 | `(("clang" ,clang-6) | |
957 | ("llvm" ,llvm-6))))) | |
958 | ||
959 | (define-public libclc | |
960 | (package | |
961 | (name "libclc") | |
00ede157 | 962 | (version "9.0.1") |
52f9c3b8 MB |
963 | (source |
964 | (origin | |
965 | (method git-fetch) | |
966 | (uri (git-reference | |
b0e7b699 | 967 | (url "https://github.com/llvm/llvm-project") |
52f9c3b8 MB |
968 | (commit (string-append "llvmorg-" version)))) |
969 | (file-name (git-file-name name version)) | |
970 | (sha256 | |
971 | (base32 | |
00ede157 | 972 | "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0")))) |
52f9c3b8 MB |
973 | (build-system cmake-build-system) |
974 | (arguments | |
975 | `(#:configure-flags | |
976 | (list (string-append "-DLLVM_CLANG=" | |
977 | (assoc-ref %build-inputs "clang") | |
978 | "/bin/clang") | |
979 | (string-append "-DPYTHON=" | |
980 | (assoc-ref %build-inputs "python") | |
981 | "/bin/python3")) | |
982 | #:phases | |
983 | (modify-phases %standard-phases | |
984 | (add-after 'unpack 'chdir | |
985 | (lambda _ (chdir "libclc") #t))))) | |
986 | (native-inputs | |
987 | `(("clang" ,clang) | |
988 | ("llvm" ,llvm) | |
989 | ("python" ,python))) | |
990 | (home-page "https://libclc.llvm.org") | |
991 | (synopsis "Libraries for the OpenCL programming language") | |
992 | (description | |
993 | "This package provides an implementation of the OpenCL library | |
994 | requirements according to version 1.1 of the OpenCL specification.") | |
995 | ;; Apache license 2.0 with LLVM exception | |
996 | (license license:asl2.0))) | |
997 | ||
998 | (define-public libomp | |
999 | (package | |
1000 | (name "libomp") | |
00ede157 | 1001 | (version "9.0.1") |
52f9c3b8 MB |
1002 | (source (origin |
1003 | (method url-fetch) | |
abcdf6bf | 1004 | (uri (llvm-uri "openmp" version)) |
52f9c3b8 MB |
1005 | (sha256 |
1006 | (base32 | |
00ede157 | 1007 | "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w")) |
52f9c3b8 MB |
1008 | (file-name (string-append "libomp-" version ".tar.xz")))) |
1009 | (build-system cmake-build-system) | |
1010 | ;; XXX: Note this gets built with GCC because building with Clang itself | |
1011 | ;; fails (missing <atomic>, even when libcxx is added as an input.) | |
1012 | (arguments | |
1013 | '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON" | |
1014 | "-DOPENMP_TEST_C_COMPILER=clang" | |
1015 | "-DOPENMP_TEST_CXX_COMPILER=clang++") | |
1016 | #:test-target "check-libomp")) | |
1017 | (native-inputs | |
1018 | `(("clang" ,clang) | |
1019 | ("llvm" ,llvm) | |
1020 | ("perl" ,perl) | |
1021 | ("pkg-config" ,pkg-config))) | |
1022 | (inputs | |
1023 | `(("hwloc" ,hwloc "lib"))) | |
1024 | (home-page "https://openmp.llvm.org") | |
1025 | (synopsis "OpenMP run-time support library") | |
1026 | (description | |
1027 | "This package provides the run-time support library developed by the LLVM | |
1028 | project for the OpenMP multi-theaded programming extension. This package | |
1029 | notably provides @file{libgomp.so}, which is has a binary interface compatible | |
1030 | with that of libgomp, the GNU Offloading and Multi Processing Library.") | |
1031 | (license license:expat))) | |
1032 | ||
8892cac3 RW |
1033 | (define-public python-llvmlite |
1034 | (package | |
1035 | (name "python-llvmlite") | |
8a34f292 | 1036 | (version "0.34.0") |
8892cac3 RW |
1037 | (source |
1038 | (origin | |
1039 | (method url-fetch) | |
1040 | (uri (pypi-uri "llvmlite" version)) | |
1041 | (sha256 | |
1042 | (base32 | |
8a34f292 | 1043 | "0qqzs6h34002ig2jn31vk08q9hh5kn84lhmv4bljz3yakg8y0gph")))) |
8892cac3 | 1044 | (build-system python-build-system) |
66087272 | 1045 | (arguments |
8a34f292 MC |
1046 | `(#:phases |
1047 | (modify-phases %standard-phases | |
1048 | (add-after 'unpack 'patch-reference-to-llvmlite.so | |
1049 | ;; ctypes.CDLL uses dlopen to load libllvmlite.so, which | |
1050 | ;; fails, so locate it by its absolute path. Change it in | |
1051 | ;; ffi.py, not utils.py, because setup.py relies on the | |
1052 | ;; output of get_library_name for proper installation. | |
1053 | (lambda* (#:key outputs #:allow-other-keys) | |
1054 | (let* ((out (assoc-ref outputs "out")) | |
1055 | (libllvmlite.so (string-append out "/lib/python" | |
1056 | ,(version-major+minor | |
1057 | (package-version python)) | |
1058 | "/site-packages/llvmlite/" | |
1059 | "binding/libllvmlite.so"))) | |
1060 | (substitute* "llvmlite/binding/ffi.py" | |
1061 | (("_lib_name = get_library_name\\(\\)") | |
1062 | (format #f "_lib_name = ~s" libllvmlite.so))) | |
1063 | #t))) | |
1064 | (add-after 'unpack 'skip-failing-tests | |
1065 | (lambda _ | |
1066 | (substitute* "llvmlite/tests/test_binding.py" | |
1067 | ((" def test_libm\\(self\\).*" all) | |
1068 | (string-append " @unittest.skip('Fails on Guix')\n" all))) | |
1069 | #t)) | |
1070 | (add-before 'build 'set-compiler/linker-flags | |
1071 | (lambda* (#:key inputs #:allow-other-keys) | |
1072 | (let ((llvm (assoc-ref inputs "llvm"))) | |
1073 | ;; Refer to ffi/Makefile.linux. | |
1074 | (setenv "CPPFLAGS" "-fPIC") | |
1075 | (setenv "LDFLAGS" (string-append "-Wl,-rpath=" | |
1076 | llvm "/lib")) | |
1077 | #t)))))) | |
8892cac3 RW |
1078 | (inputs |
1079 | `(("llvm" | |
8a34f292 MC |
1080 | ,(let* ((patches-commit "061ab39e1d4591f3aa842458252a19ad01858167") |
1081 | (patch-uri (lambda (name) | |
1082 | (string-append | |
1083 | "https://raw.githubusercontent.com/numba/" | |
1084 | "llvmlite/" patches-commit "/conda-recipes/" | |
1085 | name))) | |
1086 | (patch-origin (lambda (name hash) | |
1087 | (origin | |
1088 | (method url-fetch) | |
1089 | (uri (patch-uri name)) | |
1090 | (sha256 (base32 hash))))) | |
1091 | (arch-independent-patches | |
6ee74687 | 1092 | (list |
8a34f292 MC |
1093 | (patch-origin |
1094 | "partial-testing.patch" | |
1095 | "1cwy4jsmijd838q0bylxl77vrwrb7ksijfly5062ay32303jmj86") | |
1096 | (patch-origin | |
1097 | "0001-Revert-Limit-size-of-non-GlobalValue-name.patch" | |
1098 | "0n4k7za0smx6qwdipsh6x5lm7bfvzzb3p9r8q1zq1dqi4na21295")))) | |
1099 | (if (string=? "aarch64-linux" (%current-system)) | |
1100 | (package | |
1101 | (inherit llvm-9) | |
1102 | (source | |
6ee74687 | 1103 | (origin |
8a34f292 MC |
1104 | (inherit (package-source llvm-9)) |
1105 | (patches | |
1106 | `(,(patch-origin | |
1107 | "intel-D47188-svml-VF_LLVM9.patch" | |
1108 | "1f9ld7wc8bn4gbvdsmk07w1rq371h42vy05rxsq9a22f57rljqbd") | |
1109 | ,@arch-independent-patches | |
1110 | ,@(origin-patches (package-source llvm-9))))))) | |
1111 | (package | |
1112 | (inherit llvm-10) | |
1113 | (source | |
6ee74687 | 1114 | (origin |
8a34f292 MC |
1115 | (inherit (package-source llvm-10)) |
1116 | (patches | |
1117 | `(,(patch-origin | |
1118 | "intel-D47188-svml-VF.patch" | |
1119 | "0n46qjwfl7i12bl7wp0cyxl277axfvaaz5lxx5kdlgwjcpa582dg") | |
1120 | ,(patch-origin | |
1121 | "expect-fastmath-entrypoints-in-add-TLI-mappings.ll.patch" | |
1122 | "0jxhjkkwwi1cy898l2n57l73ckpw0v73lqnrifp7r1mwpsh624nv") | |
1123 | ,@arch-independent-patches | |
1124 | ,@(origin-patches (package-source llvm-10)))))))))))) | |
1125 | (home-page "https://llvmlite.pydata.org") | |
8892cac3 RW |
1126 | (synopsis "Wrapper around basic LLVM functionality") |
1127 | (description | |
1128 | "This package provides a Python binding to LLVM for use in Numba.") | |
1129 | (license license:bsd-3))) | |
7628ff1f TG |
1130 | |
1131 | (define-public emacs-clang-format | |
1132 | (package | |
1133 | (inherit clang) | |
1134 | (name "emacs-clang-format") | |
1135 | (build-system emacs-build-system) | |
1136 | (inputs | |
1137 | `(("clang" ,clang))) | |
1138 | (arguments | |
1139 | `(#:phases | |
1140 | (modify-phases %standard-phases | |
1141 | (add-after 'unpack 'configure | |
1142 | (lambda* (#:key inputs #:allow-other-keys) | |
1143 | (let ((clang (assoc-ref inputs "clang"))) | |
1144 | (copy-file "tools/clang-format/clang-format.el" "clang-format.el") | |
1145 | (emacs-substitute-variables "clang-format.el" | |
1146 | ("clang-format-executable" | |
1147 | (string-append clang "/bin/clang-format")))) | |
1148 | #t))))) | |
1149 | (synopsis "Format code using clang-format") | |
3bb22e54 | 1150 | (description "This package filters code through @code{clang-format} |
7628ff1f TG |
1151 | to fix its formatting. @code{clang-format} is a tool that formats |
1152 | C/C++/Obj-C code according to a set of style options, see | |
3bdcc668 | 1153 | @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))) |
51002b72 PN |
1154 | |
1155 | (define-public emacs-clang-rename | |
1156 | (package | |
1157 | (inherit clang) | |
1158 | (name "emacs-clang-rename") | |
1159 | (build-system emacs-build-system) | |
1160 | (inputs | |
1161 | `(("clang" ,clang))) | |
1162 | (arguments | |
1163 | `(#:phases | |
1164 | (modify-phases %standard-phases | |
1165 | (add-after 'unpack 'configure | |
1166 | (lambda* (#:key inputs #:allow-other-keys) | |
1167 | (let ((clang (assoc-ref inputs "clang"))) | |
1168 | (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el") | |
1169 | (emacs-substitute-variables "clang-rename.el" | |
1170 | ("clang-rename-binary" | |
1171 | (string-append clang "/bin/clang-rename")))) | |
1172 | #t))))) | |
1173 | (synopsis "Rename every occurrence of a symbol using clang-rename") | |
1174 | (description "This package renames every occurrence of a symbol at point | |
1175 | using @code{clang-rename}."))) | |
97f8b22f LC |
1176 | |
1177 | (define make-ocaml-llvm | |
1178 | ;; Make it a memoizing procedure so its callers below don't end up defining | |
1179 | ;; two equal-but-not-eq "ocaml-llvm" packages for the default LLVM. | |
1180 | (mlambdaq (llvm) | |
1181 | (package | |
1182 | (inherit llvm) | |
1183 | (name "ocaml-llvm") | |
1184 | (outputs '("out")) | |
1185 | (arguments | |
1186 | `(#:configure-flags | |
1187 | (list | |
1188 | (string-append "-DLLVM_OCAML_EXTERNAL_LLVM_LIBDIR=" | |
1189 | (assoc-ref %build-inputs "llvm") "/lib") | |
1190 | "-DBUILD_SHARED_LIBS=TRUE" | |
1191 | "-DLLVM_OCAML_OUT_OF_TREE=TRUE" | |
1192 | (string-append "-DLLVM_OCAML_INSTALL_PATH=" | |
1193 | (assoc-ref %outputs "out") "/lib/ocaml/site-lib")) | |
1194 | #:phases | |
1195 | (modify-phases %standard-phases | |
1196 | (replace 'build | |
1197 | (lambda _ | |
1198 | (invoke "make" "ocaml_all"))) | |
1199 | (replace 'install | |
1200 | (lambda _ | |
1201 | (invoke "cmake" "-P" "bindings/ocaml/cmake_install.cmake")))))) | |
1202 | (inputs | |
1203 | `(("llvm" ,llvm))) | |
1204 | (native-inputs | |
1205 | `(("ocaml" ,ocaml) | |
1206 | ("ocaml-findlib" ,ocaml-findlib) | |
1207 | ("ocaml-ounit" ,ocaml-ounit) | |
1208 | ("python" ,python))) | |
1209 | (propagated-inputs | |
1210 | `(("ocaml-integers" ,ocaml-integers) | |
1211 | ("ocaml-ctypes" ,ocaml-ctypes))) | |
1212 | (synopsis "OCaml bindings to LLVM") | |
1213 | (description "This package contains the OCaml bindings distributed with | |
1214 | LLVM.")))) | |
1215 | ||
1216 | (define-public ocaml-llvm (make-ocaml-llvm llvm)) | |
1217 | (define-public ocaml-llvm-9 (make-ocaml-llvm llvm-9)) | |
1218 | (define-public ocaml-llvm-10 (make-ocaml-llvm llvm-10)) | |
1219 | (define-public ocaml-llvm-11 (make-ocaml-llvm llvm-11)) |