Commit | Line | Data |
---|---|---|
e9c0b944 LC |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
7 | ;;; under the terms of the GNU General Public License as published by | |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | (define-module (gnu packages gcc) | |
c6d7e299 LC |
20 | #:use-module ((guix licenses) |
21 | #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+)) | |
e9c0b944 LC |
22 | #:use-module (gnu packages) |
23 | #:use-module (gnu packages bootstrap) | |
24 | #:use-module (gnu packages compression) | |
25 | #:use-module (gnu packages multiprecision) | |
c8ebc821 | 26 | #:use-module (gnu packages texinfo) |
e9c0b944 LC |
27 | #:use-module (guix packages) |
28 | #:use-module (guix download) | |
ca16cb96 LC |
29 | #:use-module (guix build-system gnu) |
30 | #:use-module (ice-9 regex)) | |
e9c0b944 | 31 | |
832abc76 LC |
32 | (define %gcc-infrastructure |
33 | ;; Base URL for GCC's infrastructure. | |
34 | "ftp://gcc.gnu.org/pub/gcc/infrastructure/") | |
35 | ||
ca16cb96 LC |
36 | (define-public (gcc-configure-flags-for-triplet target) |
37 | "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet. | |
38 | ||
39 | The purpose of this procedure is to translate extended GNU triplets---e.g., | |
40 | where the OS part is overloaded to denote a specific ABI---into GCC | |
41 | `configure' options. We take extended GNU triplets that glibc recognizes." | |
42 | (cond ((string-match "^mips64el.*gnuabin?64$" target) | |
43 | ;; Triplets recognized by glibc as denoting the N64 ABI; see | |
44 | ;; ports/sysdeps/mips/preconfigure. | |
45 | '("--with-abi=64")) | |
46 | (else | |
47 | ;; TODO: Add `armel.*gnueabi', `hf', etc. | |
48 | '()))) | |
49 | ||
e9c0b944 | 50 | (define-public gcc-4.7 |
de1d41f9 LC |
51 | (let* ((stripped? #t) ; TODO: make this a parameter |
52 | (maybe-target-tools | |
53 | (lambda () | |
54 | ;; Return the `_FOR_TARGET' variables that are needed when | |
55 | ;; cross-compiling GCC. | |
56 | (let ((target (%current-target-system))) | |
57 | (if target | |
58 | (map (lambda (var tool) | |
59 | (string-append (string-append var "_FOR_TARGET") | |
60 | "=" target "-" tool)) | |
61 | '("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP") | |
62 | '("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip")) | |
63 | '())))) | |
64 | (configure-flags | |
65 | (lambda () | |
66 | ;; This is terrible. Since we have two levels of quasiquotation, | |
67 | ;; we have to do this convoluted thing just so we can insert the | |
68 | ;; contents of (maybe-target-tools). | |
69 | (list 'quasiquote | |
70 | (append | |
71 | '("--enable-plugin" | |
72 | "--enable-languages=c,c++" | |
73 | "--disable-multilib" | |
74 | ||
75 | "--with-local-prefix=/no-gcc-local-prefix" | |
76 | ||
77 | ,(let ((libc (assoc-ref %build-inputs "libc"))) | |
78 | (if libc | |
79 | (string-append "--with-native-system-header-dir=" libc | |
80 | "/include") | |
81 | "--without-headers"))) | |
82 | ||
ca16cb96 LC |
83 | ;; When cross-compiling GCC, pass the right options for the |
84 | ;; target triplet. | |
85 | (or (and=> (%current-target-system) | |
86 | gcc-configure-flags-for-triplet) | |
87 | '()) | |
88 | ||
de1d41f9 | 89 | (maybe-target-tools)))))) |
e9c0b944 | 90 | (package |
de1d41f9 LC |
91 | (name "gcc") |
92 | (version "4.7.3") | |
93 | (source (origin | |
94 | (method url-fetch) | |
95 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
96 | version "/gcc-" version ".tar.bz2")) | |
97 | (sha256 | |
98 | (base32 | |
99 | "1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g")))) | |
100 | (build-system gnu-build-system) | |
101 | (inputs `(("gmp" ,gmp) | |
102 | ("mpfr" ,mpfr) | |
103 | ("mpc" ,mpc) | |
104 | ("isl" ,isl) | |
105 | ("cloog" ,cloog) | |
106 | ("libelf" ,libelf) | |
107 | ("zlib" ,zlib))) | |
c8ebc821 LC |
108 | |
109 | ;; GCC is one of the few packages that doesn't ship .info files. | |
110 | (native-inputs `(("texinfo" ,texinfo))) | |
111 | ||
de1d41f9 LC |
112 | (arguments |
113 | `(#:out-of-source? #t | |
114 | #:strip-binaries? ,stripped? | |
115 | #:configure-flags ,(configure-flags) | |
116 | #:make-flags | |
117 | (let ((libc (assoc-ref %build-inputs "libc"))) | |
118 | `(,@(if libc | |
119 | (list (string-append "LDFLAGS_FOR_TARGET=" | |
120 | "-B" libc "/lib " | |
121 | "-Wl,-dynamic-linker " | |
122 | "-Wl," libc | |
123 | ,(glibc-dynamic-linker))) | |
124 | '()) | |
125 | ,(string-append "BOOT_CFLAGS=-O2 " | |
126 | ,(if stripped? "-g0" "-g")))) | |
127 | ||
128 | #:tests? #f | |
129 | #:phases | |
130 | (alist-cons-before | |
131 | 'configure 'pre-configure | |
132 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
133 | (let ((out (assoc-ref outputs "out")) | |
134 | (libc (assoc-ref inputs "libc"))) | |
135 | (when libc | |
136 | ;; The following is not performed for `--without-headers' | |
137 | ;; cross-compiler builds. | |
138 | ||
139 | ;; Fix the dynamic linker's file name. | |
140 | (substitute* (find-files "gcc/config" | |
141 | "^linux(64|-elf)?\\.h$") | |
142 | (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix) | |
143 | (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%" | |
144 | suffix | |
145 | (string-append libc ,(glibc-dynamic-linker))))) | |
146 | ||
147 | ;; Tell where to find libstdc++, libc, and `?crt*.o', except | |
148 | ;; `crt{begin,end}.o', which come with GCC. | |
149 | (substitute* (find-files "gcc/config" | |
150 | "^(gnu-user(64)?|linux-elf)\\.h$") | |
151 | (("#define LIB_SPEC (.*)$" _ suffix) | |
152 | ;; Note that with this "lib" spec, we may still add a | |
153 | ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED. | |
154 | ;; There's not much that can be done to avoid it, though. | |
155 | (format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \ | |
4928e500 | 156 | %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a" |
de1d41f9 LC |
157 | libc libc out out suffix)) |
158 | (("#define STARTFILE_SPEC.*$" line) | |
159 | (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\" | |
e9c0b944 LC |
160 | #define STANDARD_STARTFILE_PREFIX_2 \"\" |
161 | ~a~%" | |
de1d41f9 LC |
162 | libc line)))) |
163 | ||
164 | ;; Don't retain a dependency on the build-time sed. | |
165 | (substitute* "fixincludes/fixincl.x" | |
166 | (("static char const sed_cmd_z\\[\\] =.*;") | |
167 | "static char const sed_cmd_z[] = \"sed\";")))) | |
168 | ||
169 | (alist-cons-after | |
170 | 'configure 'post-configure | |
171 | (lambda _ | |
172 | ;; Don't store configure flags, to avoid retaining references to | |
173 | ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'. | |
174 | (substitute* "Makefile" | |
175 | (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest) | |
176 | "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))) | |
177 | (alist-replace 'install | |
178 | (lambda* (#:key outputs #:allow-other-keys) | |
179 | (zero? | |
180 | (system* "make" | |
181 | ,(if stripped? | |
182 | "install-strip" | |
183 | "install")))) | |
184 | %standard-phases))))) | |
185 | ||
186 | (native-search-paths | |
187 | (list (search-path-specification | |
188 | (variable "CPATH") | |
189 | (directories '("include"))) | |
190 | (search-path-specification | |
191 | (variable "LIBRARY_PATH") | |
192 | (directories '("lib" "lib64"))))) | |
193 | ||
194 | (properties `((gcc-libc . ,(assoc-ref inputs "libc")))) | |
195 | (synopsis "GNU Compiler Collection") | |
196 | (description | |
197 | "The GNU Compiler Collection includes compiler front ends for C, C++, | |
e9c0b944 LC |
198 | Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as |
199 | libraries for these languages (libstdc++, libgcj, libgomp,...). | |
200 | ||
201 | GCC development is a part of the GNU Project, aiming to improve the compiler | |
202 | used in the GNU system including the GNU/Linux variant.") | |
de1d41f9 LC |
203 | (license gpl3+) |
204 | (home-page "http://gcc.gnu.org/")))) | |
832abc76 | 205 | |
3b401612 | 206 | (define-public gcc-4.8 |
3b401612 | 207 | (package (inherit gcc-4.7) |
2c034e1b | 208 | (version "4.8.1") |
3b401612 LC |
209 | (source (origin |
210 | (method url-fetch) | |
211 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
212 | version "/gcc-" version ".tar.bz2")) | |
213 | (sha256 | |
214 | (base32 | |
2c034e1b | 215 | "04sqn0ds17ys8l6zn7vyyvjz1a7hsk4zb0381vlw9wnr7az48nsl")))))) |
3b401612 | 216 | |
832abc76 LC |
217 | (define-public isl |
218 | (package | |
219 | (name "isl") | |
220 | (version "0.11.1") | |
221 | (source (origin | |
222 | (method url-fetch) | |
223 | (uri (list (string-append | |
224 | "ftp://ftp.linux.student.kuleuven.be/pub/people/skimo/isl/isl-" | |
225 | version | |
226 | ".tar.bz2") | |
227 | (string-append %gcc-infrastructure | |
228 | name "-" version ".tar.gz"))) | |
229 | (sha256 | |
230 | (base32 | |
231 | "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9")))) | |
232 | (build-system gnu-build-system) | |
233 | (inputs `(("gmp" ,gmp))) | |
234 | (home-page "http://www.kotnet.org/~skimo/isl/") | |
235 | (synopsis | |
236 | "A library for manipulating sets and relations of integer points bounded | |
237 | by linear constraints") | |
238 | (description | |
239 | "isl is a library for manipulating sets and relations of integer points | |
240 | bounded by linear constraints. Supported operations on sets include | |
241 | intersection, union, set difference, emptiness check, convex hull, (integer) | |
242 | affine hull, integer projection, computing the lexicographic minimum using | |
243 | parametric integer programming, coalescing and parametric vertex | |
244 | enumeration. It also includes an ILP solver based on generalized basis | |
245 | reduction, transitive closures on maps (which may encode infinite graphs), | |
246 | dependence analysis and bounds on piecewise step-polynomials.") | |
247 | (license lgpl2.1+))) | |
248 | ||
249 | (define-public cloog | |
250 | (package | |
251 | (name "cloog") | |
252 | (version "0.18.0") | |
253 | (source | |
254 | (origin | |
255 | (method url-fetch) | |
256 | (uri (list (string-append | |
257 | "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-" | |
258 | version | |
259 | ".tar.gz") | |
260 | (string-append %gcc-infrastructure | |
261 | name "-" version ".tar.gz"))) | |
262 | (sha256 | |
263 | (base32 | |
264 | "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw")) | |
265 | (file-name (string-append name "-" version ".tar.gz")))) | |
266 | (build-system gnu-build-system) | |
267 | (inputs `(("gmp" ,gmp) | |
268 | ("isl" ,isl))) | |
269 | (arguments '(#:configure-flags '("--with-isl=system"))) | |
270 | (home-page "http://www.cloog.org/") | |
271 | (synopsis "A library to generate code for scanning Z-polyhedra") | |
272 | (description | |
273 | "CLooG is a free software library to generate code for scanning | |
274 | Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that | |
275 | reaches each integral point of one or more parameterized polyhedra. | |
276 | CLooG has been originally written to solve the code generation problem | |
277 | for optimizing compilers based on the polytope model. Nevertheless it | |
278 | is used now in various area e.g., to build control automata for | |
279 | high-level synthesis or to find the best polynomial approximation of a | |
280 | function. CLooG may help in any situation where scanning polyhedra | |
281 | matters. While the user has full control on generated code quality, | |
282 | CLooG is designed to avoid control overhead and to produce a very | |
283 | effective code.") | |
284 | (license gpl2+))) | |
5c126b64 LC |
285 | |
286 | (define-public libelf | |
287 | (package | |
288 | (name "libelf") | |
289 | (version "0.8.13") | |
290 | (source (origin | |
291 | (method url-fetch) | |
292 | (uri (string-append "http://www.mr511.de/software/libelf-" | |
293 | version ".tar.gz")) | |
294 | (sha256 | |
295 | (base32 | |
296 | "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr")))) | |
297 | (build-system gnu-build-system) | |
298 | (arguments '(#:phases (alist-replace | |
299 | 'configure | |
300 | (lambda* (#:key outputs #:allow-other-keys) | |
301 | ;; This old `configure' script doesn't support | |
302 | ;; variables passed as arguments. | |
303 | (let ((out (assoc-ref outputs "out"))) | |
304 | (setenv "CONFIG_SHELL" (which "bash")) | |
305 | (zero? | |
306 | (system* "./configure" | |
307 | (string-append "--prefix=" out))))) | |
308 | %standard-phases))) | |
309 | (home-page "http://www.mr511.de/software/english.html") | |
310 | (synopsis "An ELF object file access library") | |
311 | (description "libelf is a C library to access ELF object files.") | |
312 | (license lgpl2.0+))) |