gnu: hidapi: Fix 'license'.
[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 Ludovic Courtès <ludo@gnu.org>
5 ;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
6 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
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)
25 #:use-module ((guix licenses) #:prefix license:)
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)
31 #:use-module (gnu packages gcc)
32 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages libffi)
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")
42 (version "3.8.1")
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
50 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))
51 (build-system cmake-build-system)
52 (native-inputs
53 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
54 ("perl" ,perl)))
55 (inputs
56 `(("libffi" ,libffi)))
57 (propagated-inputs
58 `(("zlib" ,zlib))) ;to use output from llvm-config
59 (arguments
60 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
61 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
62 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
63 "-DLLVM_ENABLE_FFI:BOOL=TRUE")
64
65 ;; Don't use '-g' during the build, to save space.
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)))))
77 (home-page "http://www.llvm.org")
78 (synopsis "Optimizing compiler infrastructure")
79 (description
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.")
86 (license license:ncsa)))
87
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
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.
115 #:build-type "Release"
116 #:tests? #f)) ; Tests require gtest
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\".")
124 (license license:ncsa)
125
126 ;; <http://compiler-rt.llvm.org/> doesn't list MIPS as supported.
127 (supported-systems (delete "mips64el-linux" %supported-systems))))
128
129 (define* (clang-from-llvm llvm clang-runtime hash
130 #:key (patches '("clang-libc-search-path.patch")))
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"))
139 (sha256 (base32 hash))
140 (patches (map search-patch patches))))
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)
148 ("gcc-lib" ,gcc "lib")
149 ,@(package-inputs llvm)))
150 (propagated-inputs
151 `(("llvm" ,llvm)
152 ("clang-runtime" ,clang-runtime)))
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
166 ;; Don't use '-g' during the build to save space.
167 #:build-type "Release"
168
169 #:phases (modify-phases %standard-phases
170 (add-after
171 'unpack 'set-glibc-file-names
172 (lambda* (#:key inputs #:allow-other-keys)
173 (let ((libc (assoc-ref inputs "libc"))
174 (compiler-rt (assoc-ref inputs "clang-runtime")))
175 (substitute* "lib/Driver/Tools.cpp"
176 ;; Patch the 'getLinuxDynamicLinker' function to that
177 ;; it uses the right dynamic linker file name.
178 (("/lib64/ld-linux-x86-64.so.2")
179 (string-append libc
180 ,(glibc-dynamic-linker)))
181
182 ;; Link to libclang_rt files from clang-runtime.
183 (("TC\\.getDriver\\(\\)\\.ResourceDir")
184 (string-append "\"" compiler-rt "\"")))
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")))))))))
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
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.")
208 (license license:ncsa)))
209
210 (define-public clang-runtime
211 (clang-runtime-from-llvm
212 llvm
213 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"))
214
215 (define-public clang
216 (clang-from-llvm llvm clang-runtime
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
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
260 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"))
261
262 (define-public llvm-3.5
263 (package (inherit llvm)
264 (version "3.5.2")
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
272 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
273
274 (define-public clang-runtime-3.5
275 (clang-runtime-from-llvm
276 llvm-3.5
277 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"))
278
279 (define-public clang-3.5
280 (clang-from-llvm llvm-3.5 clang-runtime-3.5
281 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"))
282
283 (define-public llvm-for-extempore
284 (package (inherit llvm-3.7)
285 (source
286 (origin
287 (inherit (package-source llvm-3.7))
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"))))