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