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> |
e2170c31 | 9 | ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr> |
0627f93d | 10 | ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il> |
7628ff1f TG |
11 | ;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de> |
12 | ;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz> | |
c5296e20 | 13 | ;;; Copyright © 2019 Rutger Helling <rhelling@mykolab.com> |
5dea5cbc | 14 | ;;; Copyright © 2019 Arm Ltd <David.Truby@arm.com> |
57c7bfec | 15 | ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> |
66087272 | 16 | ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org> |
b1cb8b5d | 17 | ;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org> |
851a7caf | 18 | ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> |
3e4249ce EB |
19 | ;;; |
20 | ;;; This file is part of GNU Guix. | |
21 | ;;; | |
22 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
23 | ;;; under the terms of the GNU General Public License as published by | |
24 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
25 | ;;; your option) any later version. | |
26 | ;;; | |
27 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
28 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
29 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
30 | ;;; GNU General Public License for more details. | |
31 | ;;; | |
32 | ;;; You should have received a copy of the GNU General Public License | |
33 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
34 | ||
35 | (define-module (gnu packages llvm) | |
36 | #:use-module (guix packages) | |
ac00973c | 37 | #:use-module ((guix licenses) #:prefix license:) |
3e4249ce | 38 | #:use-module (guix download) |
a2cc25ab | 39 | #:use-module (guix git-download) |
3e4249ce EB |
40 | #:use-module (guix utils) |
41 | #:use-module (guix build-system gnu) | |
42 | #:use-module (guix build-system cmake) | |
7628ff1f | 43 | #:use-module (guix build-system emacs) |
8892cac3 | 44 | #:use-module (guix build-system python) |
57c7bfec | 45 | #:use-module (guix build-system trivial) |
3e4249ce | 46 | #:use-module (gnu packages) |
57c7bfec | 47 | #:use-module (gnu packages base) |
fd6ae1b9 LC |
48 | #:use-module (gnu packages gcc) |
49 | #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker | |
ee077430 EB |
50 | #:use-module (gnu packages compression) |
51 | #:use-module (gnu packages libffi) | |
698e91f0 | 52 | #:use-module (gnu packages mpi) |
290b55c5 | 53 | #:use-module (gnu packages onc-rpc) |
3e4249ce | 54 | #:use-module (gnu packages perl) |
698e91f0 | 55 | #:use-module (gnu packages pkg-config) |
3e4249ce | 56 | #:use-module (gnu packages python) |
96a9a8d3 LC |
57 | #:use-module (gnu packages xml) |
58 | #:export (system->llvm-target)) | |
59 | ||
60 | (define* (system->llvm-target #:optional | |
61 | (system (or (and=> (%current-target-system) | |
62 | gnu-triplet->nix-system) | |
63 | (%current-system)))) | |
64 | "Return the LLVM target name that corresponds to SYSTEM, a system type such | |
65 | as \"x86_64-linux\"." | |
66 | ;; See the 'lib/Target' directory of LLVM for a list of supported targets. | |
67 | (letrec-syntax ((matches (syntax-rules (=>) | |
68 | ((_ (system-prefix => target) rest ...) | |
69 | (if (string-prefix? system-prefix system) | |
70 | target | |
71 | (matches rest ...))) | |
72 | ((_) | |
73 | (error "LLVM target for system is unknown" system))))) | |
74 | (matches ("aarch64" => "AArch64") | |
75 | ("armhf" => "ARM") | |
76 | ("mips64el" => "Mips") | |
77 | ("powerpc" => "PowerPC") | |
78 | ("riscv" => "RISCV") | |
79 | ("x86_64" => "X86") | |
3a1c3642 JN |
80 | ("i686" => "X86") |
81 | ("i586" => "X86")))) | |
3e4249ce | 82 | |
cd16014f MB |
83 | (define (llvm-download-uri component version) |
84 | (if (version>=? version "9.0.1") | |
85 | (string-append "https://github.com/llvm/llvm-project/releases/download" | |
86 | "/llvmorg-" version "/" component "-" version ".src.tar.xz") | |
87 | (string-append "https://releases.llvm.org/" version "/" component "-" | |
88 | version ".src.tar.xz"))) | |
89 | ||
193192ca | 90 | (define-public llvm-10 |
3e4249ce EB |
91 | (package |
92 | (name "llvm") | |
193192ca | 93 | (version "10.0.0") |
3e4249ce EB |
94 | (source |
95 | (origin | |
96 | (method url-fetch) | |
cd16014f | 97 | (uri (llvm-download-uri "llvm" version)) |
3e4249ce EB |
98 | (sha256 |
99 | (base32 | |
193192ca | 100 | "1pwgm6cr0xr5a0hrbqs1zvsvvjvy0yq1y47c96804wcs795s90yz")))) |
3e4249ce | 101 | (build-system cmake-build-system) |
50b61ec2 | 102 | (outputs '("out" "opt-viewer")) |
3e4249ce | 103 | (native-inputs |
3ebc0905 | 104 | `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2 |
3e4249ce | 105 | ("perl" ,perl))) |
ee077430 | 106 | (inputs |
44e8559d EB |
107 | `(("libffi" ,libffi))) |
108 | (propagated-inputs | |
109 | `(("zlib" ,zlib))) ;to use output from llvm-config | |
3e4249ce | 110 | (arguments |
22d0e9b7 | 111 | `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE" |
ee077430 | 112 | "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE" |
ab78618f | 113 | "-DBUILD_SHARED_LIBS:BOOL=TRUE" |
22897187 | 114 | "-DLLVM_ENABLE_FFI:BOOL=TRUE" |
fc9dbf41 | 115 | "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities |
22897187 | 116 | "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc. |
0935fb27 EB |
117 | |
118 | ;; Don't use '-g' during the build, to save space. | |
ab78618f | 119 | #:build-type "Release" |
50b61ec2 JL |
120 | #:phases |
121 | (modify-phases %standard-phases | |
122 | (add-before 'build 'shared-lib-workaround | |
123 | ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen | |
124 | ;; doesn't seem to get the correct rpath to be able to run | |
125 | ;; from the build directory. Set LD_LIBRARY_PATH as a | |
126 | ;; workaround. | |
127 | (lambda _ | |
128 | (setenv "LD_LIBRARY_PATH" | |
129 | (string-append (getcwd) "/lib")) | |
130 | #t)) | |
131 | (add-after 'install 'install-opt-viewer | |
132 | (lambda* (#:key outputs #:allow-other-keys) | |
133 | (let* ((out (assoc-ref outputs "out")) | |
134 | (opt-viewer-out (assoc-ref outputs "opt-viewer")) | |
135 | (opt-viewer-share-dir (string-append opt-viewer-out "/share")) | |
136 | (opt-viewer-dir (string-append opt-viewer-share-dir "/opt-viewer"))) | |
137 | (mkdir-p opt-viewer-share-dir) | |
138 | (rename-file (string-append out "/share/opt-viewer") | |
139 | opt-viewer-dir)) | |
140 | #t))))) | |
ac97dce1 | 141 | (home-page "https://www.llvm.org") |
3e4249ce EB |
142 | (synopsis "Optimizing compiler infrastructure") |
143 | (description | |
e881752c AK |
144 | "LLVM is a compiler infrastructure designed for compile-time, link-time, |
145 | runtime, and idle-time optimization of programs from arbitrary programming | |
146 | languages. It currently supports compilation of C and C++ programs, using | |
147 | front-ends derived from GCC 4.0.1. A new front-end for the C family of | |
148 | languages is in development. The compiler infrastructure includes mirror sets | |
149 | of programming tools as well as libraries with equivalent functionality.") | |
00ede157 | 150 | (license license:asl2.0))) ;with LLVM exceptions, see LICENSE.txt |
f5de2b9a | 151 | |
6b26f915 LC |
152 | (define* (clang-runtime-from-llvm llvm hash |
153 | #:optional (patches '())) | |
b81f5693 AW |
154 | (package |
155 | (name "clang-runtime") | |
156 | (version (package-version llvm)) | |
157 | (source | |
158 | (origin | |
159 | (method url-fetch) | |
cd16014f | 160 | (uri (llvm-download-uri "compiler-rt" version)) |
6b26f915 LC |
161 | (sha256 (base32 hash)) |
162 | (patches (map search-patch patches)))) | |
b81f5693 AW |
163 | (build-system cmake-build-system) |
164 | (native-inputs (package-native-inputs llvm)) | |
165 | (inputs | |
166 | `(("llvm" ,llvm))) | |
167 | (arguments | |
168 | `(;; Don't use '-g' during the build to save space. | |
3b956a33 | 169 | #:build-type "Release" |
3fd9c90c MB |
170 | #:tests? #f ; Tests require gtest |
171 | #:modules ((srfi srfi-1) | |
172 | (ice-9 match) | |
173 | ,@%cmake-build-system-modules) | |
174 | #:phases (modify-phases (@ (guix build cmake-build-system) %standard-phases) | |
175 | (add-after 'set-paths 'hide-glibc | |
176 | ;; Work around https://issues.guix.info/issue/36882. We need to | |
177 | ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded | |
178 | ;; in GCC, at the bottom of GCC include search-path is used. | |
179 | (lambda* (#:key inputs #:allow-other-keys) | |
180 | (let* ((filters '("libc")) | |
181 | (input-directories | |
182 | (filter-map (lambda (input) | |
183 | (match input | |
184 | ((name . dir) | |
185 | (and (not (member name filters)) | |
186 | dir)))) | |
187 | inputs))) | |
188 | (set-path-environment-variable "CPLUS_INCLUDE_PATH" | |
189 | '("include") | |
190 | input-directories) | |
191 | #t)))))) | |
ac97dce1 | 192 | (home-page "https://compiler-rt.llvm.org") |
b81f5693 AW |
193 | (synopsis "Runtime library for Clang/LLVM") |
194 | (description | |
195 | "The \"clang-runtime\" library provides the implementations of run-time | |
196 | functions for C and C++ programs. It also provides header files that allow C | |
197 | and C++ source code to interface with the \"sanitization\" passes of the clang | |
198 | compiler. In LLVM this library is called \"compiler-rt\".") | |
00ede157 | 199 | (license (package-license llvm)) |
9e6b9ea4 | 200 | |
ac97dce1 | 201 | ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported. |
9e6b9ea4 | 202 | (supported-systems (delete "mips64el-linux" %supported-systems)))) |
b81f5693 | 203 | |
3b956a33 | 204 | (define* (clang-from-llvm llvm clang-runtime hash |
77a87ad4 LC |
205 | #:key (patches '()) tools-extra) |
206 | "Produce Clang with dependencies on LLVM and CLANG-RUNTIME, and applying the | |
207 | given PATCHES. When TOOLS-EXTRA is given, it must point to the | |
208 | 'clang-tools-extra' tarball, which contains code for 'clang-tidy', 'pp-trace', | |
209 | 'modularize', and other tools." | |
3e4249ce EB |
210 | (package |
211 | (name "clang") | |
212 | (version (package-version llvm)) | |
213 | (source | |
214 | (origin | |
215 | (method url-fetch) | |
cd16014f MB |
216 | (uri (llvm-download-uri (if (version>=? version "9.0.1") |
217 | "clang" | |
218 | "cfe") | |
219 | version)) | |
fd6ae1b9 | 220 | (sha256 (base32 hash)) |
3b956a33 | 221 | (patches (map search-patch patches)))) |
3e4249ce EB |
222 | ;; Using cmake allows us to treat llvm as an external library. There |
223 | ;; doesn't seem to be any way to do this with clang's autotools-based | |
224 | ;; build system. | |
225 | (build-system cmake-build-system) | |
77a87ad4 | 226 | (outputs (if tools-extra '("out" "extra") '("out"))) |
3e4249ce EB |
227 | (native-inputs (package-native-inputs llvm)) |
228 | (inputs | |
229 | `(("libxml2" ,libxml2) | |
c92f1c0a | 230 | ("gcc-lib" ,gcc "lib") |
77a87ad4 LC |
231 | ,@(package-inputs llvm) |
232 | ,@(if tools-extra | |
233 | `(("clang-tools-extra" ,tools-extra)) | |
234 | '()))) | |
3e4249ce | 235 | (propagated-inputs |
b81f5693 AW |
236 | `(("llvm" ,llvm) |
237 | ("clang-runtime" ,clang-runtime))) | |
fd6ae1b9 LC |
238 | (arguments |
239 | `(#:configure-flags | |
240 | (list "-DCLANG_INCLUDE_TESTS=True" | |
241 | ||
242 | ;; Find libgcc_s, crtbegin.o, and crtend.o. | |
243 | (string-append "-DGCC_INSTALL_PREFIX=" | |
244 | (assoc-ref %build-inputs "gcc-lib")) | |
245 | ||
246 | ;; Use a sane default include directory. | |
247 | (string-append "-DC_INCLUDE_DIRS=" | |
248 | (assoc-ref %build-inputs "libc") | |
249 | "/include")) | |
250 | ||
94585e88 LC |
251 | ;; Don't use '-g' during the build to save space. |
252 | #:build-type "Release" | |
253 | ||
fd6ae1b9 | 254 | #:phases (modify-phases %standard-phases |
77a87ad4 LC |
255 | ,@(if tools-extra |
256 | `((add-after 'unpack 'add-tools-extra | |
257 | (lambda* (#:key inputs #:allow-other-keys) | |
258 | ;; Unpack the 'clang-tools-extra' tarball under | |
259 | ;; tools/. | |
260 | (let ((extra (assoc-ref inputs | |
261 | "clang-tools-extra"))) | |
262 | (invoke "tar" "xf" extra) | |
263 | (rename-file ,(string-append | |
264 | "clang-tools-extra-" | |
265 | (package-version llvm) | |
266 | ".src") | |
267 | "tools/extra") | |
268 | #t))) | |
269 | (add-after 'install 'move-extra-tools | |
270 | (lambda* (#:key outputs #:allow-other-keys) | |
271 | ;; Move the extra tools to the "extra" output. | |
272 | ;; These programs alone weigh in at 296 MiB, | |
273 | ;; because they statically-link a whole bunch of | |
274 | ;; Clang libraries. | |
275 | (let* ((out (assoc-ref outputs "out")) | |
276 | (extra (assoc-ref outputs "extra")) | |
277 | (bin (string-append out "/bin")) | |
278 | (bin* (string-append extra "/bin")) | |
279 | (lib (string-append out "/lib"))) | |
280 | (define (move program) | |
281 | (rename-file (string-append bin "/" program) | |
282 | (string-append bin* "/" | |
283 | program))) | |
284 | ||
285 | (mkdir-p bin*) | |
286 | (for-each move | |
287 | '("clang-apply-replacements" | |
288 | "clang-change-namespace" | |
289 | "clangd" | |
290 | "clang-doc" | |
291 | "clang-include-fixer" | |
292 | "clang-move" | |
293 | "clang-query" | |
294 | "clang-reorder-fields" | |
295 | "clang-tidy" | |
296 | "find-all-symbols" | |
297 | "modularize" | |
298 | "pp-trace")) | |
299 | ||
300 | ;; Remove MiBs of .a files coming from | |
301 | ;; 'clang-tools-extra'. | |
302 | (for-each (lambda (component) | |
303 | (delete-file | |
304 | (string-append lib "/libclang" | |
305 | component ".a"))) | |
306 | '("ApplyReplacements" | |
307 | "ChangeNamespace" | |
308 | "Daemon" | |
309 | "DaemonTweaks" | |
310 | "Doc" | |
311 | "IncludeFixer" | |
312 | "IncludeFixerPlugin" | |
313 | "Move")) | |
314 | (for-each delete-file | |
315 | (find-files | |
316 | lib | |
317 | "^(libfindAllSymbols|libclangTidy)")) | |
318 | #t)))) | |
319 | '()) | |
f5cc5de8 MB |
320 | (add-after 'unpack 'add-missing-triplets |
321 | (lambda _ | |
322 | ;; Clang iterates through known triplets to search for | |
323 | ;; GCC's headers, but does not recognize some of the | |
324 | ;; triplets that are used in Guix. | |
325 | (substitute* ,@(if (version>=? version "6.0") | |
326 | '("lib/Driver/ToolChains/Gnu.cpp") | |
327 | '("lib/Driver/ToolChains.cpp")) | |
328 | (("\"aarch64-linux-gnu\"," all) | |
329 | (string-append "\"aarch64-unknown-linux-gnu\", " | |
330 | all)) | |
331 | (("\"arm-linux-gnueabihf\"," all) | |
332 | (string-append all | |
333 | " \"arm-unknown-linux-gnueabihf\",")) | |
334 | (("\"i686-pc-linux-gnu\"," all) | |
335 | (string-append "\"i686-unknown-linux-gnu\", " | |
336 | all))) | |
337 | #t)) | |
5041cc28 MB |
338 | (add-after 'unpack 'set-glibc-file-names |
339 | (lambda* (#:key inputs #:allow-other-keys) | |
340 | (let ((libc (assoc-ref inputs "libc")) | |
341 | (compiler-rt (assoc-ref inputs "clang-runtime")) | |
342 | (gcc (assoc-ref inputs "gcc"))) | |
343 | ,@(cond | |
344 | ((version>=? version "6.0") | |
345 | `(;; Link to libclang_rt files from clang-runtime. | |
9bdbabe9 MB |
346 | (substitute* "lib/Driver/ToolChain.cpp" |
347 | (("getDriver\\(\\)\\.ResourceDir") | |
5041cc28 | 348 | (string-append "\"" compiler-rt "\""))) |
9bdbabe9 | 349 | |
5041cc28 MB |
350 | ;; Make "LibDir" refer to <glibc>/lib so that it |
351 | ;; uses the right dynamic linker file name. | |
352 | (substitute* "lib/Driver/ToolChains/Linux.cpp" | |
353 | (("(^[[:blank:]]+LibDir = ).*" _ declaration) | |
354 | (string-append declaration "\"" libc "/lib\";\n")) | |
9bdbabe9 | 355 | |
5041cc28 MB |
356 | ;; Make clang look for libstdc++ in the right |
357 | ;; location. | |
358 | (("LibStdCXXIncludePathCandidates\\[\\] = \\{") | |
359 | (string-append | |
360 | "LibStdCXXIncludePathCandidates[] = { \"" gcc | |
361 | "/include/c++\",")) | |
496bbeee | 362 | |
5041cc28 MB |
363 | ;; Make sure libc's libdir is on the search path, to |
364 | ;; allow crt1.o & co. to be found. | |
365 | (("@GLIBC_LIBDIR@") | |
366 | (string-append libc "/lib"))))) | |
367 | (else | |
368 | `((substitute* "lib/Driver/Tools.cpp" | |
369 | ;; Patch the 'getLinuxDynamicLinker' function so that | |
370 | ;; it uses the right dynamic linker file name. | |
371 | (("/lib64/ld-linux-x86-64.so.2") | |
372 | (string-append libc | |
373 | ,(glibc-dynamic-linker)))) | |
9bdbabe9 | 374 | |
5041cc28 MB |
375 | ;; Link to libclang_rt files from clang-runtime. |
376 | ;; This substitution needed slight adjustment in 3.8. | |
377 | ,@(if (version>=? version "3.8") | |
378 | '((substitute* "lib/Driver/Tools.cpp" | |
379 | (("TC\\.getDriver\\(\\)\\.ResourceDir") | |
380 | (string-append "\"" compiler-rt "\"")))) | |
381 | '((substitute* "lib/Driver/ToolChain.cpp" | |
382 | (("getDriver\\(\\)\\.ResourceDir") | |
383 | (string-append "\"" compiler-rt "\""))))) | |
9bdbabe9 | 384 | |
5041cc28 MB |
385 | ;; Make sure libc's libdir is on the search path, to |
386 | ;; allow crt1.o & co. to be found. | |
387 | (substitute* "lib/Driver/ToolChains.cpp" | |
388 | (("@GLIBC_LIBDIR@") | |
389 | (string-append libc "/lib")))))) | |
390 | #t))) | |
0d3063f4 MB |
391 | ,@(if (version>? version "3.8") |
392 | `((add-after 'install 'symlink-cfi_blacklist | |
393 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
394 | (let* ((out (assoc-ref outputs "out")) | |
395 | (lib-share (string-append out "/lib/clang/" | |
396 | ,version "/share")) | |
397 | (compiler-rt (assoc-ref inputs "clang-runtime")) | |
398 | ;; The location varies between Clang versions. | |
399 | (cfi-blacklist | |
400 | (cond | |
401 | ((file-exists? | |
402 | (string-append compiler-rt "/cfi_blacklist.txt")) | |
403 | (string-append compiler-rt "/cfi_blacklist.txt")) | |
404 | (else (string-append compiler-rt | |
405 | "/share/cfi_blacklist.txt"))))) | |
406 | (mkdir-p lib-share) | |
407 | ;; Symlink cfi_blacklist.txt to where Clang expects | |
408 | ;; to find it. | |
409 | (symlink cfi-blacklist | |
410 | (string-append lib-share "/cfi_blacklist.txt")) | |
411 | #t)))) | |
412 | '()) | |
1c7372a5 PN |
413 | (add-after 'install 'install-clean-up-/share/clang |
414 | (lambda* (#:key outputs #:allow-other-keys) | |
415 | (let* ((out (assoc-ref outputs "out")) | |
416 | (compl-dir (string-append | |
417 | out "/etc/bash_completion.d"))) | |
418 | (with-directory-excursion (string-append out | |
419 | "/share/clang") | |
ad8a4a66 PN |
420 | (for-each |
421 | (lambda (file) | |
422 | (when (file-exists? file) | |
423 | (delete-file file))) | |
424 | ;; Delete extensions for proprietary text editors. | |
425 | '("clang-format-bbedit.applescript" | |
426 | "clang-format-sublime.py" | |
427 | ;; Delete Emacs extensions: see their respective Emacs | |
428 | ;; Guix package instead. | |
429 | "clang-rename.el" "clang-format.el")) | |
1c7372a5 | 430 | ;; Install bash completion. |
ad8a4a66 PN |
431 | (when (file-exists? "bash-autocomplete.sh") |
432 | (mkdir-p compl-dir) | |
433 | (rename-file "bash-autocomplete.sh" | |
434 | (string-append compl-dir "/clang"))))) | |
1c7372a5 | 435 | #t))))) |
ef11ac87 LC |
436 | |
437 | ;; Clang supports the same environment variables as GCC. | |
438 | (native-search-paths | |
439 | (list (search-path-specification | |
f42bfc7a | 440 | (variable "C_INCLUDE_PATH") |
ef11ac87 | 441 | (files '("include"))) |
f42bfc7a MB |
442 | (search-path-specification |
443 | (variable "CPLUS_INCLUDE_PATH") | |
444 | (files '("include/c++" "include"))) | |
ef11ac87 LC |
445 | (search-path-specification |
446 | (variable "LIBRARY_PATH") | |
447 | (files '("lib" "lib64"))))) | |
448 | ||
ac97dce1 | 449 | (home-page "https://clang.llvm.org") |
3e4249ce EB |
450 | (synopsis "C language family frontend for LLVM") |
451 | (description | |
452 | "Clang is a compiler front end for the C, C++, Objective-C and | |
453 | Objective-C++ programming languages. It uses LLVM as its back end. The Clang | |
454 | project includes the Clang front end, the Clang static analyzer, and several | |
455 | code analysis tools.") | |
00ede157 MB |
456 | (license (if (version>=? version "9.0") |
457 | license:asl2.0 ;with LLVM exceptions | |
458 | license:ncsa)))) | |
1204c510 | 459 | |
57c7bfec MO |
460 | (define (make-clang-toolchain clang) |
461 | (package | |
462 | (name (string-append (package-name clang) "-toolchain")) | |
463 | (version (package-version clang)) | |
464 | (source #f) | |
465 | (build-system trivial-build-system) | |
466 | (arguments | |
467 | '(#:modules ((guix build union)) | |
468 | #:builder (begin | |
469 | (use-modules (ice-9 match) | |
470 | (srfi srfi-26) | |
471 | (guix build union)) | |
472 | ||
473 | (let ((out (assoc-ref %outputs "out"))) | |
474 | ||
475 | (match %build-inputs | |
476 | (((names . directories) ...) | |
477 | (union-build out directories))) | |
478 | ||
479 | (union-build (assoc-ref %outputs "debug") | |
480 | (list (assoc-ref %build-inputs | |
481 | "libc-debug"))) | |
482 | (union-build (assoc-ref %outputs "static") | |
483 | (list (assoc-ref %build-inputs | |
484 | "libc-static"))) | |
485 | #t)))) | |
486 | ||
487 | (native-search-paths (package-native-search-paths clang)) | |
488 | (search-paths (package-search-paths clang)) | |
489 | ||
490 | (license (package-license clang)) | |
491 | (home-page "https://clang.llvm.org") | |
492 | (synopsis "Complete Clang toolchain for C/C++ development") | |
493 | (description "This package provides a complete Clang toolchain for C/C++ | |
494 | development to be installed in user profiles. This includes Clang, as well as | |
495 | libc (headers and binaries, plus debugging symbols in the @code{debug} | |
496 | output), and Binutils.") | |
497 | (outputs '("out" "debug" "static")) | |
498 | (inputs `(("clang" ,clang) | |
499 | ("ld-wrapper" ,(car (assoc-ref (%final-inputs) "ld-wrapper"))) | |
500 | ("binutils" ,binutils) | |
501 | ("libc" ,glibc) | |
502 | ("libc-debug" ,glibc "debug") | |
503 | ("libc-static" ,glibc "static"))))) | |
504 | ||
193192ca LC |
505 | (define-public clang-runtime-10 |
506 | (clang-runtime-from-llvm | |
507 | llvm-10 | |
508 | "0x9c531k6ww21s2mkdwqx1vbdjmx6d4wmfb8gdbj0wqa796sczba")) | |
509 | ||
510 | (define-public clang-10 | |
511 | (clang-from-llvm llvm-10 clang-runtime-10 | |
512 | "08fbxa2a0kr3ni35ckppj0kyvlcyaywrhpqwcdrdy0z900mhcnw8" | |
77a87ad4 LC |
513 | #:patches '("clang-10.0-libc-search-path.patch") |
514 | #:tools-extra | |
515 | (origin | |
516 | (method url-fetch) | |
517 | (uri (llvm-download-uri "clang-tools-extra" | |
518 | (package-version llvm-10))) | |
519 | (sha256 | |
520 | (base32 | |
521 | "074ija5s2jsdn0k035r2dzmryjmqxdnyg4xwvaqych2bazv8rpxc"))))) | |
193192ca LC |
522 | |
523 | (define-public clang-toolchain-10 | |
524 | (make-clang-toolchain clang-10)) | |
525 | ||
526 | (define-public llvm-9 | |
527 | (package | |
528 | (inherit llvm-10) | |
529 | (version "9.0.1") | |
530 | (source | |
531 | (origin | |
532 | (method url-fetch) | |
533 | (uri (llvm-download-uri "llvm" version)) | |
534 | (sha256 | |
535 | (base32 | |
851a7caf JK |
536 | "16hwp3qa54c3a3v7h8nlw0fh5criqh0hlr1skybyk0cz70gyx880")) |
537 | (patch-flags '("-p2")) | |
538 | (patches (search-patches | |
ff2f8611 | 539 | "llvm-9-fix-bitcast-miscompilation.patch" |
851a7caf JK |
540 | "llvm-9-fix-scev-miscompilation.patch" |
541 | "llvm-9-fix-lpad-miscompilation.patch")))))) | |
193192ca LC |
542 | |
543 | (define-public clang-runtime-9 | |
b81f5693 | 544 | (clang-runtime-from-llvm |
193192ca | 545 | llvm-9 |
af88972b MB |
546 | "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2" |
547 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
b81f5693 | 548 | |
193192ca LC |
549 | (define-public clang-9 |
550 | (clang-from-llvm llvm-9 clang-runtime-9 | |
00ede157 MB |
551 | "0ls2h3iv4finqyflyhry21qhc9cm9ga7g1zq21020p065qmm2y2p" |
552 | #:patches '("clang-9.0-libc-search-path.patch"))) | |
d199a4c7 | 553 | |
193192ca LC |
554 | (define-public clang-toolchain-9 |
555 | (make-clang-toolchain clang-9)) | |
57c7bfec | 556 | |
193192ca LC |
557 | ;; Default LLVM and Clang version. |
558 | (define-public llvm llvm-9) | |
559 | (define-public clang-runtime clang-runtime-9) | |
560 | (define-public clang clang-9) | |
561 | (define-public clang-toolchain clang-toolchain-9) | |
00ede157 | 562 | |
5ce123bd JK |
563 | (define-public lld |
564 | (package | |
565 | (name "lld") | |
566 | (version (package-version llvm-10)) | |
567 | (source (origin | |
568 | (method url-fetch) | |
569 | (uri (llvm-download-uri "lld" version)) | |
570 | (sha256 | |
571 | (base32 | |
572 | "026pwcbczcg0j5c9h7hxxrn3ki81ia9m9sfn0sy0bvzffv2xg85r")))) | |
573 | (build-system cmake-build-system) | |
574 | (inputs | |
575 | `(("llvm" ,llvm-10))) | |
576 | (arguments | |
577 | `(#:build-type "Release" | |
578 | ;; TODO: Tests require the lit tool, which isn't installed by the LLVM | |
579 | ;; package. | |
580 | #:tests? #f)) | |
581 | (home-page "https://lld.llvm.org/") | |
582 | (synopsis "Linker from the LLVM project") | |
583 | (description "LLD is a high-performance linker, built as a set of reusable | |
584 | components which highly leverage existing libraries in the larger LLVM Project.") | |
585 | (license license:asl2.0))) ; With LLVM exception | |
586 | ||
00ede157 | 587 | (define-public llvm-8 |
96d5a206 DT |
588 | (package |
589 | (inherit llvm) | |
00ede157 | 590 | (version "8.0.0") |
96d5a206 DT |
591 | (source (origin |
592 | (method url-fetch) | |
cd16014f | 593 | (uri (llvm-download-uri "llvm" version)) |
96d5a206 DT |
594 | (sha256 |
595 | (base32 | |
00ede157 MB |
596 | "0k124sxkfhfi1rca6kzkdraf4axhx99x3cw2rk55056628dvwwl8")))) |
597 | (license license:ncsa))) | |
96d5a206 | 598 | |
00ede157 | 599 | (define-public clang-runtime-8 |
96d5a206 | 600 | (clang-runtime-from-llvm |
00ede157 | 601 | llvm-8 |
af88972b MB |
602 | "1c919wsm17xnv7lr8bhpq2wkq8113lzlw6hzhfr737j59x3wfddl" |
603 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
96d5a206 | 604 | |
00ede157 MB |
605 | (define-public clang-8 |
606 | (clang-from-llvm llvm-8 clang-runtime-8 | |
607 | "0svk1f70hvpwrjp6x5i9kqwrqwxnmcrw5s7f4cxyd100mdd12k08" | |
608 | #:patches '("clang-7.0-libc-search-path.patch"))) | |
96d5a206 | 609 | |
00ede157 MB |
610 | (define-public clang-toolchain-8 |
611 | (make-clang-toolchain clang-8)) | |
96d5a206 | 612 | |
4289d1d7 MB |
613 | (define-public llvm-7 |
614 | (package | |
00ede157 | 615 | (inherit llvm-8) |
4289d1d7 MB |
616 | (version "7.0.1") |
617 | (source (origin | |
618 | (method url-fetch) | |
cd16014f | 619 | (uri (llvm-download-uri "llvm" version)) |
4289d1d7 MB |
620 | (sha256 |
621 | (base32 | |
622 | "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3")))))) | |
623 | ||
624 | (define-public clang-runtime-7 | |
625 | (clang-runtime-from-llvm | |
626 | llvm-7 | |
af88972b MB |
627 | "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq" |
628 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
4289d1d7 MB |
629 | |
630 | (define-public clang-7 | |
501672d7 | 631 | (clang-from-llvm llvm-7 clang-runtime-7 |
4289d1d7 MB |
632 | "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4" |
633 | #:patches '("clang-7.0-libc-search-path.patch"))) | |
634 | ||
57c7bfec MO |
635 | (define-public clang-toolchain-7 |
636 | (make-clang-toolchain clang-7)) | |
637 | ||
d199a4c7 MB |
638 | (define-public llvm-6 |
639 | (package | |
00ede157 | 640 | (inherit llvm-7) |
d199a4c7 MB |
641 | (version "6.0.1") |
642 | (source (origin | |
643 | (method url-fetch) | |
cd16014f | 644 | (uri (llvm-download-uri "llvm" version)) |
d199a4c7 MB |
645 | (sha256 |
646 | (base32 | |
647 | "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn")))))) | |
648 | ||
649 | (define-public clang-runtime-6 | |
650 | (clang-runtime-from-llvm | |
651 | llvm-6 | |
af88972b MB |
652 | "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl" |
653 | '("clang-runtime-9-libsanitizer-mode-field.patch"))) | |
d199a4c7 MB |
654 | |
655 | (define-public clang-6 | |
501672d7 | 656 | (clang-from-llvm llvm-6 clang-runtime-6 |
148df605 | 657 | "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w" |
9bdbabe9 | 658 | #:patches '("clang-6.0-libc-search-path.patch"))) |
3b956a33 | 659 | |
57c7bfec MO |
660 | (define-public clang-toolchain-6 |
661 | (make-clang-toolchain clang-6)) | |
662 | ||
584da12d | 663 | (define-public llvm-3.9.1 |
00ede157 | 664 | (package (inherit llvm-6) |
584da12d RJ |
665 | (name "llvm") |
666 | (version "3.9.1") | |
667 | (source | |
668 | (origin | |
669 | (method url-fetch) | |
cd16014f | 670 | (uri (llvm-download-uri "llvm" version)) |
584da12d RJ |
671 | (sha256 |
672 | (base32 | |
a6046f24 MB |
673 | "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z")))) |
674 | (outputs '("out")) | |
675 | (arguments | |
676 | (substitute-keyword-arguments (package-arguments llvm) | |
677 | ((#:phases phases) | |
678 | `(modify-phases ,phases | |
679 | (delete 'install-opt-viewer))))))) | |
584da12d RJ |
680 | |
681 | (define-public clang-runtime-3.9.1 | |
682 | (clang-runtime-from-llvm | |
683 | llvm-3.9.1 | |
6b26f915 | 684 | "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk" |
af88972b MB |
685 | '("clang-runtime-3.9-libsanitizer-mode-field.patch" |
686 | "clang-runtime-asan-build-fixes.patch" | |
0627f93d | 687 | "clang-runtime-esan-build-fixes.patch" |
1a2d8d06 | 688 | "clang-3.5-libsanitizer-ustat-fix.patch"))) |
584da12d RJ |
689 | |
690 | (define-public clang-3.9.1 | |
691 | (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1 | |
692 | "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76" | |
9bdbabe9 MB |
693 | #:patches '("clang-3.8-libc-search-path.patch"))) |
694 | ||
695 | (define-public llvm-3.8 | |
a6046f24 | 696 | (package (inherit llvm-3.9.1) |
9bdbabe9 MB |
697 | (name "llvm") |
698 | (version "3.8.1") | |
699 | (source | |
700 | (origin | |
701 | (method url-fetch) | |
cd16014f | 702 | (uri (llvm-download-uri "llvm" version)) |
9bdbabe9 MB |
703 | (sha256 |
704 | (base32 | |
705 | "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf")))))) | |
706 | ||
707 | (define-public clang-runtime-3.8 | |
708 | (clang-runtime-from-llvm | |
709 | llvm-3.8 | |
710 | "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d" | |
0627f93d | 711 | '("clang-runtime-asan-build-fixes.patch" |
af88972b | 712 | "clang-runtime-3.8-libsanitizer-mode-field.patch" |
1a2d8d06 | 713 | "clang-3.5-libsanitizer-ustat-fix.patch"))) |
9bdbabe9 MB |
714 | |
715 | (define-public clang-3.8 | |
716 | (clang-from-llvm llvm-3.8 clang-runtime-3.8 | |
717 | "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc" | |
718 | #:patches '("clang-3.8-libc-search-path.patch"))) | |
584da12d | 719 | |
3b956a33 | 720 | (define-public llvm-3.7 |
00ede157 | 721 | (package (inherit llvm-3.8) |
3b956a33 EB |
722 | (version "3.7.1") |
723 | (source | |
724 | (origin | |
725 | (method url-fetch) | |
cd16014f | 726 | (uri (llvm-download-uri "llvm" version)) |
3b956a33 EB |
727 | (sha256 |
728 | (base32 | |
729 | "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy")))))) | |
730 | ||
731 | (define-public clang-runtime-3.7 | |
732 | (clang-runtime-from-llvm | |
733 | llvm-3.7 | |
6b26f915 | 734 | "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx" |
0627f93d | 735 | '("clang-runtime-asan-build-fixes.patch" |
af88972b | 736 | "clang-runtime-3.8-libsanitizer-mode-field.patch" |
1a2d8d06 | 737 | "clang-3.5-libsanitizer-ustat-fix.patch"))) |
3b956a33 EB |
738 | |
739 | (define-public clang-3.7 | |
740 | (clang-from-llvm llvm-3.7 clang-runtime-3.7 | |
9bdbabe9 MB |
741 | "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn" |
742 | #:patches '("clang-3.5-libc-search-path.patch"))) | |
3ebc0905 EB |
743 | |
744 | (define-public llvm-3.6 | |
00ede157 | 745 | (package (inherit llvm-3.7) |
3ebc0905 EB |
746 | (version "3.6.2") |
747 | (source | |
748 | (origin | |
749 | (method url-fetch) | |
cd16014f | 750 | (uri (llvm-download-uri "llvm" version)) |
3ebc0905 EB |
751 | (sha256 |
752 | (base32 | |
753 | "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn")))))) | |
754 | ||
755 | (define-public clang-runtime-3.6 | |
756 | (clang-runtime-from-llvm | |
757 | llvm-3.6 | |
6b26f915 | 758 | "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg" |
af88972b | 759 | '("clang-runtime-asan-build-fixes.patch"))) |
3ebc0905 EB |
760 | |
761 | (define-public clang-3.6 | |
762 | (clang-from-llvm llvm-3.6 clang-runtime-3.6 | |
9bdbabe9 MB |
763 | "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df" |
764 | #:patches '("clang-3.5-libc-search-path.patch"))) | |
1204c510 MW |
765 | |
766 | (define-public llvm-3.5 | |
00ede157 | 767 | (package (inherit llvm-3.6) |
a53c486d | 768 | (version "3.5.2") |
1204c510 MW |
769 | (source |
770 | (origin | |
771 | (method url-fetch) | |
cd16014f | 772 | (uri (llvm-download-uri "llvm" version)) |
6ba4eca2 RW |
773 | (patches |
774 | (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch")) | |
1204c510 MW |
775 | (sha256 |
776 | (base32 | |
a53c486d | 777 | "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4")))))) |
1204c510 | 778 | |
b81f5693 | 779 | (define-public clang-runtime-3.5 |
290b55c5 RW |
780 | (let ((runtime (clang-runtime-from-llvm |
781 | llvm-3.5 | |
782 | "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal" | |
783 | '("clang-runtime-asan-build-fixes.patch" | |
784 | "clang-3.5-libsanitizer-ustat-fix.patch")))) | |
785 | (package | |
786 | (inherit runtime) | |
787 | (arguments | |
788 | (substitute-keyword-arguments (package-arguments runtime) | |
789 | ((#:phases phases '%standard-phases) | |
790 | `(modify-phases ,phases | |
791 | ;; glibc no longer includes rpc/xdr.h, so we use the headers from | |
792 | ;; libtirpc. | |
793 | (add-after 'unpack 'find-rpc-includes | |
794 | (lambda* (#:key inputs #:allow-other-keys) | |
795 | (setenv "CPATH" | |
796 | (string-append (assoc-ref inputs "libtirpc") | |
797 | "/include/tirpc/:" | |
798 | (or (getenv "CPATH") ""))) | |
799 | (setenv "CPLUS_INCLUDE_PATH" | |
800 | (string-append (assoc-ref inputs "libtirpc") | |
801 | "/include/tirpc/:" | |
802 | (or (getenv "CPLUS_INCLUDE_PATH") ""))) | |
803 | #t)))))) | |
804 | (inputs | |
805 | `(("libtirpc" ,libtirpc) | |
806 | ("llvm" ,llvm-3.5)))))) | |
b81f5693 | 807 | |
1204c510 | 808 | (define-public clang-3.5 |
b81f5693 | 809 | (clang-from-llvm llvm-3.5 clang-runtime-3.5 |
9bdbabe9 MB |
810 | "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg" |
811 | #:patches '("clang-3.5-libc-search-path.patch"))) | |
921cb13a RW |
812 | |
813 | (define-public llvm-for-extempore | |
b1cb8b5d | 814 | (package (inherit llvm-3.8) |
7355634d | 815 | (name "llvm-for-extempore") |
921cb13a RW |
816 | (source |
817 | (origin | |
b1cb8b5d GL |
818 | (method url-fetch) |
819 | (uri (string-append "http://extempore.moso.com.au/extras/" | |
820 | "llvm-3.8.0.src-patched-for-extempore.tar.xz")) | |
821 | (sha256 | |
822 | (base32 | |
823 | "1svdl6fxn8l01ni8mpm0bd5h856ahv3h9sdzgmymr6fayckjvqzs")))) | |
39162ee4 RW |
824 | ;; Extempore refuses to build on architectures other than x86_64 |
825 | (supported-systems '("x86_64-linux")))) | |
8892cac3 | 826 | |
52f9c3b8 MB |
827 | (define-public libcxx |
828 | (package | |
829 | (name "libcxx") | |
00ede157 | 830 | (version "9.0.1") |
52f9c3b8 MB |
831 | (source |
832 | (origin | |
833 | (method url-fetch) | |
834 | (uri (llvm-download-uri "libcxx" version)) | |
835 | (sha256 | |
836 | (base32 | |
00ede157 | 837 | "0d2bj5i6mk4caq7skd5nsdmz8c2m5w5anximl5wz3x32p08zz089")))) |
52f9c3b8 | 838 | (build-system cmake-build-system) |
40a461fd MB |
839 | (arguments |
840 | `(#:phases | |
841 | (modify-phases (@ (guix build cmake-build-system) %standard-phases) | |
842 | (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH | |
843 | (lambda* (#:key inputs #:allow-other-keys) | |
844 | (let ((gcc (assoc-ref inputs "gcc"))) | |
845 | ;; Hide GCC's C++ headers so that they do not interfere with | |
846 | ;; the ones we are attempting to build. | |
847 | (setenv "CPLUS_INCLUDE_PATH" | |
848 | (string-join (delete (string-append gcc "/include/c++") | |
849 | (string-split (getenv "CPLUS_INCLUDE_PATH") | |
850 | #\:)) | |
851 | ":")) | |
852 | (format #t | |
853 | "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" | |
854 | (getenv "CPLUS_INCLUDE_PATH")) | |
855 | #t)))))) | |
52f9c3b8 MB |
856 | (native-inputs |
857 | `(("clang" ,clang) | |
858 | ("llvm" ,llvm))) | |
859 | (home-page "https://libcxx.llvm.org") | |
860 | (synopsis "C++ standard library") | |
861 | (description | |
862 | "This package provides an implementation of the C++ standard library for | |
863 | use with Clang, targeting C++11, C++14 and above.") | |
864 | (license license:expat))) | |
865 | ||
866 | ;; Libcxx files specifically used by PySide2. | |
867 | (define-public libcxx-6 | |
868 | (package | |
869 | (inherit libcxx) | |
870 | (version (package-version llvm-6)) | |
871 | (source | |
872 | (origin | |
873 | (inherit (package-source libcxx)) | |
874 | (uri (llvm-download-uri "libcxx" version)) | |
875 | (sha256 | |
876 | (base32 | |
877 | "0rzw4qvxp6qx4l4h9amrq02gp7hbg8lw4m0sy3k60f50234gnm3n")))) | |
878 | (native-inputs | |
879 | `(("clang" ,clang-6) | |
880 | ("llvm" ,llvm-6))))) | |
881 | ||
882 | (define-public libclc | |
883 | (package | |
884 | (name "libclc") | |
00ede157 | 885 | (version "9.0.1") |
52f9c3b8 MB |
886 | (source |
887 | (origin | |
888 | (method git-fetch) | |
889 | (uri (git-reference | |
b0e7b699 | 890 | (url "https://github.com/llvm/llvm-project") |
52f9c3b8 MB |
891 | (commit (string-append "llvmorg-" version)))) |
892 | (file-name (git-file-name name version)) | |
893 | (sha256 | |
894 | (base32 | |
00ede157 | 895 | "1d1qayvrvvc1di7s7jfxnjvxq2az4lwq1sw1b2gq2ic0nksvajz0")))) |
52f9c3b8 MB |
896 | (build-system cmake-build-system) |
897 | (arguments | |
898 | `(#:configure-flags | |
899 | (list (string-append "-DLLVM_CLANG=" | |
900 | (assoc-ref %build-inputs "clang") | |
901 | "/bin/clang") | |
902 | (string-append "-DPYTHON=" | |
903 | (assoc-ref %build-inputs "python") | |
904 | "/bin/python3")) | |
905 | #:phases | |
906 | (modify-phases %standard-phases | |
907 | (add-after 'unpack 'chdir | |
908 | (lambda _ (chdir "libclc") #t))))) | |
909 | (native-inputs | |
910 | `(("clang" ,clang) | |
911 | ("llvm" ,llvm) | |
912 | ("python" ,python))) | |
913 | (home-page "https://libclc.llvm.org") | |
914 | (synopsis "Libraries for the OpenCL programming language") | |
915 | (description | |
916 | "This package provides an implementation of the OpenCL library | |
917 | requirements according to version 1.1 of the OpenCL specification.") | |
918 | ;; Apache license 2.0 with LLVM exception | |
919 | (license license:asl2.0))) | |
920 | ||
921 | (define-public libomp | |
922 | (package | |
923 | (name "libomp") | |
00ede157 | 924 | (version "9.0.1") |
52f9c3b8 MB |
925 | (source (origin |
926 | (method url-fetch) | |
927 | (uri (llvm-download-uri "openmp" version)) | |
928 | (sha256 | |
929 | (base32 | |
00ede157 | 930 | "1knafnpp0f7hylx8q20lkd6g1sf0flly572dayc5d5kghh7hd52w")) |
52f9c3b8 MB |
931 | (file-name (string-append "libomp-" version ".tar.xz")))) |
932 | (build-system cmake-build-system) | |
933 | ;; XXX: Note this gets built with GCC because building with Clang itself | |
934 | ;; fails (missing <atomic>, even when libcxx is added as an input.) | |
935 | (arguments | |
936 | '(#:configure-flags '("-DLIBOMP_USE_HWLOC=ON" | |
937 | "-DOPENMP_TEST_C_COMPILER=clang" | |
938 | "-DOPENMP_TEST_CXX_COMPILER=clang++") | |
939 | #:test-target "check-libomp")) | |
940 | (native-inputs | |
941 | `(("clang" ,clang) | |
942 | ("llvm" ,llvm) | |
943 | ("perl" ,perl) | |
944 | ("pkg-config" ,pkg-config))) | |
945 | (inputs | |
946 | `(("hwloc" ,hwloc "lib"))) | |
947 | (home-page "https://openmp.llvm.org") | |
948 | (synopsis "OpenMP run-time support library") | |
949 | (description | |
950 | "This package provides the run-time support library developed by the LLVM | |
951 | project for the OpenMP multi-theaded programming extension. This package | |
952 | notably provides @file{libgomp.so}, which is has a binary interface compatible | |
953 | with that of libgomp, the GNU Offloading and Multi Processing Library.") | |
954 | (license license:expat))) | |
955 | ||
8892cac3 RW |
956 | (define-public python-llvmlite |
957 | (package | |
958 | (name "python-llvmlite") | |
66087272 | 959 | (version "0.30.0") |
8892cac3 RW |
960 | (source |
961 | (origin | |
962 | (method url-fetch) | |
963 | (uri (pypi-uri "llvmlite" version)) | |
964 | (sha256 | |
965 | (base32 | |
66087272 | 966 | "01wspdc0xhnydl66jyhyr4ii16h3fnw6mjihiwnnxdxg9j6kkajf")))) |
8892cac3 | 967 | (build-system python-build-system) |
66087272 BG |
968 | (arguments |
969 | ;; FIXME: One test fails unable to find libm.so | |
970 | ;; https://github.com/numba/llvmlite/issues/537 | |
971 | `(#:tests? #f)) | |
8892cac3 RW |
972 | (inputs |
973 | `(("llvm" | |
6ee74687 CB |
974 | ,(let ((patches-commit "486edd5fb2a6667feb5c865f300c0da73785434a")) |
975 | (package | |
976 | (inherit llvm-7) | |
977 | (source | |
978 | (origin | |
979 | (inherit (package-source llvm-7)) | |
980 | (patches | |
981 | (list | |
982 | (origin | |
983 | (method url-fetch) | |
984 | (uri (string-append | |
985 | "https://raw.githubusercontent.com/numba/" | |
986 | "llvmlite/" patches-commit "/conda-recipes/" | |
987 | "D47188-svml-VF.patch")) | |
988 | (sha256 | |
989 | (base32 | |
990 | "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr"))) | |
991 | (origin | |
992 | (method url-fetch) | |
993 | (uri (string-append | |
994 | "https://raw.githubusercontent.com/numba/" | |
995 | "llvmlite/" patches-commit "/conda-recipes/" | |
996 | "twine_cfg_undefined_behavior.patch")) | |
997 | (sha256 | |
998 | (base32 | |
999 | "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))) | |
8892cac3 RW |
1000 | (home-page "http://llvmlite.pydata.org") |
1001 | (synopsis "Wrapper around basic LLVM functionality") | |
1002 | (description | |
1003 | "This package provides a Python binding to LLVM for use in Numba.") | |
1004 | (license license:bsd-3))) | |
7628ff1f TG |
1005 | |
1006 | (define-public emacs-clang-format | |
1007 | (package | |
1008 | (inherit clang) | |
1009 | (name "emacs-clang-format") | |
1010 | (build-system emacs-build-system) | |
1011 | (inputs | |
1012 | `(("clang" ,clang))) | |
1013 | (arguments | |
1014 | `(#:phases | |
1015 | (modify-phases %standard-phases | |
1016 | (add-after 'unpack 'configure | |
1017 | (lambda* (#:key inputs #:allow-other-keys) | |
1018 | (let ((clang (assoc-ref inputs "clang"))) | |
1019 | (copy-file "tools/clang-format/clang-format.el" "clang-format.el") | |
1020 | (emacs-substitute-variables "clang-format.el" | |
1021 | ("clang-format-executable" | |
1022 | (string-append clang "/bin/clang-format")))) | |
1023 | #t))))) | |
1024 | (synopsis "Format code using clang-format") | |
3bb22e54 | 1025 | (description "This package filters code through @code{clang-format} |
7628ff1f TG |
1026 | to fix its formatting. @code{clang-format} is a tool that formats |
1027 | C/C++/Obj-C code according to a set of style options, see | |
3bdcc668 | 1028 | @url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))) |
51002b72 PN |
1029 | |
1030 | (define-public emacs-clang-rename | |
1031 | (package | |
1032 | (inherit clang) | |
1033 | (name "emacs-clang-rename") | |
1034 | (build-system emacs-build-system) | |
1035 | (inputs | |
1036 | `(("clang" ,clang))) | |
1037 | (arguments | |
1038 | `(#:phases | |
1039 | (modify-phases %standard-phases | |
1040 | (add-after 'unpack 'configure | |
1041 | (lambda* (#:key inputs #:allow-other-keys) | |
1042 | (let ((clang (assoc-ref inputs "clang"))) | |
1043 | (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el") | |
1044 | (emacs-substitute-variables "clang-rename.el" | |
1045 | ("clang-rename-binary" | |
1046 | (string-append clang "/bin/clang-rename")))) | |
1047 | #t))))) | |
1048 | (synopsis "Rename every occurrence of a symbol using clang-rename") | |
1049 | (description "This package renames every occurrence of a symbol at point | |
1050 | using @code{clang-rename}."))) |