Commit | Line | Data |
---|---|---|
e9c0b944 | 1 | ;;; GNU Guix --- Functional package management for GNU |
9af07624 | 2 | ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> |
270b501e | 3 | ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org> |
82f145ef | 4 | ;;; Copyright © 2014, 2015, 2016 Ricardo Wurmus <rekado@elephly.net> |
ed2b1c4f | 5 | ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr> |
b0847497 | 6 | ;;; Copyright © 2015, 2016 Efraim Flashner <efraim@flashner.co.il> |
e9c0b944 LC |
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 gcc) | |
c6d7e299 | 24 | #:use-module ((guix licenses) |
50c7a1e2 | 25 | #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+)) |
e9c0b944 LC |
26 | #:use-module (gnu packages) |
27 | #:use-module (gnu packages bootstrap) | |
28 | #:use-module (gnu packages compression) | |
29 | #:use-module (gnu packages multiprecision) | |
c8ebc821 | 30 | #:use-module (gnu packages texinfo) |
c364a287 | 31 | #:use-module (gnu packages dejagnu) |
99828fa7 | 32 | #:use-module (gnu packages documentation) |
98b385d1 LC |
33 | #:use-module (gnu packages xml) |
34 | #:use-module (gnu packages docbook) | |
35 | #:use-module (gnu packages graphviz) | |
3e778ad3 | 36 | #:use-module (gnu packages elf) |
38cf2ba0 | 37 | #:use-module (gnu packages perl) |
e9c0b944 LC |
38 | #:use-module (guix packages) |
39 | #:use-module (guix download) | |
ca16cb96 | 40 | #:use-module (guix build-system gnu) |
74574fd1 | 41 | #:use-module (guix build-system trivial) |
fdd6c726 | 42 | #:use-module (guix utils) |
e052c7e1 | 43 | #:use-module (srfi srfi-1) |
ca16cb96 | 44 | #:use-module (ice-9 regex)) |
e9c0b944 | 45 | |
832abc76 LC |
46 | (define %gcc-infrastructure |
47 | ;; Base URL for GCC's infrastructure. | |
966a543b | 48 | "mirror://gcc/infrastructure/") |
832abc76 | 49 | |
76e639a0 | 50 | (define (gcc-configure-flags-for-triplet target) |
ca16cb96 LC |
51 | "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet. |
52 | ||
53 | The purpose of this procedure is to translate extended GNU triplets---e.g., | |
54 | where the OS part is overloaded to denote a specific ABI---into GCC | |
55 | `configure' options. We take extended GNU triplets that glibc recognizes." | |
56 | (cond ((string-match "^mips64el.*gnuabin?64$" target) | |
57 | ;; Triplets recognized by glibc as denoting the N64 ABI; see | |
58 | ;; ports/sysdeps/mips/preconfigure. | |
59 | '("--with-abi=64")) | |
3f00ff8b MW |
60 | |
61 | ((string-match "^arm.*-gnueabihf$" target) | |
62 | '("--with-arch=armv7-a" | |
63 | "--with-float=hard" | |
64 | "--with-mode=thumb" | |
aa725117 | 65 | "--with-fpu=neon")) |
3f00ff8b | 66 | |
ca16cb96 | 67 | (else |
3f00ff8b | 68 | ;; TODO: Add `arm.*-gnueabi', etc. |
ca16cb96 LC |
69 | '()))) |
70 | ||
e9c0b944 | 71 | (define-public gcc-4.7 |
9063ef0f | 72 | (let* ((stripped? #t) ;whether to strip the compiler, not the libraries |
de1d41f9 LC |
73 | (maybe-target-tools |
74 | (lambda () | |
75 | ;; Return the `_FOR_TARGET' variables that are needed when | |
76 | ;; cross-compiling GCC. | |
77 | (let ((target (%current-target-system))) | |
78 | (if target | |
79 | (map (lambda (var tool) | |
80 | (string-append (string-append var "_FOR_TARGET") | |
81 | "=" target "-" tool)) | |
82 | '("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP") | |
83 | '("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip")) | |
84 | '())))) | |
7e3c9f74 LC |
85 | (libdir |
86 | (let ((base '(or (assoc-ref outputs "lib") | |
87 | (assoc-ref outputs "out")))) | |
88 | (lambda () | |
89 | ;; Return the directory that contains lib/libgcc_s.so et al. | |
90 | (if (%current-target-system) | |
91 | `(string-append ,base "/" ,(%current-target-system)) | |
92 | base)))) | |
de1d41f9 LC |
93 | (configure-flags |
94 | (lambda () | |
95 | ;; This is terrible. Since we have two levels of quasiquotation, | |
96 | ;; we have to do this convoluted thing just so we can insert the | |
97 | ;; contents of (maybe-target-tools). | |
98 | (list 'quasiquote | |
99 | (append | |
100 | '("--enable-plugin" | |
101 | "--enable-languages=c,c++" | |
102 | "--disable-multilib" | |
98bd851e | 103 | "--with-system-zlib" |
de1d41f9 | 104 | |
06213498 LC |
105 | ;; No pre-compiled libstdc++ headers, to save space. |
106 | "--disable-libstdcxx-pch" | |
107 | ||
de1d41f9 LC |
108 | "--with-local-prefix=/no-gcc-local-prefix" |
109 | ||
84e6756c LC |
110 | ;; With a separate "lib" output, the build system |
111 | ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force | |
112 | ;; it. (Don't use a versioned sub-directory, that's | |
113 | ;; unnecessary.) | |
114 | ,(string-append "--with-gxx-include-dir=" | |
115 | (assoc-ref %outputs "out") | |
116 | "/include/c++") | |
117 | ||
de1d41f9 LC |
118 | ,(let ((libc (assoc-ref %build-inputs "libc"))) |
119 | (if libc | |
120 | (string-append "--with-native-system-header-dir=" libc | |
121 | "/include") | |
122 | "--without-headers"))) | |
123 | ||
76e639a0 MW |
124 | ;; Pass the right options for the target triplet. |
125 | (let ((triplet | |
126 | (or (%current-target-system) | |
127 | (nix-system->gnu-triplet (%current-system))))) | |
128 | (gcc-configure-flags-for-triplet triplet)) | |
ca16cb96 | 129 | |
de1d41f9 | 130 | (maybe-target-tools)))))) |
e9c0b944 | 131 | (package |
de1d41f9 | 132 | (name "gcc") |
d2e2f142 | 133 | (version "4.7.4") |
de1d41f9 LC |
134 | (source (origin |
135 | (method url-fetch) | |
136 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
137 | version "/gcc-" version ".tar.bz2")) | |
138 | (sha256 | |
139 | (base32 | |
d2e2f142 | 140 | "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj")))) |
de1d41f9 | 141 | (build-system gnu-build-system) |
84e6756c LC |
142 | |
143 | ;; Separate out the run-time support libraries because all the | |
144 | ;; dynamic-linked objects depend on it. | |
9063ef0f LC |
145 | (outputs '("out" ;commands, etc. (60+ MiB) |
146 | "lib" ;libgcc_s, libgomp, etc. (15+ MiB) | |
147 | "debug")) ;debug symbols of run-time libraries | |
84e6756c | 148 | |
de1d41f9 LC |
149 | (inputs `(("gmp" ,gmp) |
150 | ("mpfr" ,mpfr) | |
151 | ("mpc" ,mpc) | |
152 | ("isl" ,isl) | |
153 | ("cloog" ,cloog) | |
154 | ("libelf" ,libelf) | |
155 | ("zlib" ,zlib))) | |
c8ebc821 | 156 | |
868c13c5 | 157 | ;; GCC < 5 is one of the few packages that doesn't ship .info files. |
72246dc0 EF |
158 | ;; Newer texinfos fail to build the manual, so we use an older one. |
159 | (native-inputs `(("texinfo" ,texinfo-5))) | |
c8ebc821 | 160 | |
de1d41f9 LC |
161 | (arguments |
162 | `(#:out-of-source? #t | |
de1d41f9 LC |
163 | #:configure-flags ,(configure-flags) |
164 | #:make-flags | |
fd0b2766 LC |
165 | ;; None of the flags below are needed when doing a Canadian cross. |
166 | ;; TODO: Simplify this. | |
167 | ,(if (%current-target-system) | |
168 | (if stripped? | |
169 | ''("CFLAGS=-g0 -O2") | |
170 | ''()) | |
171 | `(let* ((libc (assoc-ref %build-inputs "libc")) | |
172 | (libc-native (or (assoc-ref %build-inputs "libc-native") | |
173 | libc))) | |
174 | `(,@(if libc | |
175 | (list (string-append "LDFLAGS_FOR_TARGET=" | |
176 | "-B" libc "/lib " | |
177 | "-Wl,-dynamic-linker " | |
178 | "-Wl," libc | |
179 | ,(glibc-dynamic-linker))) | |
180 | '()) | |
181 | ||
182 | ;; Native programs like 'genhooks' also need that right. | |
183 | ,(string-append "LDFLAGS=" | |
184 | "-Wl,-rpath=" libc-native "/lib " | |
185 | "-Wl,-dynamic-linker " | |
186 | "-Wl," libc-native ,(glibc-dynamic-linker)) | |
187 | ,(string-append "BOOT_CFLAGS=-O2 " | |
188 | ,(if stripped? "-g0" "-g"))))) | |
de1d41f9 LC |
189 | |
190 | #:tests? #f | |
dfc8bb20 | 191 | |
de1d41f9 LC |
192 | #:phases |
193 | (alist-cons-before | |
194 | 'configure 'pre-configure | |
195 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
7e3c9f74 | 196 | (let ((libdir ,(libdir)) |
84e6756c | 197 | (libc (assoc-ref inputs "libc"))) |
de1d41f9 LC |
198 | (when libc |
199 | ;; The following is not performed for `--without-headers' | |
200 | ;; cross-compiler builds. | |
201 | ||
91c47bef MW |
202 | ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a |
203 | ;; single line, to allow the next step to work properly. | |
204 | (for-each | |
205 | (lambda (x) | |
206 | (substitute* (find-files "gcc/config" | |
3f00ff8b | 207 | "^linux(64|-elf|-eabi)?\\.h$") |
91c47bef MW |
208 | (("(#define GLIBC_DYNAMIC_LINKER.*)\\\\\n$" _ line) |
209 | line))) | |
210 | '(1 2 3)) | |
211 | ||
de1d41f9 LC |
212 | ;; Fix the dynamic linker's file name. |
213 | (substitute* (find-files "gcc/config" | |
0cce9968 | 214 | "^(linux|gnu)(64|-elf|-eabi)?\\.h$") |
de1d41f9 LC |
215 | (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix) |
216 | (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%" | |
217 | suffix | |
218 | (string-append libc ,(glibc-dynamic-linker))))) | |
219 | ||
220 | ;; Tell where to find libstdc++, libc, and `?crt*.o', except | |
221 | ;; `crt{begin,end}.o', which come with GCC. | |
222 | (substitute* (find-files "gcc/config" | |
06213498 LC |
223 | "^gnu-user.*\\.h$") |
224 | (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix) | |
fa1e2f3d MW |
225 | ;; Help libgcc_s.so be found (see also below.) Always use |
226 | ;; '-lgcc_s' so that libgcc_s.so is always found by those | |
227 | ;; programs that use 'pthread_cancel' (glibc dlopens | |
228 | ;; libgcc_s.so when pthread_cancel support is needed, but | |
229 | ;; having it in the application's RUNPATH isn't enough; see | |
a7bf595f | 230 | ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.) |
270b501e MW |
231 | ;; |
232 | ;; NOTE: The '-lgcc_s' added below needs to be removed in a | |
233 | ;; later phase of %gcc-static. If you change the string | |
234 | ;; below, make sure to update the relevant code in | |
235 | ;; %gcc-static package as needed. | |
06213498 | 236 | (format #f "#define GNU_USER_TARGET_LIB_SPEC \ |
81197492 LC |
237 | \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a" |
238 | libc libc libdir suffix)) | |
06213498 | 239 | (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line) |
de1d41f9 | 240 | (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\" |
e9c0b944 | 241 | #define STANDARD_STARTFILE_PREFIX_2 \"\" |
06213498 | 242 | ~a" |
de1d41f9 LC |
243 | libc line)))) |
244 | ||
245 | ;; Don't retain a dependency on the build-time sed. | |
246 | (substitute* "fixincludes/fixincl.x" | |
247 | (("static char const sed_cmd_z\\[\\] =.*;") | |
84e6756c LC |
248 | "static char const sed_cmd_z[] = \"sed\";")) |
249 | ||
d0b62698 LC |
250 | (when (file-exists? "libbacktrace") |
251 | ;; GCC 4.8+ comes with libbacktrace. By default it builds | |
252 | ;; with -Werror, which fails with a -Wcast-qual error in glibc | |
253 | ;; 2.21's stdlib-bsearch.h. Remove -Werror. | |
254 | (substitute* "libbacktrace/configure" | |
255 | (("WARN_FLAGS=(.*)-Werror" _ flags) | |
ec299071 LC |
256 | (string-append "WARN_FLAGS=" flags))) |
257 | ||
258 | (when (file-exists? "libsanitizer/libbacktrace") | |
259 | ;; Same in libsanitizer's bundled copy (!) found in 4.9+. | |
260 | (substitute* "libsanitizer/libbacktrace/Makefile.in" | |
261 | (("-Werror") | |
262 | "")))) | |
d0b62698 | 263 | |
21e583de LC |
264 | ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s. |
265 | ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354> | |
266 | ;; and <http://bugs.gnu.org/20358>. | |
267 | (substitute* "libstdc++-v3/src/Makefile.in" | |
268 | (("^OPT_LDFLAGS = ") | |
269 | "OPT_LDFLAGS = -Wl,-rpath=$(libdir) ")) | |
270 | ||
84e6756c LC |
271 | ;; Move libstdc++*-gdb.py to the "lib" output to avoid a |
272 | ;; circularity between "out" and "lib". (Note: | |
273 | ;; --with-python-dir is useless because it imposes $(prefix) as | |
274 | ;; the parent directory.) | |
275 | (substitute* "libstdc++-v3/python/Makefile.in" | |
276 | (("pythondir = .*$") | |
277 | (string-append "pythondir = " libdir "/share" | |
278 | "/gcc-$(gcc_version)/python\n"))) | |
279 | ||
280 | ;; Avoid another circularity between the outputs: this #define | |
281 | ;; ends up in auto-host.h in the "lib" output, referring to | |
282 | ;; "out". (This variable is used to augment cpp's search path, | |
283 | ;; but there's nothing useful to look for here.) | |
284 | (substitute* "gcc/config.in" | |
285 | (("PREFIX_INCLUDE_DIR") | |
286 | "PREFIX_INCLUDE_DIR_isnt_necessary_here")))) | |
de1d41f9 LC |
287 | |
288 | (alist-cons-after | |
289 | 'configure 'post-configure | |
290 | (lambda _ | |
291 | ;; Don't store configure flags, to avoid retaining references to | |
6f58d582 | 292 | ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'. |
de1d41f9 LC |
293 | (substitute* "Makefile" |
294 | (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest) | |
295 | "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))) | |
9063ef0f | 296 | %standard-phases)))) |
de1d41f9 LC |
297 | |
298 | (native-search-paths | |
009b53fd LC |
299 | ;; Use the language-specific variables rather than 'CPATH' because they |
300 | ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. | |
301 | ;; The intent is to allow headers that are in the search path to be | |
302 | ;; treated as "system headers" (headers exempt from warnings) just like | |
303 | ;; the typical /usr/include headers on an FHS system. | |
de1d41f9 | 304 | (list (search-path-specification |
009b53fd LC |
305 | (variable "C_INCLUDE_PATH") |
306 | (files '("include"))) | |
307 | (search-path-specification | |
308 | (variable "CPLUS_INCLUDE_PATH") | |
af070955 | 309 | (files '("include"))) |
de1d41f9 LC |
310 | (search-path-specification |
311 | (variable "LIBRARY_PATH") | |
af070955 | 312 | (files '("lib" "lib64"))))) |
de1d41f9 LC |
313 | |
314 | (properties `((gcc-libc . ,(assoc-ref inputs "libc")))) | |
315 | (synopsis "GNU Compiler Collection") | |
316 | (description | |
a22dc0c4 LC |
317 | "GCC is the GNU Compiler Collection. It provides compiler front-ends |
318 | for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and | |
79c311b8 | 319 | Go. It also includes runtime support libraries for these languages.") |
de1d41f9 LC |
320 | (license gpl3+) |
321 | (home-page "http://gcc.gnu.org/")))) | |
832abc76 | 322 | |
3b401612 | 323 | (define-public gcc-4.8 |
3b401612 | 324 | (package (inherit gcc-4.7) |
ab5f49cf | 325 | (version "4.8.5") |
3b401612 | 326 | (source (origin |
7e35b9dd LC |
327 | (method url-fetch) |
328 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
329 | version "/gcc-" version ".tar.bz2")) | |
330 | (sha256 | |
331 | (base32 | |
ab5f49cf | 332 | "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2")) |
fc1adab1 | 333 | (patches (search-patches "gcc-arm-link-spec-fix.patch")))))) |
3b401612 | 334 | |
571aa6cd | 335 | (define-public gcc-4.9 |
e052c7e1 | 336 | (package (inherit gcc-4.7) |
b0847497 | 337 | (version "4.9.4") |
571aa6cd | 338 | (source (origin |
7e35b9dd LC |
339 | (method url-fetch) |
340 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
341 | version "/gcc-" version ".tar.bz2")) | |
342 | (sha256 | |
343 | (base32 | |
b0847497 | 344 | "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc")) |
e7e43727 | 345 | (patches (search-patches "gcc-arm-bug-71399.patch" |
72246dc0 EF |
346 | "gcc-libvtv-runpath.patch")))) |
347 | (native-inputs `(("texinfo" ,texinfo))))) | |
571aa6cd | 348 | |
629f4d2e | 349 | (define-public gcc-5 |
7912677c LC |
350 | ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install |
351 | ;; them in a VPATH build. | |
7e35b9dd | 352 | (package (inherit gcc-4.9) |
8c8b2bf3 | 353 | (version "5.4.0") |
60e2d5fe | 354 | (source (origin |
7e35b9dd LC |
355 | (method url-fetch) |
356 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
357 | version "/gcc-" version ".tar.bz2")) | |
358 | (sha256 | |
359 | (base32 | |
8c8b2bf3 | 360 | "0fihlcy5hnksdxk0sn6bvgnyq8gfrgs8m794b1jxwd1dxinzg3b0")) |
80337723 LC |
361 | (patches (search-patches "gcc-strmov-store-file-names.patch" |
362 | "gcc-5.0-libvtv-runpath.patch")))))) | |
60e2d5fe | 363 | |
e760ec41 LC |
364 | (define-public gcc-6 |
365 | (package | |
366 | (inherit gcc-5) | |
5d0ebcc4 | 367 | (version "6.3.0") |
e760ec41 LC |
368 | (source (origin |
369 | (method url-fetch) | |
370 | (uri (string-append "mirror://gnu/gcc/gcc-" | |
371 | version "/gcc-" version ".tar.bz2")) | |
372 | (sha256 | |
373 | (base32 | |
5d0ebcc4 | 374 | "17xjz30jb65hcf714vn9gcxvrrji8j20xm7n33qg1ywhyzryfsph")) |
80337723 LC |
375 | (patches (search-patches "gcc-strmov-store-file-names.patch" |
376 | "gcc-5.0-libvtv-runpath.patch")))))) | |
e760ec41 | 377 | |
ce362de8 MW |
378 | ;; Note: When changing the default gcc version, update |
379 | ;; the gcc-toolchain-* definitions accordingly. | |
9dee9e8f | 380 | (define-public gcc gcc-4.9) |
eed67cbb | 381 | |
d0abf829 LC |
382 | (define-public (make-libstdc++ gcc) |
383 | "Return a libstdc++ package based on GCC. The primary use case is when | |
384 | using compilers other than GCC." | |
385 | (package | |
386 | (inherit gcc) | |
387 | (name "libstdc++") | |
388 | (arguments | |
389 | `(#:out-of-source? #t | |
390 | #:phases (alist-cons-before | |
391 | 'configure 'chdir | |
392 | (lambda _ | |
393 | (chdir "libstdc++-v3")) | |
394 | %standard-phases) | |
395 | #:configure-flags `("--disable-libstdcxx-pch" | |
396 | ,(string-append "--with-gxx-include-dir=" | |
397 | (assoc-ref %outputs "out") | |
398 | "/include")))) | |
399 | (outputs '("out" "debug")) | |
400 | (inputs '()) | |
401 | (native-inputs '()) | |
402 | (propagated-inputs '()) | |
403 | (synopsis "GNU C++ standard library"))) | |
404 | ||
405 | (define-public libstdc++-4.9 | |
406 | (make-libstdc++ gcc-4.9)) | |
407 | ||
2b6b6d13 RW |
408 | (define (make-libiberty gcc) |
409 | "Return a libiberty package based on GCC." | |
410 | (package | |
411 | (inherit gcc) | |
412 | (name "libiberty") | |
413 | (arguments | |
414 | `(#:out-of-source? #t | |
415 | #:phases | |
416 | (modify-phases %standard-phases | |
417 | (add-before 'configure 'chdir | |
418 | (lambda _ | |
419 | (chdir "libiberty") | |
420 | #t)) | |
421 | (replace | |
422 | 'install | |
423 | (lambda* (#:key outputs #:allow-other-keys) | |
424 | (let* ((out (assoc-ref outputs "out")) | |
425 | (lib (string-append out "/lib/")) | |
426 | (include (string-append out "/include/"))) | |
427 | (mkdir-p lib) | |
428 | (mkdir-p include) | |
429 | (copy-file "libiberty.a" | |
430 | (string-append lib "libiberty.a")) | |
431 | (copy-file "../include/libiberty.h" | |
432 | (string-append include "libiberty.h")) | |
433 | #t)))))) | |
434 | (inputs '()) | |
435 | (outputs '("out")) | |
436 | (native-inputs '()) | |
437 | (propagated-inputs '()) | |
438 | (synopsis "Collection of subroutines used by various GNU programs"))) | |
439 | ||
440 | (define-public libiberty | |
441 | (make-libiberty gcc)) | |
442 | ||
009b53fd LC |
443 | (define* (custom-gcc gcc name languages |
444 | #:optional | |
445 | (search-paths (package-native-search-paths gcc)) | |
446 | #:key (separate-lib-output? #t)) | |
447 | "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS | |
448 | as the 'native-search-paths' field." | |
fdd6c726 NK |
449 | (package (inherit gcc) |
450 | (name name) | |
c4df90a5 MW |
451 | (outputs (if separate-lib-output? |
452 | (package-outputs gcc) | |
453 | (delete "lib" (package-outputs gcc)))) | |
009b53fd | 454 | (native-search-paths search-paths) |
fdd6c726 NK |
455 | (arguments |
456 | (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system) | |
457 | (guix build utils) | |
458 | (ice-9 regex) | |
459 | (srfi srfi-1) | |
460 | (srfi srfi-26)) | |
461 | ,@(package-arguments gcc)) | |
462 | ((#:configure-flags flags) | |
463 | `(cons (string-append "--enable-languages=" | |
464 | ,(string-join languages ",")) | |
465 | (remove (cut string-match "--enable-languages.*" <>) | |
82f145ef RW |
466 | ,flags))) |
467 | ((#:phases phases) | |
468 | `(modify-phases ,phases | |
469 | (add-after 'install 'remove-broken-or-conflicting-files | |
470 | (lambda* (#:key outputs #:allow-other-keys) | |
471 | (for-each delete-file | |
472 | (find-files (string-append (assoc-ref outputs "out") "/bin") | |
473 | ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc.*)")) | |
474 | #t)))))))) | |
fdd6c726 | 475 | |
009b53fd LC |
476 | (define %generic-search-paths |
477 | ;; This is the language-neutral search path for GCC. Entries in $CPATH are | |
478 | ;; not considered "system headers", which means GCC can raise warnings for | |
479 | ;; issues in those headers. 'CPATH' is the only one that works for | |
480 | ;; front-ends not in the C family. | |
481 | (list (search-path-specification | |
482 | (variable "CPATH") | |
483 | (files '("include"))) | |
484 | (search-path-specification | |
485 | (variable "LIBRARY_PATH") | |
486 | (files '("lib" "lib64"))))) | |
487 | ||
fdd6c726 | 488 | (define-public gfortran-4.8 |
009b53fd LC |
489 | (custom-gcc gcc-4.8 "gfortran" '("fortran") |
490 | %generic-search-paths)) | |
fdd6c726 | 491 | |
c69a8b7b | 492 | (define-public gfortran-4.9 |
009b53fd LC |
493 | (custom-gcc gcc-4.9 "gfortran" '("fortran") |
494 | %generic-search-paths)) | |
c69a8b7b | 495 | |
eed67cbb | 496 | (define-public gfortran |
9af07624 LC |
497 | ;; Note: Update this when GCC changes! We cannot use |
498 | ;; (custom-gcc gcc "fortran" …) because that would lead to a package object | |
499 | ;; that is not 'eq?' with GFORTRAN-4.9, and thus 'fold-packages' would | |
500 | ;; report two gfortran@4.9 that are in fact identical. | |
501 | gfortran-4.9) | |
eed67cbb | 502 | |
e61d9e39 | 503 | (define-public gfortran-5 |
009b53fd LC |
504 | (custom-gcc gcc-5 "gfortran" '("fortran") |
505 | %generic-search-paths)) | |
e61d9e39 | 506 | |
c8732e19 EF |
507 | (define-public gccgo-4.9 |
508 | (custom-gcc gcc-4.9 "gccgo" '("go") | |
009b53fd | 509 | %generic-search-paths |
c4df90a5 MW |
510 | ;; Suppress the separate "lib" output, because otherwise the |
511 | ;; "lib" and "out" outputs would refer to each other, creating | |
512 | ;; a cyclic dependency. <http://debbugs.gnu.org/18101> | |
513 | #:separate-lib-output? #f)) | |
fdd6c726 | 514 | |
ed2b1c4f AE |
515 | (define javac.in |
516 | (origin | |
517 | (method url-fetch) | |
518 | (uri (string-append "http://sources.gentoo.org/cgi-bin/viewvc.cgi/" | |
61af1014 LC |
519 | "gentoo-x86/dev-java/gcj-jdk/files/javac.in?revision=1.1")) |
520 | (file-name "javac.in") | |
ed2b1c4f AE |
521 | (sha256 (base32 |
522 | "1c3dk4z5yfj6ic2fn3lyxs27n6pmn2wy9k0r1s17lnkf1bzkrciv")))) | |
523 | ||
397dbde8 RW |
524 | (define-public gcj |
525 | (package (inherit gcc) | |
74574fd1 | 526 | (name "gcj") |
dbf8f84f | 527 | (version (package-version gcc)) |
74574fd1 RW |
528 | (inputs |
529 | `(("fastjar" ,fastjar) | |
530 | ("perl" ,perl) | |
ed2b1c4f | 531 | ("javac.in" ,javac.in) |
397dbde8 RW |
532 | ("ecj-bootstrap" ,ecj-bootstrap) |
533 | ,@(package-inputs gcc))) | |
c364a287 RW |
534 | (native-inputs |
535 | `(("dejagnu" ,dejagnu) | |
7edd195a RW |
536 | ,@(if (string-prefix? "armhf" (or (%current-system) |
537 | (%current-target-system))) | |
538 | `(("arm-patch" ,(origin | |
539 | (method url-fetch) | |
540 | (uri (search-patch "gcj-arm-mode.patch")) | |
541 | (sha256 | |
542 | (base32 | |
543 | "1z15xs5yx6qinnb572swzxrn9f668sw7ga5280q3gznj1jyrynfn"))))) | |
544 | '()) | |
c364a287 | 545 | ,@(package-native-inputs gcc))) |
009b53fd LC |
546 | (native-search-paths %generic-search-paths) |
547 | ||
74574fd1 RW |
548 | ;; Suppress the separate "lib" output, because otherwise the |
549 | ;; "lib" and "out" outputs would refer to each other, creating | |
550 | ;; a cyclic dependency. <http://debbugs.gnu.org/18101> | |
551 | (outputs | |
397dbde8 | 552 | (delete "lib" (package-outputs gcc))) |
74574fd1 RW |
553 | (arguments |
554 | (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system) | |
555 | (guix build utils) | |
556 | (ice-9 regex) | |
557 | (srfi srfi-1) | |
558 | (srfi srfi-26)) | |
c364a287 RW |
559 | #:test-target "check-target-libjava" |
560 | ,@(package-arguments gcc)) | |
561 | ((#:tests? _) #t) | |
74574fd1 RW |
562 | ((#:configure-flags flags) |
563 | `(let ((ecj (assoc-ref %build-inputs "ecj-bootstrap"))) | |
564 | `("--enable-java-home" | |
565 | "--enable-gjdoc" | |
566 | ,(string-append "--with-ecj-jar=" ecj) | |
567 | "--enable-languages=java" | |
568 | ,@(remove (cut string-match "--enable-languages.*" <>) | |
569 | ,flags)))) | |
ad12c43e RW |
570 | ((#:phases phases) |
571 | `(modify-phases ,phases | |
7edd195a RW |
572 | ;; Conditionally add phase to apply patch |
573 | ,@(if (string-prefix? "armhf" (or (%current-system) | |
574 | (%current-target-system))) | |
575 | `((add-after 'unpack 'apply-arm-patch | |
576 | (lambda* (#:key inputs #:allow-other-keys) | |
577 | (zero? (system* "patch" "-p1" | |
578 | "-i" (assoc-ref inputs "arm-patch")))))) | |
579 | '()) | |
ad12c43e RW |
580 | (add-after |
581 | 'unpack 'add-lib-output-to-rpath | |
582 | (lambda _ | |
583 | (substitute* "libjava/Makefile.in" | |
584 | (("libgcj_bc_dummy_LINK = .* -shared" line) | |
585 | (string-append line " -Wl,-rpath=$(libdir)")) | |
586 | (("libgcj(_bc)?_la_LDFLAGS =" ldflags _) | |
587 | (string-append ldflags " -Wl,-rpath=$(libdir)"))))) | |
a9c958b5 EF |
588 | (add-after |
589 | 'unpack 'patch-testsuite | |
590 | ;; dejagnu-1.6 removes the 'absolute' command | |
591 | (lambda _ | |
dbf8f84f RW |
592 | ;; This test fails on armhf. It seems harmless enough to disable it. |
593 | (for-each delete-file '("libjava/testsuite/libjava.lang/Throw_2.java" | |
594 | "libjava/testsuite/libjava.lang/Throw_2.out" | |
595 | "libjava/testsuite/libjava.lang/Throw_2.jar")) | |
a9c958b5 EF |
596 | (substitute* "libjava/testsuite/lib/libjava.exp" |
597 | (("absolute") "file normalize")) | |
598 | #t)) | |
ad12c43e RW |
599 | (add-after |
600 | 'install 'install-javac-and-javap-wrappers | |
601 | (lambda _ | |
602 | (let* ((javac (assoc-ref %build-inputs "javac.in")) | |
603 | (ecj (assoc-ref %build-inputs "ecj-bootstrap")) | |
604 | (gcj (assoc-ref %outputs "out")) | |
605 | (gcjbin (string-append gcj "/bin/")) | |
606 | (jvm (string-append gcj "/lib/jvm/")) | |
607 | (target (string-append jvm "/bin/javac"))) | |
608 | ||
609 | (symlink (string-append gcjbin "jcf-dump") | |
610 | (string-append jvm "/bin/javap")) | |
611 | ||
612 | (copy-file ecj (string-append gcj "/share/java/ecj.jar")) | |
613 | ||
614 | ;; Create javac wrapper from the template javac.in by | |
615 | ;; replacing the @VARIABLES@ with paths. | |
616 | (copy-file javac target) | |
617 | (patch-shebang target) | |
618 | (substitute* target | |
619 | (("@JAVA@") | |
620 | (string-append jvm "/bin/java")) | |
621 | (("@ECJ_JAR@") | |
622 | (string-append gcj "/share/java/ecj.jar")) | |
623 | (("@RT_JAR@") | |
624 | (string-append jvm "/jre/lib/rt.jar")) | |
625 | (("@TOOLS_JAR@") | |
626 | (string-append jvm "/lib/tools.jar"))) | |
627 | (chmod target #o755) | |
628 | #t))) | |
629 | (add-after | |
5f6887e8 RW |
630 | 'install 'remove-broken-or-conflicting-files |
631 | (lambda _ | |
632 | (let ((out (assoc-ref %outputs "out"))) | |
633 | (for-each | |
634 | delete-file | |
635 | (append (find-files (string-append out "/lib/jvm/jre/lib") | |
636 | "libjawt.so") | |
637 | (find-files (string-append out "/bin") | |
638 | ".*(c\\+\\+|cpp|g\\+\\+|gcc.*)")))) | |
ad12c43e | 639 | #t)))))))) |
74574fd1 | 640 | |
397dbde8 | 641 | (define ecj-bootstrap |
74574fd1 RW |
642 | (origin |
643 | (method url-fetch) | |
397dbde8 | 644 | (uri "ftp://sourceware.org/pub/java/ecj-4.9.jar") |
74574fd1 RW |
645 | (sha256 |
646 | (base32 | |
397dbde8 | 647 | "1k9lgm3qamf6zy534pa2zwskr8mpiqrngbv1vw9j4y1ghrdyf1lm")))) |
74574fd1 | 648 | |
fdd6c726 | 649 | (define-public gcc-objc-4.8 |
009b53fd LC |
650 | (custom-gcc gcc-4.8 "gcc-objc" '("objc") |
651 | (list (search-path-specification | |
652 | (variable "OBJC_INCLUDE_PATH") | |
653 | (files '("include"))) | |
654 | (search-path-specification | |
655 | (variable "LIBRARY_PATH") | |
656 | (files '("lib" "lib64")))))) | |
fdd6c726 | 657 | |
2d69c161 RW |
658 | (define-public gcc-objc-4.9 |
659 | (custom-gcc gcc-4.9 "gcc-objc" '("objc") | |
660 | (list (search-path-specification | |
661 | (variable "OBJC_INCLUDE_PATH") | |
662 | (files '("include"))) | |
663 | (search-path-specification | |
664 | (variable "LIBRARY_PATH") | |
665 | (files '("lib" "lib64")))))) | |
666 | ||
8b196ad2 RW |
667 | (define-public gcc-objc gcc-objc-4.9) |
668 | ||
fdd6c726 | 669 | (define-public gcc-objc++-4.8 |
009b53fd LC |
670 | (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++") |
671 | (list (search-path-specification | |
672 | (variable "OBJCPLUS_INCLUDE_PATH") | |
673 | (files '("include"))) | |
674 | (search-path-specification | |
675 | (variable "LIBRARY_PATH") | |
676 | (files '("lib" "lib64")))))) | |
fdd6c726 | 677 | |
a5948c0d RW |
678 | (define-public gcc-objc++-4.9 |
679 | (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++") | |
680 | (list (search-path-specification | |
681 | (variable "OBJCPLUS_INCLUDE_PATH") | |
682 | (files '("include"))) | |
009b53fd LC |
683 | (search-path-specification |
684 | (variable "LIBRARY_PATH") | |
685 | (files '("lib" "lib64")))))) | |
fdd6c726 | 686 | |
987a1183 RW |
687 | (define-public gcc-objc++ gcc-objc++-4.9) |
688 | ||
98b385d1 LC |
689 | (define (make-libstdc++-doc gcc) |
690 | "Return a package with the libstdc++ documentation for GCC." | |
691 | (package | |
692 | (inherit gcc) | |
693 | (name "libstdc++-doc") | |
694 | (version (package-version gcc)) | |
695 | (synopsis "GNU libstdc++ documentation") | |
696 | (outputs '("out")) | |
697 | (native-inputs `(("doxygen" ,doxygen) | |
698 | ("texinfo" ,texinfo) | |
699 | ("libxml2" ,libxml2) | |
700 | ("libxslt" ,libxslt) | |
701 | ("docbook-xml" ,docbook-xml) | |
702 | ("docbook-xsl" ,docbook-xsl) | |
703 | ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen' | |
704 | (inputs '()) | |
705 | (propagated-inputs '()) | |
706 | (arguments | |
707 | '(#:out-of-source? #t | |
708 | #:tests? #f ;it's just documentation | |
709 | #:phases (modify-phases %standard-phases | |
710 | (add-before 'configure 'chdir | |
711 | (lambda _ | |
712 | (chdir "libstdc++-v3"))) | |
713 | (add-before 'configure 'set-xsl-directory | |
714 | (lambda* (#:key inputs #:allow-other-keys) | |
715 | (let ((docbook (assoc-ref inputs "docbook-xsl"))) | |
716 | (substitute* (find-files "doc" | |
717 | "^Makefile\\.in$") | |
718 | (("@XSL_STYLE_DIR@") | |
719 | (string-append | |
720 | docbook "/xml/xsl/" | |
b7c7c03e | 721 | (strip-store-file-name docbook))))))) |
98b385d1 LC |
722 | (replace 'build |
723 | (lambda _ | |
724 | ;; XXX: There's also a 'doc-info' target, but it | |
725 | ;; relies on docbook2X, which itself relies on | |
726 | ;; DocBook 4.1.2, which is not really usable | |
727 | ;; (lacks a catalog.xml.) | |
728 | (zero? (system* "make" | |
729 | "doc-html" | |
730 | "doc-man")))) | |
731 | (replace 'install | |
732 | (lambda* (#:key outputs #:allow-other-keys) | |
733 | (let ((out (assoc-ref outputs "out"))) | |
734 | (zero? (system* "make" | |
735 | "doc-install-html" | |
736 | "doc-install-man")))))))))) | |
737 | ||
738 | (define-public libstdc++-doc-4.9 | |
739 | (make-libstdc++-doc gcc-4.9)) | |
740 | ||
629f4d2e MW |
741 | (define-public libstdc++-doc-5 |
742 | (make-libstdc++-doc gcc-5)) | |
98b385d1 | 743 | |
832abc76 LC |
744 | (define-public isl |
745 | (package | |
746 | (name "isl") | |
747 | (version "0.11.1") | |
748 | (source (origin | |
749 | (method url-fetch) | |
750 | (uri (list (string-append | |
590a4904 | 751 | "http://isl.gforge.inria.fr/isl-" |
832abc76 LC |
752 | version |
753 | ".tar.bz2") | |
754 | (string-append %gcc-infrastructure | |
755 | name "-" version ".tar.gz"))) | |
756 | (sha256 | |
757 | (base32 | |
2ff746dc EF |
758 | "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9")) |
759 | (patches (search-patches "isl-0.11.1-aarch64-support.patch")))) | |
832abc76 LC |
760 | (build-system gnu-build-system) |
761 | (inputs `(("gmp" ,gmp))) | |
590a4904 | 762 | (home-page "http://isl.gforge.inria.fr/") |
832abc76 | 763 | (synopsis |
9e771e3b LC |
764 | "Manipulating sets and relations of integer points \ |
765 | bounded by linear constraints") | |
832abc76 LC |
766 | (description |
767 | "isl is a library for manipulating sets and relations of integer points | |
35b9e423 | 768 | bounded by linear constraints. Supported operations on sets include |
832abc76 LC |
769 | intersection, union, set difference, emptiness check, convex hull, (integer) |
770 | affine hull, integer projection, computing the lexicographic minimum using | |
771 | parametric integer programming, coalescing and parametric vertex | |
35b9e423 | 772 | enumeration. It also includes an ILP solver based on generalized basis |
832abc76 LC |
773 | reduction, transitive closures on maps (which may encode infinite graphs), |
774 | dependence analysis and bounds on piecewise step-polynomials.") | |
775 | (license lgpl2.1+))) | |
776 | ||
777 | (define-public cloog | |
778 | (package | |
779 | (name "cloog") | |
780 | (version "0.18.0") | |
781 | (source | |
782 | (origin | |
783 | (method url-fetch) | |
784 | (uri (list (string-append | |
785 | "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-" | |
786 | version | |
787 | ".tar.gz") | |
788 | (string-append %gcc-infrastructure | |
789 | name "-" version ".tar.gz"))) | |
790 | (sha256 | |
791 | (base32 | |
792 | "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw")) | |
793 | (file-name (string-append name "-" version ".tar.gz")))) | |
794 | (build-system gnu-build-system) | |
795 | (inputs `(("gmp" ,gmp) | |
796 | ("isl" ,isl))) | |
797 | (arguments '(#:configure-flags '("--with-isl=system"))) | |
798 | (home-page "http://www.cloog.org/") | |
9e771e3b | 799 | (synopsis "Library to generate code for scanning Z-polyhedra") |
832abc76 LC |
800 | (description |
801 | "CLooG is a free software library to generate code for scanning | |
802 | Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that | |
803 | reaches each integral point of one or more parameterized polyhedra. | |
804 | CLooG has been originally written to solve the code generation problem | |
805 | for optimizing compilers based on the polytope model. Nevertheless it | |
806 | is used now in various area e.g., to build control automata for | |
807 | high-level synthesis or to find the best polynomial approximation of a | |
808 | function. CLooG may help in any situation where scanning polyhedra | |
809 | matters. While the user has full control on generated code quality, | |
810 | CLooG is designed to avoid control overhead and to produce a very | |
811 | effective code.") | |
812 | (license gpl2+))) | |
5c126b64 | 813 | |
50c7a1e2 LC |
814 | (define-public gnu-c-manual |
815 | (package | |
816 | (name "gnu-c-manual") | |
d35f8c7c | 817 | (version "0.2.5") |
50c7a1e2 LC |
818 | (source (origin |
819 | (method url-fetch) | |
820 | (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-" | |
821 | version ".tar.gz")) | |
822 | (sha256 | |
823 | (base32 | |
d35f8c7c | 824 | "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys")))) |
50c7a1e2 LC |
825 | (build-system gnu-build-system) |
826 | (native-inputs `(("texinfo" ,texinfo))) | |
827 | (arguments | |
828 | '(#:phases (modify-phases %standard-phases | |
829 | (delete 'configure) | |
830 | (delete 'check) | |
831 | (replace 'build | |
832 | (lambda _ | |
833 | (zero? (system* "make" | |
834 | "gnu-c-manual.info" | |
835 | "gnu-c-manual.html")))) | |
836 | (replace 'install | |
837 | (lambda* (#:key outputs #:allow-other-keys) | |
838 | (let* ((out (assoc-ref outputs "out")) | |
839 | (info (string-append out "/share/info")) | |
840 | (html (string-append | |
841 | out "/share/doc/gnu-c-manual"))) | |
842 | (mkdir-p info) | |
843 | (mkdir-p html) | |
844 | ||
845 | (for-each (lambda (file) | |
846 | (copy-file file | |
847 | (string-append info "/" | |
848 | file))) | |
849 | (find-files "." "\\.info(-[0-9])?$")) | |
850 | (for-each (lambda (file) | |
851 | (copy-file file | |
852 | (string-append html "/" | |
853 | file))) | |
854 | (find-files "." "\\.html$")) | |
855 | #t)))))) | |
856 | (synopsis "Reference manual for the C programming language") | |
857 | (description | |
858 | "This is a reference manual for the C programming language, as | |
859 | implemented by the GNU C Compiler (gcc). As a reference, it is not intended | |
860 | to be a tutorial of the language. Rather, it outlines all of the constructs | |
861 | of the language. Library functions are not included.") | |
862 | (home-page "http://www.gnu.org/software/gnu-c-manual") | |
863 | (license fdl1.3+))) |