gnu: go-github-com-gogo-protobuf: Update to 0.5-1.35b81a0.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014, 2016 Eric Bavier <bavier@member.fsf.org>
3 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2017 Ludovic Courtès <ludo@gnu.org>
5 ;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
6 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
7 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
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)
26 #:use-module ((guix licenses) #:prefix license:)
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)
32 #:use-module (gnu packages gcc)
33 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages libffi)
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")
43 (version "3.8.1")
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
51 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))
52 (build-system cmake-build-system)
53 (native-inputs
54 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
55 ("perl" ,perl)))
56 (inputs
57 `(("libffi" ,libffi)))
58 (propagated-inputs
59 `(("zlib" ,zlib))) ;to use output from llvm-config
60 (arguments
61 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
62 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
63 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
64 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
65 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
66
67 ;; Don't use '-g' during the build, to save space.
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)))))
79 (home-page "https://www.llvm.org")
80 (synopsis "Optimizing compiler infrastructure")
81 (description
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.")
88 (license license:ncsa)))
89
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
101 (define (clang-runtime-from-llvm llvm hash)
102 (package
103 (name "clang-runtime")
104 (version (package-version llvm))
105 (source
106 (origin
107 (method url-fetch)
108 (uri (string-append "http://llvm.org/releases/"
109 version "/compiler-rt-" version ".src.tar.xz"))
110 (sha256 (base32 hash))))
111 (build-system cmake-build-system)
112 (native-inputs (package-native-inputs llvm))
113 (inputs
114 `(("llvm" ,llvm)))
115 (arguments
116 `(;; Don't use '-g' during the build to save space.
117 #:build-type "Release"
118 #:tests? #f)) ; Tests require gtest
119 (home-page "https://compiler-rt.llvm.org")
120 (synopsis "Runtime library for Clang/LLVM")
121 (description
122 "The \"clang-runtime\" library provides the implementations of run-time
123 functions for C and C++ programs. It also provides header files that allow C
124 and C++ source code to interface with the \"sanitization\" passes of the clang
125 compiler. In LLVM this library is called \"compiler-rt\".")
126 (license license:ncsa)
127
128 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
129 (supported-systems (delete "mips64el-linux" %supported-systems))))
130
131 (define* (clang-from-llvm llvm clang-runtime hash
132 #:key (patches '("clang-libc-search-path.patch")))
133 (package
134 (name "clang")
135 (version (package-version llvm))
136 (source
137 (origin
138 (method url-fetch)
139 (uri (string-append "http://llvm.org/releases/"
140 version "/cfe-" version ".src.tar.xz"))
141 (sha256 (base32 hash))
142 (patches (map search-patch patches))))
143 ;; Using cmake allows us to treat llvm as an external library. There
144 ;; doesn't seem to be any way to do this with clang's autotools-based
145 ;; build system.
146 (build-system cmake-build-system)
147 (native-inputs (package-native-inputs llvm))
148 (inputs
149 `(("libxml2" ,libxml2)
150 ("gcc-lib" ,gcc "lib")
151 ,@(package-inputs llvm)))
152 (propagated-inputs
153 `(("llvm" ,llvm)
154 ("clang-runtime" ,clang-runtime)))
155 (arguments
156 `(#:configure-flags
157 (list "-DCLANG_INCLUDE_TESTS=True"
158
159 ;; Find libgcc_s, crtbegin.o, and crtend.o.
160 (string-append "-DGCC_INSTALL_PREFIX="
161 (assoc-ref %build-inputs "gcc-lib"))
162
163 ;; Use a sane default include directory.
164 (string-append "-DC_INCLUDE_DIRS="
165 (assoc-ref %build-inputs "libc")
166 "/include"))
167
168 ;; Don't use '-g' during the build to save space.
169 #:build-type "Release"
170
171 #:phases (modify-phases %standard-phases
172 (add-after
173 'unpack 'set-glibc-file-names
174 (lambda* (#:key inputs #:allow-other-keys)
175 (let ((libc (assoc-ref inputs "libc"))
176 (compiler-rt (assoc-ref inputs "clang-runtime")))
177 (substitute* "lib/Driver/Tools.cpp"
178 ;; Patch the 'getLinuxDynamicLinker' function to that
179 ;; it uses the right dynamic linker file name.
180 (("/lib64/ld-linux-x86-64.so.2")
181 (string-append libc
182 ,(glibc-dynamic-linker)))
183
184 ;; Link to libclang_rt files from clang-runtime.
185 (("TC\\.getDriver\\(\\)\\.ResourceDir")
186 (string-append "\"" compiler-rt "\"")))
187
188 ;; Same for libc's libdir, to allow crt1.o & co. to be
189 ;; found.
190 (substitute* "lib/Driver/ToolChains.cpp"
191 (("@GLIBC_LIBDIR@")
192 (string-append libc "/lib")))))))))
193
194 ;; Clang supports the same environment variables as GCC.
195 (native-search-paths
196 (list (search-path-specification
197 (variable "CPATH")
198 (files '("include")))
199 (search-path-specification
200 (variable "LIBRARY_PATH")
201 (files '("lib" "lib64")))))
202
203 (home-page "https://clang.llvm.org")
204 (synopsis "C language family frontend for LLVM")
205 (description
206 "Clang is a compiler front end for the C, C++, Objective-C and
207 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
208 project includes the Clang front end, the Clang static analyzer, and several
209 code analysis tools.")
210 (license license:ncsa)))
211
212 (define-public clang-runtime
213 (clang-runtime-from-llvm
214 llvm
215 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"))
216
217 (define-public clang
218 (clang-from-llvm llvm clang-runtime
219 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
220 #:patches '("clang-3.8-libc-search-path.patch")))
221
222 (define-public llvm-3.9.1
223 (package (inherit llvm)
224 (name "llvm")
225 (version "3.9.1")
226 (source
227 (origin
228 (method url-fetch)
229 (uri (string-append "http://llvm.org/releases/"
230 version "/llvm-" version ".src.tar.xz"))
231 (sha256
232 (base32
233 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
234
235 (define-public clang-runtime-3.9.1
236 (clang-runtime-from-llvm
237 llvm-3.9.1
238 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"))
239
240 (define-public clang-3.9.1
241 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
242 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
243 #:patches '()))
244
245 (define-public llvm-3.7
246 (package (inherit llvm)
247 (version "3.7.1")
248 (source
249 (origin
250 (method url-fetch)
251 (uri (string-append "http://llvm.org/releases/"
252 version "/llvm-" version ".src.tar.xz"))
253 (sha256
254 (base32
255 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
256
257 (define-public clang-runtime-3.7
258 (clang-runtime-from-llvm
259 llvm-3.7
260 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"))
261
262 (define-public clang-3.7
263 (clang-from-llvm llvm-3.7 clang-runtime-3.7
264 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"))
265
266 (define-public llvm-3.6
267 (package (inherit llvm)
268 (version "3.6.2")
269 (source
270 (origin
271 (method url-fetch)
272 (uri (string-append "http://llvm.org/releases/"
273 version "/llvm-" version ".src.tar.xz"))
274 (sha256
275 (base32
276 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
277
278 (define-public clang-runtime-3.6
279 (clang-runtime-from-llvm
280 llvm-3.6
281 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"))
282
283 (define-public clang-3.6
284 (clang-from-llvm llvm-3.6 clang-runtime-3.6
285 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"))
286
287 (define-public llvm-3.5
288 (package (inherit llvm)
289 (version "3.5.2")
290 (source
291 (origin
292 (method url-fetch)
293 (uri (string-append "http://llvm.org/releases/"
294 version "/llvm-" version ".src.tar.xz"))
295 (patches
296 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
297 (sha256
298 (base32
299 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
300
301 (define-public clang-runtime-3.5
302 (clang-runtime-from-llvm
303 llvm-3.5
304 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"))
305
306 (define-public clang-3.5
307 (clang-from-llvm llvm-3.5 clang-runtime-3.5
308 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"))
309
310 (define-public llvm-for-extempore
311 (package (inherit llvm-3.7)
312 (name "llvm-for-extempore")
313 (source
314 (origin
315 (inherit (package-source llvm-3.7))
316 (patches (list (search-patch "llvm-for-extempore.patch")))))
317 ;; Extempore refuses to build on architectures other than x86_64
318 (supported-systems '("x86_64-linux"))))