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