Commit | Line | Data |
---|---|---|
3e4249ce | 1 | ;;; GNU Guix --- Functional package management for GNU |
a53c486d | 2 | ;;; Copyright © 2014, 2016 Eric Bavier <bavier@member.fsf.org> |
1204c510 | 3 | ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> |
6b26f915 | 4 | ;;; Copyright © 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org> |
ee077430 | 5 | ;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com> |
921cb13a | 6 | ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net> |
584da12d | 7 | ;;; Copyright © 2017 Roel Janssen <roel@gnu.org> |
3e4249ce EB |
8 | ;;; |
9 | ;;; This file is part of GNU Guix. | |
10 | ;;; | |
11 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
12 | ;;; under the terms of the GNU General Public License as published by | |
13 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
14 | ;;; your option) any later version. | |
15 | ;;; | |
16 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
17 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;;; GNU General Public License for more details. | |
20 | ;;; | |
21 | ;;; You should have received a copy of the GNU General Public License | |
22 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
23 | ||
24 | (define-module (gnu packages llvm) | |
25 | #:use-module (guix packages) | |
ac00973c | 26 | #:use-module ((guix licenses) #:prefix license:) |
3e4249ce EB |
27 | #:use-module (guix download) |
28 | #:use-module (guix utils) | |
29 | #:use-module (guix build-system gnu) | |
30 | #:use-module (guix build-system cmake) | |
31 | #:use-module (gnu packages) | |
fd6ae1b9 LC |
32 | #:use-module (gnu packages gcc) |
33 | #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker | |
ee077430 EB |
34 | #:use-module (gnu packages compression) |
35 | #:use-module (gnu packages libffi) | |
3e4249ce EB |
36 | #:use-module (gnu packages perl) |
37 | #:use-module (gnu packages python) | |
38 | #:use-module (gnu packages xml)) | |
39 | ||
40 | (define-public llvm | |
41 | (package | |
42 | (name "llvm") | |
3b956a33 | 43 | (version "3.8.1") |
3e4249ce EB |
44 | (source |
45 | (origin | |
46 | (method url-fetch) | |
47 | (uri (string-append "http://llvm.org/releases/" | |
48 | version "/llvm-" version ".src.tar.xz")) | |
49 | (sha256 | |
50 | (base32 | |
3b956a33 | 51 | "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf")))) |
3e4249ce EB |
52 | (build-system cmake-build-system) |
53 | (native-inputs | |
3ebc0905 | 54 | `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2 |
3e4249ce | 55 | ("perl" ,perl))) |
ee077430 | 56 | (inputs |
44e8559d EB |
57 | `(("libffi" ,libffi))) |
58 | (propagated-inputs | |
59 | `(("zlib" ,zlib))) ;to use output from llvm-config | |
3e4249ce | 60 | (arguments |
22d0e9b7 | 61 | `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE" |
ee077430 | 62 | "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE" |
ab78618f | 63 | "-DBUILD_SHARED_LIBS:BOOL=TRUE" |
22897187 DC |
64 | "-DLLVM_ENABLE_FFI:BOOL=TRUE" |
65 | "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc. | |
0935fb27 EB |
66 | |
67 | ;; Don't use '-g' during the build, to save space. | |
ab78618f EB |
68 | #:build-type "Release" |
69 | #:phases (modify-phases %standard-phases | |
70 | (add-before 'build 'shared-lib-workaround | |
71 | ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen | |
72 | ;; doesn't seem to get the correct rpath to be able to run | |
73 | ;; from the build directory. Set LD_LIBRARY_PATH as a | |
74 | ;; workaround. | |
75 | (lambda _ | |
76 | (setenv "LD_LIBRARY_PATH" | |
77 | (string-append (getcwd) "/lib")) | |
78 | #t))))) | |
ac97dce1 | 79 | (home-page "https://www.llvm.org") |
3e4249ce EB |
80 | (synopsis "Optimizing compiler infrastructure") |
81 | (description | |
e881752c AK |
82 | "LLVM is a compiler infrastructure designed for compile-time, link-time, |
83 | runtime, and idle-time optimization of programs from arbitrary programming | |
84 | languages. It currently supports compilation of C and C++ programs, using | |
85 | front-ends derived from GCC 4.0.1. A new front-end for the C family of | |
86 | languages is in development. The compiler infrastructure includes mirror sets | |
87 | of programming tools as well as libraries with equivalent functionality.") | |
ac00973c | 88 | (license license:ncsa))) |
3e4249ce | 89 | |
83c49858 RW |
90 | (define-public llvm-with-rtti |
91 | (package (inherit llvm) | |
92 | (name "llvm-with-rtti") | |
93 | (arguments | |
94 | (substitute-keyword-arguments (package-arguments llvm) | |
95 | ((#:configure-flags flags) | |
96 | `(append '("-DCMAKE_SKIP_BUILD_RPATH=FALSE" | |
97 | "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE" | |
98 | "-DLLVM_REQUIRES_RTTI=1") | |
99 | ,flags)))))) | |
100 | ||
6b26f915 LC |
101 | (define* (clang-runtime-from-llvm llvm hash |
102 | #:optional (patches '())) | |
b81f5693 AW |
103 | (package |
104 | (name "clang-runtime") | |
105 | (version (package-version llvm)) | |
106 | (source | |
107 | (origin | |
108 | (method url-fetch) | |
109 | (uri (string-append "http://llvm.org/releases/" | |
110 | version "/compiler-rt-" version ".src.tar.xz")) | |
6b26f915 LC |
111 | (sha256 (base32 hash)) |
112 | (patches (map search-patch patches)))) | |
b81f5693 AW |
113 | (build-system cmake-build-system) |
114 | (native-inputs (package-native-inputs llvm)) | |
115 | (inputs | |
116 | `(("llvm" ,llvm))) | |
117 | (arguments | |
118 | `(;; Don't use '-g' during the build to save space. | |
3b956a33 EB |
119 | #:build-type "Release" |
120 | #:tests? #f)) ; Tests require gtest | |
ac97dce1 | 121 | (home-page "https://compiler-rt.llvm.org") |
b81f5693 AW |
122 | (synopsis "Runtime library for Clang/LLVM") |
123 | (description | |
124 | "The \"clang-runtime\" library provides the implementations of run-time | |
125 | functions for C and C++ programs. It also provides header files that allow C | |
126 | and C++ source code to interface with the \"sanitization\" passes of the clang | |
127 | compiler. In LLVM this library is called \"compiler-rt\".") | |
ac00973c | 128 | (license license:ncsa) |
9e6b9ea4 | 129 | |
ac97dce1 | 130 | ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported. |
9e6b9ea4 | 131 | (supported-systems (delete "mips64el-linux" %supported-systems)))) |
b81f5693 | 132 | |
3b956a33 EB |
133 | (define* (clang-from-llvm llvm clang-runtime hash |
134 | #:key (patches '("clang-libc-search-path.patch"))) | |
3e4249ce EB |
135 | (package |
136 | (name "clang") | |
137 | (version (package-version llvm)) | |
138 | (source | |
139 | (origin | |
140 | (method url-fetch) | |
141 | (uri (string-append "http://llvm.org/releases/" | |
142 | version "/cfe-" version ".src.tar.xz")) | |
fd6ae1b9 | 143 | (sha256 (base32 hash)) |
3b956a33 | 144 | (patches (map search-patch patches)))) |
3e4249ce EB |
145 | ;; Using cmake allows us to treat llvm as an external library. There |
146 | ;; doesn't seem to be any way to do this with clang's autotools-based | |
147 | ;; build system. | |
148 | (build-system cmake-build-system) | |
149 | (native-inputs (package-native-inputs llvm)) | |
150 | (inputs | |
151 | `(("libxml2" ,libxml2) | |
c92f1c0a | 152 | ("gcc-lib" ,gcc "lib") |
3e4249ce EB |
153 | ,@(package-inputs llvm))) |
154 | (propagated-inputs | |
b81f5693 AW |
155 | `(("llvm" ,llvm) |
156 | ("clang-runtime" ,clang-runtime))) | |
fd6ae1b9 LC |
157 | (arguments |
158 | `(#:configure-flags | |
159 | (list "-DCLANG_INCLUDE_TESTS=True" | |
160 | ||
161 | ;; Find libgcc_s, crtbegin.o, and crtend.o. | |
162 | (string-append "-DGCC_INSTALL_PREFIX=" | |
163 | (assoc-ref %build-inputs "gcc-lib")) | |
164 | ||
165 | ;; Use a sane default include directory. | |
166 | (string-append "-DC_INCLUDE_DIRS=" | |
167 | (assoc-ref %build-inputs "libc") | |
168 | "/include")) | |
169 | ||
94585e88 LC |
170 | ;; Don't use '-g' during the build to save space. |
171 | #:build-type "Release" | |
172 | ||
fd6ae1b9 LC |
173 | #:phases (modify-phases %standard-phases |
174 | (add-after | |
175 | 'unpack 'set-glibc-file-names | |
176 | (lambda* (#:key inputs #:allow-other-keys) | |
b81f5693 AW |
177 | (let ((libc (assoc-ref inputs "libc")) |
178 | (compiler-rt (assoc-ref inputs "clang-runtime"))) | |
fd6ae1b9 | 179 | (substitute* "lib/Driver/Tools.cpp" |
b81f5693 AW |
180 | ;; Patch the 'getLinuxDynamicLinker' function to that |
181 | ;; it uses the right dynamic linker file name. | |
fd6ae1b9 LC |
182 | (("/lib64/ld-linux-x86-64.so.2") |
183 | (string-append libc | |
b81f5693 AW |
184 | ,(glibc-dynamic-linker))) |
185 | ||
186 | ;; Link to libclang_rt files from clang-runtime. | |
187 | (("TC\\.getDriver\\(\\)\\.ResourceDir") | |
188 | (string-append "\"" compiler-rt "\""))) | |
fd6ae1b9 LC |
189 | |
190 | ;; Same for libc's libdir, to allow crt1.o & co. to be | |
191 | ;; found. | |
192 | (substitute* "lib/Driver/ToolChains.cpp" | |
193 | (("@GLIBC_LIBDIR@") | |
13f5a0dc MW |
194 | (string-append libc "/lib"))) |
195 | ||
196 | #t)))))) | |
ef11ac87 LC |
197 | |
198 | ;; Clang supports the same environment variables as GCC. | |
199 | (native-search-paths | |
200 | (list (search-path-specification | |
201 | (variable "CPATH") | |
202 | (files '("include"))) | |
203 | (search-path-specification | |
204 | (variable "LIBRARY_PATH") | |
205 | (files '("lib" "lib64"))))) | |
206 | ||
ac97dce1 | 207 | (home-page "https://clang.llvm.org") |
3e4249ce EB |
208 | (synopsis "C language family frontend for LLVM") |
209 | (description | |
210 | "Clang is a compiler front end for the C, C++, Objective-C and | |
211 | Objective-C++ programming languages. It uses LLVM as its back end. The Clang | |
212 | project includes the Clang front end, the Clang static analyzer, and several | |
213 | code analysis tools.") | |
ac00973c | 214 | (license license:ncsa))) |
1204c510 | 215 | |
b81f5693 AW |
216 | (define-public clang-runtime |
217 | (clang-runtime-from-llvm | |
218 | llvm | |
6b26f915 LC |
219 | "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d" |
220 | '("clang-runtime-asan-build-fixes.patch"))) | |
b81f5693 | 221 | |
1204c510 | 222 | (define-public clang |
b81f5693 | 223 | (clang-from-llvm llvm clang-runtime |
3b956a33 EB |
224 | "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc" |
225 | #:patches '("clang-3.8-libc-search-path.patch"))) | |
226 | ||
584da12d RJ |
227 | (define-public llvm-3.9.1 |
228 | (package (inherit llvm) | |
229 | (name "llvm") | |
230 | (version "3.9.1") | |
231 | (source | |
232 | (origin | |
233 | (method url-fetch) | |
234 | (uri (string-append "http://llvm.org/releases/" | |
235 | version "/llvm-" version ".src.tar.xz")) | |
236 | (sha256 | |
237 | (base32 | |
238 | "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z")))))) | |
239 | ||
240 | (define-public clang-runtime-3.9.1 | |
241 | (clang-runtime-from-llvm | |
242 | llvm-3.9.1 | |
6b26f915 LC |
243 | "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk" |
244 | '("clang-runtime-asan-build-fixes.patch" | |
245 | "clang-runtime-esan-build-fixes.patch"))) | |
584da12d RJ |
246 | |
247 | (define-public clang-3.9.1 | |
248 | (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1 | |
249 | "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76" | |
250 | #:patches '())) | |
251 | ||
3b956a33 EB |
252 | (define-public llvm-3.7 |
253 | (package (inherit llvm) | |
254 | (version "3.7.1") | |
255 | (source | |
256 | (origin | |
257 | (method url-fetch) | |
258 | (uri (string-append "http://llvm.org/releases/" | |
259 | version "/llvm-" version ".src.tar.xz")) | |
260 | (sha256 | |
261 | (base32 | |
262 | "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy")))))) | |
263 | ||
264 | (define-public clang-runtime-3.7 | |
265 | (clang-runtime-from-llvm | |
266 | llvm-3.7 | |
6b26f915 LC |
267 | "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx" |
268 | '("clang-runtime-asan-build-fixes.patch"))) | |
3b956a33 EB |
269 | |
270 | (define-public clang-3.7 | |
271 | (clang-from-llvm llvm-3.7 clang-runtime-3.7 | |
3ebc0905 EB |
272 | "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn")) |
273 | ||
274 | (define-public llvm-3.6 | |
275 | (package (inherit llvm) | |
276 | (version "3.6.2") | |
277 | (source | |
278 | (origin | |
279 | (method url-fetch) | |
280 | (uri (string-append "http://llvm.org/releases/" | |
281 | version "/llvm-" version ".src.tar.xz")) | |
282 | (sha256 | |
283 | (base32 | |
284 | "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn")))))) | |
285 | ||
286 | (define-public clang-runtime-3.6 | |
287 | (clang-runtime-from-llvm | |
288 | llvm-3.6 | |
6b26f915 LC |
289 | "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg" |
290 | '("clang-runtime-asan-build-fixes.patch"))) | |
3ebc0905 EB |
291 | |
292 | (define-public clang-3.6 | |
293 | (clang-from-llvm llvm-3.6 clang-runtime-3.6 | |
be23021d | 294 | "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df")) |
1204c510 MW |
295 | |
296 | (define-public llvm-3.5 | |
297 | (package (inherit llvm) | |
a53c486d | 298 | (version "3.5.2") |
1204c510 MW |
299 | (source |
300 | (origin | |
301 | (method url-fetch) | |
302 | (uri (string-append "http://llvm.org/releases/" | |
303 | version "/llvm-" version ".src.tar.xz")) | |
6ba4eca2 RW |
304 | (patches |
305 | (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch")) | |
1204c510 MW |
306 | (sha256 |
307 | (base32 | |
a53c486d | 308 | "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4")))))) |
1204c510 | 309 | |
b81f5693 AW |
310 | (define-public clang-runtime-3.5 |
311 | (clang-runtime-from-llvm | |
312 | llvm-3.5 | |
6b26f915 LC |
313 | "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal" |
314 | '("clang-runtime-asan-build-fixes.patch"))) | |
b81f5693 | 315 | |
1204c510 | 316 | (define-public clang-3.5 |
b81f5693 | 317 | (clang-from-llvm llvm-3.5 clang-runtime-3.5 |
a53c486d | 318 | "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg")) |
921cb13a RW |
319 | |
320 | (define-public llvm-for-extempore | |
321 | (package (inherit llvm-3.7) | |
7355634d | 322 | (name "llvm-for-extempore") |
921cb13a RW |
323 | (source |
324 | (origin | |
325 | (inherit (package-source llvm-3.7)) | |
39162ee4 RW |
326 | (patches (list (search-patch "llvm-for-extempore.patch"))))) |
327 | ;; Extempore refuses to build on architectures other than x86_64 | |
328 | (supported-systems '("x86_64-linux")))) |