gnu: Add gom.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
CommitLineData
3e4249ce
EB
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 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>
3e4249ce
EB
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages llvm)
22 #:use-module (guix packages)
23 #:use-module (guix licenses)
24 #:use-module (guix download)
25 #:use-module (guix utils)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix build-system cmake)
28 #:use-module (gnu packages)
fd6ae1b9
LC
29 #:use-module (gnu packages gcc)
30 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
3e4249ce
EB
31 #:use-module (gnu packages perl)
32 #:use-module (gnu packages python)
33 #:use-module (gnu packages xml))
34
35(define-public llvm
36 (package
37 (name "llvm")
1204c510 38 (version "3.6.0")
3e4249ce
EB
39 (source
40 (origin
41 (method url-fetch)
42 (uri (string-append "http://llvm.org/releases/"
43 version "/llvm-" version ".src.tar.xz"))
44 (sha256
45 (base32
1204c510 46 "1kmr5vlnz1419nnvyc7lsrcfx09n65ravjbmzxrqz7ml07jnk6mk"))))
3e4249ce
EB
47 (build-system cmake-build-system)
48 (native-inputs
49 `(("python" ,python-wrapper)
50 ("perl" ,perl)))
51 (arguments
52 `(#:phases (alist-cons-before
53 'build 'link-lib-for-build-exec
54 (lambda* (#:key outputs #:allow-other-keys)
55 ;; This is a hacky fix that will allow binaries to run
56 ;; before being installed. -DCMAKE_SKIP_BUILD_RPATH=FALSE
57 ;; seems to not help. Nixpkgs does the same.
58 (let* ((out (assoc-ref outputs "out"))
59 (out-lib (string-append out "/lib"))
60 (build-lib (string-append (getcwd) "/lib")))
61 (mkdir-p out)
62 (symlink build-lib out-lib)))
63 (alist-cons-after
64 'build 'cleanup-out
65 (lambda* (#:key outputs #:allow-other-keys)
66 ;; Cleanup the symlink that was created previously. Let
67 ;; the install phase repopulate out.
68 (delete-file-recursively (assoc-ref outputs "out")))
69 %standard-phases))))
70 (home-page "http://www.llvm.org")
71 (synopsis "Optimizing compiler infrastructure")
72 (description
73 "LLVM is a compiler infrastructure designed for compile-time, link-time, runtime,
74and idle-time optimization of programs from arbitrary programming languages.
75It currently supports compilation of C and C++ programs, using front-ends
76derived from GCC 4.0.1. A new front-end for the C family of languages is in
77development. The compiler infrastructure includes mirror sets of programming
78tools as well as libraries with equivalent functionality.")
79 (license ncsa)))
80
1204c510 81(define (clang-from-llvm llvm hash)
3e4249ce
EB
82 (package
83 (name "clang")
84 (version (package-version llvm))
85 (source
86 (origin
87 (method url-fetch)
88 (uri (string-append "http://llvm.org/releases/"
89 version "/cfe-" version ".src.tar.xz"))
fd6ae1b9
LC
90 (sha256 (base32 hash))
91 (patches (list (search-patch "clang-libc-search-path.patch")))))
3e4249ce
EB
92 ;; Using cmake allows us to treat llvm as an external library. There
93 ;; doesn't seem to be any way to do this with clang's autotools-based
94 ;; build system.
95 (build-system cmake-build-system)
96 (native-inputs (package-native-inputs llvm))
97 (inputs
98 `(("libxml2" ,libxml2)
fd6ae1b9 99 ("gcc-lib" ,gcc-4.9 "lib")
3e4249ce
EB
100 ,@(package-inputs llvm)))
101 (propagated-inputs
102 `(("llvm" ,llvm)))
fd6ae1b9
LC
103 (arguments
104 `(#:configure-flags
105 (list "-DCLANG_INCLUDE_TESTS=True"
106
107 ;; Find libgcc_s, crtbegin.o, and crtend.o.
108 (string-append "-DGCC_INSTALL_PREFIX="
109 (assoc-ref %build-inputs "gcc-lib"))
110
111 ;; Use a sane default include directory.
112 (string-append "-DC_INCLUDE_DIRS="
113 (assoc-ref %build-inputs "libc")
114 "/include"))
115
94585e88
LC
116 ;; Don't use '-g' during the build to save space.
117 #:build-type "Release"
118
fd6ae1b9
LC
119 #:phases (modify-phases %standard-phases
120 (add-after
121 'unpack 'set-glibc-file-names
122 (lambda* (#:key inputs #:allow-other-keys)
123 (let ((libc (assoc-ref inputs "libc")))
124 ;; Patch the 'getLinuxDynamicLinker' function to that
125 ;; it uses the right dynamic linker file name.
126 (substitute* "lib/Driver/Tools.cpp"
127 (("/lib64/ld-linux-x86-64.so.2")
128 (string-append libc
129 ,(glibc-dynamic-linker))))
130
131 ;; Same for libc's libdir, to allow crt1.o & co. to be
132 ;; found.
133 (substitute* "lib/Driver/ToolChains.cpp"
134 (("@GLIBC_LIBDIR@")
135 (string-append libc "/lib")))))))))
ef11ac87
LC
136
137 ;; Clang supports the same environment variables as GCC.
138 (native-search-paths
139 (list (search-path-specification
140 (variable "CPATH")
141 (files '("include")))
142 (search-path-specification
143 (variable "LIBRARY_PATH")
144 (files '("lib" "lib64")))))
145
3e4249ce
EB
146 (home-page "http://clang.llvm.org")
147 (synopsis "C language family frontend for LLVM")
148 (description
149 "Clang is a compiler front end for the C, C++, Objective-C and
150Objective-C++ programming languages. It uses LLVM as its back end. The Clang
151project includes the Clang front end, the Clang static analyzer, and several
152code analysis tools.")
153 (license ncsa)))
1204c510
MW
154
155(define-public clang
156 (clang-from-llvm llvm
157 "0b8825mvdhfk5r9gwcwp1j2dl9kw5glgyk7pybq2dzhrh4vnj3my"))
158
159(define-public llvm-3.5
160 (package (inherit llvm)
161 (version "3.5.0")
162 (source
163 (origin
164 (method url-fetch)
165 (uri (string-append "http://llvm.org/releases/"
166 version "/llvm-" version ".src.tar.xz"))
167 (sha256
168 (base32
169 "00swb43mzlvda8306arlg2jw7g6k3acwfccgf1k4c2pgd3rrkq98"))))))
170
171(define-public clang-3.5
172 (clang-from-llvm llvm-3.5
173 "12yv3jwdjcbkrx7zjm8wh4jrvb59v8fdw4mnmz3zc1jb00p9k07w"))