gnu: python-pandas: Fix build on 32-bit.
[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 ;;;
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)
24 #:use-module ((guix licenses)
25 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
26 #:use-module (gnu packages)
27 #:use-module (gnu packages bootstrap)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages multiprecision)
30 #:use-module (gnu packages texinfo)
31 #:use-module (gnu packages dejagnu)
32 #:use-module (gnu packages documentation)
33 #:use-module (gnu packages xml)
34 #:use-module (gnu packages docbook)
35 #:use-module (gnu packages graphviz)
36 #:use-module (gnu packages elf)
37 #:use-module (gnu packages perl)
38 #:use-module (guix packages)
39 #:use-module (guix download)
40 #:use-module (guix build-system gnu)
41 #:use-module (guix build-system trivial)
42 #:use-module (guix utils)
43 #:use-module (srfi srfi-1)
44 #:use-module (ice-9 regex))
45
46 (define %gcc-infrastructure
47 ;; Base URL for GCC's infrastructure.
48 "mirror://gcc/infrastructure/")
49
50 (define (gcc-configure-flags-for-triplet target)
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"))
60
61 ((string-match "^arm.*-gnueabihf$" target)
62 '("--with-arch=armv7-a"
63 "--with-float=hard"
64 "--with-mode=thumb"
65 "--with-fpu=neon"))
66
67 (else
68 ;; TODO: Add `arm.*-gnueabi', etc.
69 '())))
70
71 (define-public gcc-4.7
72 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
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 '()))))
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))))
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"
103 "--with-system-zlib"
104
105 ;; No pre-compiled libstdc++ headers, to save space.
106 "--disable-libstdcxx-pch"
107
108 "--with-local-prefix=/no-gcc-local-prefix"
109
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
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
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))
129
130 (maybe-target-tools))))))
131 (package
132 (name "gcc")
133 (version "4.7.4")
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
140 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))))
141 (build-system gnu-build-system)
142
143 ;; Separate out the run-time support libraries because all the
144 ;; dynamic-linked objects depend on it.
145 (outputs '("out" ;commands, etc. (60+ MiB)
146 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
147 "debug")) ;debug symbols of run-time libraries
148
149 (inputs `(("gmp" ,gmp)
150 ("mpfr" ,mpfr)
151 ("mpc" ,mpc)
152 ("isl" ,isl)
153 ("cloog" ,cloog)
154 ("libelf" ,libelf)
155 ("zlib" ,zlib)))
156
157 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
158 ;; Newer texinfos fail to build the manual, so we use an older one.
159 (native-inputs `(("texinfo" ,texinfo-5)))
160
161 (arguments
162 `(#:out-of-source? #t
163 #:configure-flags ,(configure-flags)
164 #:make-flags
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")))))
189
190 #:tests? #f
191
192 #:phases
193 (alist-cons-before
194 'configure 'pre-configure
195 (lambda* (#:key inputs outputs #:allow-other-keys)
196 (let ((libdir ,(libdir))
197 (libc (assoc-ref inputs "libc")))
198 (when libc
199 ;; The following is not performed for `--without-headers'
200 ;; cross-compiler builds.
201
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"
207 "^linux(64|-elf|-eabi)?\\.h$")
208 (("(#define GLIBC_DYNAMIC_LINKER.*)\\\\\n$" _ line)
209 line)))
210 '(1 2 3))
211
212 ;; Fix the dynamic linker's file name.
213 (substitute* (find-files "gcc/config"
214 "^(linux|gnu)(64|-elf|-eabi)?\\.h$")
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"
223 "^gnu-user.*\\.h$")
224 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
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
230 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
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.
236 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
237 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
238 libc libc libdir suffix))
239 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
240 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
241 #define STANDARD_STARTFILE_PREFIX_2 \"\"
242 ~a"
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\\[\\] =.*;")
248 "static char const sed_cmd_z[] = \"sed\";"))
249
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)
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 ""))))
263
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
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"))))
287
288 (alist-cons-after
289 'configure 'post-configure
290 (lambda _
291 ;; Don't store configure flags, to avoid retaining references to
292 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
293 (substitute* "Makefile"
294 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
295 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
296 %standard-phases))))
297
298 (native-search-paths
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.
304 (list (search-path-specification
305 (variable "C_INCLUDE_PATH")
306 (files '("include")))
307 (search-path-specification
308 (variable "CPLUS_INCLUDE_PATH")
309 (files '("include")))
310 (search-path-specification
311 (variable "LIBRARY_PATH")
312 (files '("lib" "lib64")))))
313
314 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
315 (synopsis "GNU Compiler Collection")
316 (description
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
319 Go. It also includes runtime support libraries for these languages.")
320 (license gpl3+)
321 (home-page "http://gcc.gnu.org/"))))
322
323 (define-public gcc-4.8
324 (package (inherit gcc-4.7)
325 (version "4.8.5")
326 (source (origin
327 (method url-fetch)
328 (uri (string-append "mirror://gnu/gcc/gcc-"
329 version "/gcc-" version ".tar.bz2"))
330 (sha256
331 (base32
332 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
333 (patches (search-patches "gcc-arm-link-spec-fix.patch"))))))
334
335 (define-public gcc-4.9
336 (package (inherit gcc-4.7)
337 (version "4.9.4")
338 (source (origin
339 (method url-fetch)
340 (uri (string-append "mirror://gnu/gcc/gcc-"
341 version "/gcc-" version ".tar.bz2"))
342 (sha256
343 (base32
344 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
345 (patches (search-patches "gcc-arm-bug-71399.patch"
346 "gcc-libvtv-runpath.patch"))))
347 (native-inputs `(("texinfo" ,texinfo)))))
348
349 (define-public gcc-5
350 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
351 ;; them in a VPATH build.
352 (package (inherit gcc-4.9)
353 (version "5.4.0")
354 (source (origin
355 (method url-fetch)
356 (uri (string-append "mirror://gnu/gcc/gcc-"
357 version "/gcc-" version ".tar.bz2"))
358 (sha256
359 (base32
360 "0fihlcy5hnksdxk0sn6bvgnyq8gfrgs8m794b1jxwd1dxinzg3b0"))
361 (patches (search-patches "gcc-strmov-store-file-names.patch"
362 "gcc-5.0-libvtv-runpath.patch"))))))
363
364 (define-public gcc-6
365 (package
366 (inherit gcc-5)
367 (version "6.3.0")
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
374 "17xjz30jb65hcf714vn9gcxvrrji8j20xm7n33qg1ywhyzryfsph"))
375 (patches (search-patches "gcc-strmov-store-file-names.patch"
376 "gcc-5.0-libvtv-runpath.patch"))))))
377
378 ;; Note: When changing the default gcc version, update
379 ;; the gcc-toolchain-* definitions accordingly.
380 (define-public gcc gcc-4.9)
381
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
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
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."
449 (package (inherit gcc)
450 (name name)
451 (outputs (if separate-lib-output?
452 (package-outputs gcc)
453 (delete "lib" (package-outputs gcc))))
454 (native-search-paths search-paths)
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.*" <>)
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))))))))
475
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
488 (define-public gfortran-4.8
489 (custom-gcc gcc-4.8 "gfortran" '("fortran")
490 %generic-search-paths))
491
492 (define-public gfortran-4.9
493 (custom-gcc gcc-4.9 "gfortran" '("fortran")
494 %generic-search-paths))
495
496 (define-public gfortran
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)
502
503 (define-public gfortran-5
504 (custom-gcc gcc-5 "gfortran" '("fortran")
505 %generic-search-paths))
506
507 (define-public gccgo-4.9
508 (custom-gcc gcc-4.9 "gccgo" '("go")
509 %generic-search-paths
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))
514
515 (define javac.in
516 (origin
517 (method url-fetch)
518 (uri (string-append "http://sources.gentoo.org/cgi-bin/viewvc.cgi/"
519 "gentoo-x86/dev-java/gcj-jdk/files/javac.in?revision=1.1"))
520 (file-name "javac.in")
521 (sha256 (base32
522 "1c3dk4z5yfj6ic2fn3lyxs27n6pmn2wy9k0r1s17lnkf1bzkrciv"))))
523
524 (define-public gcj
525 (package (inherit gcc)
526 (name "gcj")
527 (version (package-version gcc))
528 (inputs
529 `(("fastjar" ,fastjar)
530 ("perl" ,perl)
531 ("javac.in" ,javac.in)
532 ("ecj-bootstrap" ,ecj-bootstrap)
533 ,@(package-inputs gcc)))
534 (native-inputs
535 `(("dejagnu" ,dejagnu)
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 '())
545 ,@(package-native-inputs gcc)))
546 (native-search-paths %generic-search-paths)
547
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
552 (delete "lib" (package-outputs gcc)))
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))
559 #:test-target "check-target-libjava"
560 ,@(package-arguments gcc))
561 ((#:tests? _) #t)
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))))
570 ((#:phases phases)
571 `(modify-phases ,phases
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 '())
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)")))))
588 (add-after
589 'unpack 'patch-testsuite
590 ;; dejagnu-1.6 removes the 'absolute' command
591 (lambda _
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"))
596 (substitute* "libjava/testsuite/lib/libjava.exp"
597 (("absolute") "file normalize"))
598 #t))
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
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.*)"))))
639 #t))))))))
640
641 (define ecj-bootstrap
642 (origin
643 (method url-fetch)
644 (uri "ftp://sourceware.org/pub/java/ecj-4.9.jar")
645 (sha256
646 (base32
647 "1k9lgm3qamf6zy534pa2zwskr8mpiqrngbv1vw9j4y1ghrdyf1lm"))))
648
649 (define-public gcc-objc-4.8
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"))))))
657
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
667 (define-public gcc-objc gcc-objc-4.9)
668
669 (define-public gcc-objc++-4.8
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"))))))
677
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")))
683 (search-path-specification
684 (variable "LIBRARY_PATH")
685 (files '("lib" "lib64"))))))
686
687 (define-public gcc-objc++ gcc-objc++-4.9)
688
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/"
721 (strip-store-file-name docbook)))))))
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
741 (define-public libstdc++-doc-5
742 (make-libstdc++-doc gcc-5))
743
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
751 "http://isl.gforge.inria.fr/isl-"
752 version
753 ".tar.bz2")
754 (string-append %gcc-infrastructure
755 name "-" version ".tar.gz")))
756 (sha256
757 (base32
758 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
759 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))
760 (build-system gnu-build-system)
761 (inputs `(("gmp" ,gmp)))
762 (home-page "http://isl.gforge.inria.fr/")
763 (synopsis
764 "Manipulating sets and relations of integer points \
765 bounded by linear constraints")
766 (description
767 "isl is a library for manipulating sets and relations of integer points
768 bounded by linear constraints. Supported operations on sets include
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
772 enumeration. It also includes an ILP solver based on generalized basis
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/")
799 (synopsis "Library to generate code for scanning Z-polyhedra")
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+)))
813
814 (define-public gnu-c-manual
815 (package
816 (name "gnu-c-manual")
817 (version "0.2.5")
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
824 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
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+)))