Commit | Line | Data |
---|---|---|
e9c0b944 | 1 | ;;; GNU Guix --- Functional package management for GNU |
6f58d582 | 2 | ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
e9c0b944 LC |
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) |
3e778ad3 | 27 | #:use-module (gnu packages elf) |
e9c0b944 LC |
28 | #:use-module (guix packages) |
29 | #:use-module (guix download) | |
ca16cb96 | 30 | #:use-module (guix build-system gnu) |
fdd6c726 | 31 | #:use-module (guix utils) |
ca16cb96 | 32 | #:use-module (ice-9 regex)) |
e9c0b944 | 33 | |
832abc76 LC |
34 | (define %gcc-infrastructure |
35 | ;; Base URL for GCC's infrastructure. | |
36 | "ftp://gcc.gnu.org/pub/gcc/infrastructure/") | |
37 | ||
ca16cb96 LC |
38 | (define-public (gcc-configure-flags-for-triplet target) |
39 | "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet. | |
40 | ||
41 | The purpose of this procedure is to translate extended GNU triplets---e.g., | |
42 | where the OS part is overloaded to denote a specific ABI---into GCC | |
43 | `configure' options. We take extended GNU triplets that glibc recognizes." | |
44 | (cond ((string-match "^mips64el.*gnuabin?64$" target) | |
45 | ;; Triplets recognized by glibc as denoting the N64 ABI; see | |
46 | ;; ports/sysdeps/mips/preconfigure. | |
47 | '("--with-abi=64")) | |
48 | (else | |
49 | ;; TODO: Add `armel.*gnueabi', `hf', etc. | |
50 | '()))) | |
51 | ||
e9c0b944 | 52 | (define-public gcc-4.7 |
de1d41f9 | 53 | (let* ((stripped? #t) ; TODO: make this a parameter |
6b9229ca | 54 | (install-target |
5c860cec LC |
55 | (lambda () |
56 | ;; The 'install-strip' rule uses the native 'strip' instead of | |
57 | ;; 'TARGET-strip' when cross-compiling. Thus, use 'install' in that | |
58 | ;; case. | |
59 | (if (and stripped? (not (%current-target-system))) | |
60 | "install-strip" | |
61 | "install"))) | |
de1d41f9 LC |
62 | (maybe-target-tools |
63 | (lambda () | |
64 | ;; Return the `_FOR_TARGET' variables that are needed when | |
65 | ;; cross-compiling GCC. | |
66 | (let ((target (%current-target-system))) | |
67 | (if target | |
68 | (map (lambda (var tool) | |
69 | (string-append (string-append var "_FOR_TARGET") | |
70 | "=" target "-" tool)) | |
71 | '("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP") | |
72 | '("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip")) | |
73 | '())))) | |
74 | (configure-flags | |
75 | (lambda () | |
76 | ;; This is terrible. Since we have two levels of quasiquotation, | |
77 | ;; we have to do this convoluted thing just so we can insert the | |
78 | ;; contents of (maybe-target-tools). | |
79 | (list 'quasiquote | |
80 | (append | |
81 | '("--enable-plugin" | |
82 | "--enable-languages=c,c++" | |
83 | "--disable-multilib" | |
84 | ||
06213498 LC |
85 | ;; No pre-compiled libstdc++ headers, to save space. |
86 | "--disable-libstdcxx-pch" | |
87 | ||
de1d41f9 LC |
88 | "--with-local-prefix=/no-gcc-local-prefix" |
89 | ||
84e6756c LC |
90 | ;; With a separate "lib" output, the build system |
91 | ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force | |
92 | ;; it. (Don't use a versioned sub-directory, that's | |
93 | ;; unnecessary.) | |
94 | ,(string-append "--with-gxx-include-dir=" | |
95 | (assoc-ref %outputs "out") | |
96 | "/include/c++") | |
97 | ||
de1d41f9 LC |
98 | ,(let ((libc (assoc-ref %build-inputs "libc"))) |
99 | (if libc | |
100 | (string-append "--with-native-system-header-dir=" libc | |
101 | "/include") | |
102 | "--without-headers"))) | |
103 | ||
ca16cb96 LC |
104 | ;; When cross-compiling GCC, pass the right options for the |
105 | ;; target triplet. | |
106 | (or (and=> (%current-target-system) | |
107 | gcc-configure-flags-for-triplet) | |
108 | '()) | |
109 | ||
de1d41f9 | 110 | (maybe-target-tools)))))) |
e9c0b944 | 111 | (package |
de1d41f9 | 112 | (name "gcc") |
d2e2f142 | 113 | (version "4.7.4") |
de1d41f9 LC |
114 | (source (origin |
115 | (method url-fetch) | |
116 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
117 | version "/gcc-" version ".tar.bz2")) | |
118 | (sha256 | |
119 | (base32 | |
d2e2f142 | 120 | "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj")))) |
de1d41f9 | 121 | (build-system gnu-build-system) |
84e6756c LC |
122 | |
123 | ;; Separate out the run-time support libraries because all the | |
124 | ;; dynamic-linked objects depend on it. | |
125 | (outputs '("out" ; commands, etc. (60+ MiB) | |
126 | "lib")) ; libgcc_s, libgomp, etc. (15+ MiB) | |
127 | ||
de1d41f9 LC |
128 | (inputs `(("gmp" ,gmp) |
129 | ("mpfr" ,mpfr) | |
130 | ("mpc" ,mpc) | |
131 | ("isl" ,isl) | |
132 | ("cloog" ,cloog) | |
133 | ("libelf" ,libelf) | |
134 | ("zlib" ,zlib))) | |
c8ebc821 LC |
135 | |
136 | ;; GCC is one of the few packages that doesn't ship .info files. | |
137 | (native-inputs `(("texinfo" ,texinfo))) | |
138 | ||
de1d41f9 LC |
139 | (arguments |
140 | `(#:out-of-source? #t | |
141 | #:strip-binaries? ,stripped? | |
142 | #:configure-flags ,(configure-flags) | |
143 | #:make-flags | |
fd0b2766 LC |
144 | ;; None of the flags below are needed when doing a Canadian cross. |
145 | ;; TODO: Simplify this. | |
146 | ,(if (%current-target-system) | |
147 | (if stripped? | |
148 | ''("CFLAGS=-g0 -O2") | |
149 | ''()) | |
150 | `(let* ((libc (assoc-ref %build-inputs "libc")) | |
151 | (libc-native (or (assoc-ref %build-inputs "libc-native") | |
152 | libc))) | |
153 | `(,@(if libc | |
154 | (list (string-append "LDFLAGS_FOR_TARGET=" | |
155 | "-B" libc "/lib " | |
156 | "-Wl,-dynamic-linker " | |
157 | "-Wl," libc | |
158 | ,(glibc-dynamic-linker))) | |
159 | '()) | |
160 | ||
161 | ;; Native programs like 'genhooks' also need that right. | |
162 | ,(string-append "LDFLAGS=" | |
163 | "-Wl,-rpath=" libc-native "/lib " | |
164 | "-Wl,-dynamic-linker " | |
165 | "-Wl," libc-native ,(glibc-dynamic-linker)) | |
166 | ,(string-append "BOOT_CFLAGS=-O2 " | |
167 | ,(if stripped? "-g0" "-g"))))) | |
de1d41f9 LC |
168 | |
169 | #:tests? #f | |
170 | #:phases | |
171 | (alist-cons-before | |
172 | 'configure 'pre-configure | |
173 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
84e6756c LC |
174 | (let ((libdir (or (assoc-ref outputs "lib") |
175 | (assoc-ref outputs "out"))) | |
176 | (libc (assoc-ref inputs "libc"))) | |
de1d41f9 LC |
177 | (when libc |
178 | ;; The following is not performed for `--without-headers' | |
179 | ;; cross-compiler builds. | |
180 | ||
181 | ;; Fix the dynamic linker's file name. | |
182 | (substitute* (find-files "gcc/config" | |
183 | "^linux(64|-elf)?\\.h$") | |
184 | (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix) | |
185 | (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%" | |
186 | suffix | |
187 | (string-append libc ,(glibc-dynamic-linker))))) | |
188 | ||
189 | ;; Tell where to find libstdc++, libc, and `?crt*.o', except | |
190 | ;; `crt{begin,end}.o', which come with GCC. | |
191 | (substitute* (find-files "gcc/config" | |
06213498 LC |
192 | "^gnu-user.*\\.h$") |
193 | (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix) | |
a7bf595f LC |
194 | ;; Help libgcc_s.so be found (see also below.) Always use |
195 | ;; '-lgcc_s' so that libgcc_s.so is always found by those | |
196 | ;; programs that use 'pthread_cancel' (glibc dlopens | |
197 | ;; libgcc_s.so when pthread_cancel support is needed, but | |
198 | ;; having it in the application's RUNPATH isn't enough; see | |
199 | ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.) | |
06213498 | 200 | (format #f "#define GNU_USER_TARGET_LIB_SPEC \ |
a7bf595f | 201 | \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib -lgcc_s}} \" ~a" |
84e6756c | 202 | libc libc libdir libdir suffix)) |
06213498 | 203 | (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line) |
de1d41f9 | 204 | (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\" |
e9c0b944 | 205 | #define STANDARD_STARTFILE_PREFIX_2 \"\" |
06213498 | 206 | ~a" |
de1d41f9 LC |
207 | libc line)))) |
208 | ||
209 | ;; Don't retain a dependency on the build-time sed. | |
210 | (substitute* "fixincludes/fixincl.x" | |
211 | (("static char const sed_cmd_z\\[\\] =.*;") | |
84e6756c LC |
212 | "static char const sed_cmd_z[] = \"sed\";")) |
213 | ||
214 | ;; Move libstdc++*-gdb.py to the "lib" output to avoid a | |
215 | ;; circularity between "out" and "lib". (Note: | |
216 | ;; --with-python-dir is useless because it imposes $(prefix) as | |
217 | ;; the parent directory.) | |
218 | (substitute* "libstdc++-v3/python/Makefile.in" | |
219 | (("pythondir = .*$") | |
220 | (string-append "pythondir = " libdir "/share" | |
221 | "/gcc-$(gcc_version)/python\n"))) | |
222 | ||
223 | ;; Avoid another circularity between the outputs: this #define | |
224 | ;; ends up in auto-host.h in the "lib" output, referring to | |
225 | ;; "out". (This variable is used to augment cpp's search path, | |
226 | ;; but there's nothing useful to look for here.) | |
227 | (substitute* "gcc/config.in" | |
228 | (("PREFIX_INCLUDE_DIR") | |
229 | "PREFIX_INCLUDE_DIR_isnt_necessary_here")))) | |
de1d41f9 LC |
230 | |
231 | (alist-cons-after | |
232 | 'configure 'post-configure | |
233 | (lambda _ | |
234 | ;; Don't store configure flags, to avoid retaining references to | |
6f58d582 | 235 | ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'. |
de1d41f9 LC |
236 | (substitute* "Makefile" |
237 | (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest) | |
238 | "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))) | |
239 | (alist-replace 'install | |
240 | (lambda* (#:key outputs #:allow-other-keys) | |
241 | (zero? | |
5c860cec | 242 | (system* "make" ,(install-target)))) |
de1d41f9 LC |
243 | %standard-phases))))) |
244 | ||
245 | (native-search-paths | |
246 | (list (search-path-specification | |
247 | (variable "CPATH") | |
248 | (directories '("include"))) | |
249 | (search-path-specification | |
250 | (variable "LIBRARY_PATH") | |
251 | (directories '("lib" "lib64"))))) | |
252 | ||
253 | (properties `((gcc-libc . ,(assoc-ref inputs "libc")))) | |
254 | (synopsis "GNU Compiler Collection") | |
255 | (description | |
a22dc0c4 LC |
256 | "GCC is the GNU Compiler Collection. It provides compiler front-ends |
257 | for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and | |
79c311b8 | 258 | Go. It also includes runtime support libraries for these languages.") |
de1d41f9 LC |
259 | (license gpl3+) |
260 | (home-page "http://gcc.gnu.org/")))) | |
832abc76 | 261 | |
3b401612 | 262 | (define-public gcc-4.8 |
3b401612 | 263 | (package (inherit gcc-4.7) |
a43da8f9 | 264 | (version "4.8.3") |
3b401612 LC |
265 | (source (origin |
266 | (method url-fetch) | |
267 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
268 | version "/gcc-" version ".tar.bz2")) | |
269 | (sha256 | |
270 | (base32 | |
6904ecce LC |
271 | "07hg10zs7gnqz58my10ch0zygizqh0z0bz6pv4pgxx45n48lz3ka")) |
272 | (patches (list (search-patch "gcc-fix-pr61801.patch"))))))) | |
3b401612 | 273 | |
571aa6cd LC |
274 | (define-public gcc-4.9 |
275 | (package (inherit gcc-4.7) | |
da9c8102 | 276 | (version "4.9.1") |
571aa6cd LC |
277 | (source (origin |
278 | (method url-fetch) | |
279 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
280 | version "/gcc-" version ".tar.bz2")) | |
281 | (sha256 | |
282 | (base32 | |
da9c8102 | 283 | "0zki3ngi0gsidnmsp88mjl2868cc7cm5wm1vwqw6znja28d7hd6k")))))) |
571aa6cd | 284 | |
c4df90a5 | 285 | (define* (custom-gcc gcc name languages #:key (separate-lib-output? #t)) |
fdd6c726 NK |
286 | "Return a custom version of GCC that supports LANGUAGES." |
287 | (package (inherit gcc) | |
288 | (name name) | |
c4df90a5 MW |
289 | (outputs (if separate-lib-output? |
290 | (package-outputs gcc) | |
291 | (delete "lib" (package-outputs gcc)))) | |
fdd6c726 NK |
292 | (arguments |
293 | (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system) | |
294 | (guix build utils) | |
295 | (ice-9 regex) | |
296 | (srfi srfi-1) | |
297 | (srfi srfi-26)) | |
298 | ,@(package-arguments gcc)) | |
299 | ((#:configure-flags flags) | |
300 | `(cons (string-append "--enable-languages=" | |
301 | ,(string-join languages ",")) | |
302 | (remove (cut string-match "--enable-languages.*" <>) | |
303 | ,flags))))))) | |
304 | ||
305 | (define-public gfortran-4.8 | |
306 | (custom-gcc gcc-4.8 "gfortran" '("fortran"))) | |
307 | ||
308 | (define-public gccgo-4.8 | |
c4df90a5 MW |
309 | (custom-gcc gcc-4.8 "gccgo" '("go") |
310 | ;; Suppress the separate "lib" output, because otherwise the | |
311 | ;; "lib" and "out" outputs would refer to each other, creating | |
312 | ;; a cyclic dependency. <http://debbugs.gnu.org/18101> | |
313 | #:separate-lib-output? #f)) | |
fdd6c726 NK |
314 | |
315 | (define-public gcc-objc-4.8 | |
316 | (custom-gcc gcc-4.8 "gcc-objc" '("objc"))) | |
317 | ||
318 | (define-public gcc-objc++-4.8 | |
319 | (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++"))) | |
320 | ||
832abc76 LC |
321 | (define-public isl |
322 | (package | |
323 | (name "isl") | |
324 | (version "0.11.1") | |
325 | (source (origin | |
326 | (method url-fetch) | |
327 | (uri (list (string-append | |
590a4904 | 328 | "http://isl.gforge.inria.fr/isl-" |
832abc76 LC |
329 | version |
330 | ".tar.bz2") | |
331 | (string-append %gcc-infrastructure | |
332 | name "-" version ".tar.gz"))) | |
333 | (sha256 | |
334 | (base32 | |
335 | "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9")))) | |
336 | (build-system gnu-build-system) | |
337 | (inputs `(("gmp" ,gmp))) | |
590a4904 | 338 | (home-page "http://isl.gforge.inria.fr/") |
832abc76 | 339 | (synopsis |
9e771e3b LC |
340 | "Manipulating sets and relations of integer points \ |
341 | bounded by linear constraints") | |
832abc76 LC |
342 | (description |
343 | "isl is a library for manipulating sets and relations of integer points | |
344 | bounded by linear constraints. Supported operations on sets include | |
345 | intersection, union, set difference, emptiness check, convex hull, (integer) | |
346 | affine hull, integer projection, computing the lexicographic minimum using | |
347 | parametric integer programming, coalescing and parametric vertex | |
348 | enumeration. It also includes an ILP solver based on generalized basis | |
349 | reduction, transitive closures on maps (which may encode infinite graphs), | |
350 | dependence analysis and bounds on piecewise step-polynomials.") | |
351 | (license lgpl2.1+))) | |
352 | ||
353 | (define-public cloog | |
354 | (package | |
355 | (name "cloog") | |
356 | (version "0.18.0") | |
357 | (source | |
358 | (origin | |
359 | (method url-fetch) | |
360 | (uri (list (string-append | |
361 | "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-" | |
362 | version | |
363 | ".tar.gz") | |
364 | (string-append %gcc-infrastructure | |
365 | name "-" version ".tar.gz"))) | |
366 | (sha256 | |
367 | (base32 | |
368 | "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw")) | |
369 | (file-name (string-append name "-" version ".tar.gz")))) | |
370 | (build-system gnu-build-system) | |
371 | (inputs `(("gmp" ,gmp) | |
372 | ("isl" ,isl))) | |
373 | (arguments '(#:configure-flags '("--with-isl=system"))) | |
374 | (home-page "http://www.cloog.org/") | |
9e771e3b | 375 | (synopsis "Library to generate code for scanning Z-polyhedra") |
832abc76 LC |
376 | (description |
377 | "CLooG is a free software library to generate code for scanning | |
378 | Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that | |
379 | reaches each integral point of one or more parameterized polyhedra. | |
380 | CLooG has been originally written to solve the code generation problem | |
381 | for optimizing compilers based on the polytope model. Nevertheless it | |
382 | is used now in various area e.g., to build control automata for | |
383 | high-level synthesis or to find the best polynomial approximation of a | |
384 | function. CLooG may help in any situation where scanning polyhedra | |
385 | matters. While the user has full control on generated code quality, | |
386 | CLooG is designed to avoid control overhead and to produce a very | |
387 | effective code.") | |
388 | (license gpl2+))) | |
5c126b64 | 389 |