1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
3 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
6 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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)
29 #:use-module (gnu packages gcc)
30 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
31 #:use-module (gnu packages perl)
32 #:use-module (gnu packages python)
33 #:use-module (gnu packages xml))
42 (uri (string-append "http://llvm.org/releases/"
43 version "/llvm-" version ".src.tar.xz"))
46 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))
47 (build-system cmake-build-system)
49 `(("python" ,python-wrapper)
52 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
53 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE")))
54 (home-page "http://www.llvm.org")
55 (synopsis "Optimizing compiler infrastructure")
57 "LLVM is a compiler infrastructure designed for compile-time, link-time,
58 runtime, and idle-time optimization of programs from arbitrary programming
59 languages. It currently supports compilation of C and C++ programs, using
60 front-ends derived from GCC 4.0.1. A new front-end for the C family of
61 languages is in development. The compiler infrastructure includes mirror sets
62 of programming tools as well as libraries with equivalent functionality.")
65 (define (clang-runtime-from-llvm llvm hash)
67 (name "clang-runtime")
68 (version (package-version llvm))
72 (uri (string-append "http://llvm.org/releases/"
73 version "/compiler-rt-" version ".src.tar.xz"))
74 (sha256 (base32 hash))))
75 (build-system cmake-build-system)
76 (native-inputs (package-native-inputs llvm))
80 `(;; Don't use '-g' during the build to save space.
81 #:build-type "Release"))
83 (home-page "http://compiler-rt.llvm.org")
84 (synopsis "Runtime library for Clang/LLVM")
86 "The \"clang-runtime\" library provides the implementations of run-time
87 functions for C and C++ programs. It also provides header files that allow C
88 and C++ source code to interface with the \"sanitization\" passes of the clang
89 compiler. In LLVM this library is called \"compiler-rt\".")
92 ;; <http://compiler-rt.llvm.org/> doesn't list MIPS as supported.
93 (supported-systems (delete "mips64el-linux" %supported-systems))))
95 (define (clang-from-llvm llvm clang-runtime hash)
98 (version (package-version llvm))
102 (uri (string-append "http://llvm.org/releases/"
103 version "/cfe-" version ".src.tar.xz"))
104 (sha256 (base32 hash))
105 (patches (list (search-patch "clang-libc-search-path.patch")))))
106 ;; Using cmake allows us to treat llvm as an external library. There
107 ;; doesn't seem to be any way to do this with clang's autotools-based
109 (build-system cmake-build-system)
110 (native-inputs (package-native-inputs llvm))
112 `(("libxml2" ,libxml2)
113 ("gcc-lib" ,gcc "lib")
114 ,@(package-inputs llvm)))
117 ("clang-runtime" ,clang-runtime)))
120 (list "-DCLANG_INCLUDE_TESTS=True"
122 ;; Find libgcc_s, crtbegin.o, and crtend.o.
123 (string-append "-DGCC_INSTALL_PREFIX="
124 (assoc-ref %build-inputs "gcc-lib"))
126 ;; Use a sane default include directory.
127 (string-append "-DC_INCLUDE_DIRS="
128 (assoc-ref %build-inputs "libc")
131 ;; Don't use '-g' during the build to save space.
132 #:build-type "Release"
134 #:phases (modify-phases %standard-phases
136 'unpack 'set-glibc-file-names
137 (lambda* (#:key inputs #:allow-other-keys)
138 (let ((libc (assoc-ref inputs "libc"))
139 (compiler-rt (assoc-ref inputs "clang-runtime")))
140 (substitute* "lib/Driver/Tools.cpp"
141 ;; Patch the 'getLinuxDynamicLinker' function to that
142 ;; it uses the right dynamic linker file name.
143 (("/lib64/ld-linux-x86-64.so.2")
145 ,(glibc-dynamic-linker)))
147 ;; Link to libclang_rt files from clang-runtime.
148 (("TC\\.getDriver\\(\\)\\.ResourceDir")
149 (string-append "\"" compiler-rt "\"")))
151 ;; Same for libc's libdir, to allow crt1.o & co. to be
153 (substitute* "lib/Driver/ToolChains.cpp"
155 (string-append libc "/lib")))))))))
157 ;; Clang supports the same environment variables as GCC.
159 (list (search-path-specification
161 (files '("include")))
162 (search-path-specification
163 (variable "LIBRARY_PATH")
164 (files '("lib" "lib64")))))
166 (home-page "http://clang.llvm.org")
167 (synopsis "C language family frontend for LLVM")
169 "Clang is a compiler front end for the C, C++, Objective-C and
170 Objective-C++ programming languages. It uses LLVM as its back end. The Clang
171 project includes the Clang front end, the Clang static analyzer, and several
172 code analysis tools.")
175 (define-public clang-runtime
176 (clang-runtime-from-llvm
178 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"))
181 (clang-from-llvm llvm clang-runtime
182 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"))
184 (define-public llvm-3.5
185 (package (inherit llvm)
190 (uri (string-append "http://llvm.org/releases/"
191 version "/llvm-" version ".src.tar.xz"))
194 "00swb43mzlvda8306arlg2jw7g6k3acwfccgf1k4c2pgd3rrkq98"))))))
196 (define-public clang-runtime-3.5
197 (clang-runtime-from-llvm
199 "0dl1kbrhz96djsxqr61iw5h788s7ncfpfb7aayixky1bhdaydcx4"))
201 (define-public clang-3.5
202 (clang-from-llvm llvm-3.5 clang-runtime-3.5
203 "12yv3jwdjcbkrx7zjm8wh4jrvb59v8fdw4mnmz3zc1jb00p9k07w"))