Merge branch '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 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 "ftp://gcc.gnu.org/pub/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 (native-inputs `(("texinfo" ,texinfo)))
159
160 (arguments
161 `(#:out-of-source? #t
162 #:configure-flags ,(configure-flags)
163 #:make-flags
164 ;; None of the flags below are needed when doing a Canadian cross.
165 ;; TODO: Simplify this.
166 ,(if (%current-target-system)
167 (if stripped?
168 ''("CFLAGS=-g0 -O2")
169 ''())
170 `(let* ((libc (assoc-ref %build-inputs "libc"))
171 (libc-native (or (assoc-ref %build-inputs "libc-native")
172 libc)))
173 `(,@(if libc
174 (list (string-append "LDFLAGS_FOR_TARGET="
175 "-B" libc "/lib "
176 "-Wl,-dynamic-linker "
177 "-Wl," libc
178 ,(glibc-dynamic-linker)))
179 '())
180
181 ;; Native programs like 'genhooks' also need that right.
182 ,(string-append "LDFLAGS="
183 "-Wl,-rpath=" libc-native "/lib "
184 "-Wl,-dynamic-linker "
185 "-Wl," libc-native ,(glibc-dynamic-linker))
186 ,(string-append "BOOT_CFLAGS=-O2 "
187 ,(if stripped? "-g0" "-g")))))
188
189 #:tests? #f
190
191 #:phases
192 (alist-cons-before
193 'configure 'pre-configure
194 (lambda* (#:key inputs outputs #:allow-other-keys)
195 (let ((libdir ,(libdir))
196 (libc (assoc-ref inputs "libc")))
197 (when libc
198 ;; The following is not performed for `--without-headers'
199 ;; cross-compiler builds.
200
201 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
202 ;; single line, to allow the next step to work properly.
203 (for-each
204 (lambda (x)
205 (substitute* (find-files "gcc/config"
206 "^linux(64|-elf|-eabi)?\\.h$")
207 (("(#define GLIBC_DYNAMIC_LINKER.*)\\\\\n$" _ line)
208 line)))
209 '(1 2 3))
210
211 ;; Fix the dynamic linker's file name.
212 (substitute* (find-files "gcc/config"
213 "^(linux|gnu)(64|-elf|-eabi)?\\.h$")
214 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
215 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
216 suffix
217 (string-append libc ,(glibc-dynamic-linker)))))
218
219 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
220 ;; `crt{begin,end}.o', which come with GCC.
221 (substitute* (find-files "gcc/config"
222 "^gnu-user.*\\.h$")
223 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
224 ;; Help libgcc_s.so be found (see also below.) Always use
225 ;; '-lgcc_s' so that libgcc_s.so is always found by those
226 ;; programs that use 'pthread_cancel' (glibc dlopens
227 ;; libgcc_s.so when pthread_cancel support is needed, but
228 ;; having it in the application's RUNPATH isn't enough; see
229 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
230 ;;
231 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
232 ;; later phase of %gcc-static. If you change the string
233 ;; below, make sure to update the relevant code in
234 ;; %gcc-static package as needed.
235 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
236 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
237 libc libc libdir suffix))
238 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
239 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
240 #define STANDARD_STARTFILE_PREFIX_2 \"\"
241 ~a"
242 libc line))))
243
244 ;; Don't retain a dependency on the build-time sed.
245 (substitute* "fixincludes/fixincl.x"
246 (("static char const sed_cmd_z\\[\\] =.*;")
247 "static char const sed_cmd_z[] = \"sed\";"))
248
249 (when (file-exists? "libbacktrace")
250 ;; GCC 4.8+ comes with libbacktrace. By default it builds
251 ;; with -Werror, which fails with a -Wcast-qual error in glibc
252 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
253 (substitute* "libbacktrace/configure"
254 (("WARN_FLAGS=(.*)-Werror" _ flags)
255 (string-append "WARN_FLAGS=" flags)))
256
257 (when (file-exists? "libsanitizer/libbacktrace")
258 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
259 (substitute* "libsanitizer/libbacktrace/Makefile.in"
260 (("-Werror")
261 ""))))
262
263 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
264 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
265 ;; and <http://bugs.gnu.org/20358>.
266 (substitute* "libstdc++-v3/src/Makefile.in"
267 (("^OPT_LDFLAGS = ")
268 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
269
270 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
271 ;; circularity between "out" and "lib". (Note:
272 ;; --with-python-dir is useless because it imposes $(prefix) as
273 ;; the parent directory.)
274 (substitute* "libstdc++-v3/python/Makefile.in"
275 (("pythondir = .*$")
276 (string-append "pythondir = " libdir "/share"
277 "/gcc-$(gcc_version)/python\n")))
278
279 ;; Avoid another circularity between the outputs: this #define
280 ;; ends up in auto-host.h in the "lib" output, referring to
281 ;; "out". (This variable is used to augment cpp's search path,
282 ;; but there's nothing useful to look for here.)
283 (substitute* "gcc/config.in"
284 (("PREFIX_INCLUDE_DIR")
285 "PREFIX_INCLUDE_DIR_isnt_necessary_here"))))
286
287 (alist-cons-after
288 'configure 'post-configure
289 (lambda _
290 ;; Don't store configure flags, to avoid retaining references to
291 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
292 (substitute* "Makefile"
293 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
294 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
295 %standard-phases))))
296
297 (native-search-paths
298 ;; Use the language-specific variables rather than 'CPATH' because they
299 ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
300 ;; The intent is to allow headers that are in the search path to be
301 ;; treated as "system headers" (headers exempt from warnings) just like
302 ;; the typical /usr/include headers on an FHS system.
303 (list (search-path-specification
304 (variable "C_INCLUDE_PATH")
305 (files '("include")))
306 (search-path-specification
307 (variable "CPLUS_INCLUDE_PATH")
308 (files '("include")))
309 (search-path-specification
310 (variable "LIBRARY_PATH")
311 (files '("lib" "lib64")))))
312
313 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
314 (synopsis "GNU Compiler Collection")
315 (description
316 "GCC is the GNU Compiler Collection. It provides compiler front-ends
317 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
318 Go. It also includes runtime support libraries for these languages.")
319 (license gpl3+)
320 (home-page "http://gcc.gnu.org/"))))
321
322 (define-public gcc-4.8
323 (package (inherit gcc-4.7)
324 (version "4.8.5")
325 (source (origin
326 (method url-fetch)
327 (uri (string-append "mirror://gnu/gcc/gcc-"
328 version "/gcc-" version ".tar.bz2"))
329 (sha256
330 (base32
331 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
332 (patches (search-patches "gcc-arm-link-spec-fix.patch"))))
333
334 ;; Texinfo 6.3 fails to build the manual:
335 ;; ../../gcc-4.8.5/gcc/doc/gcc.texi:208: no matching `@end tex'
336 ;; Use an older one.
337 (native-inputs `(("texinfo" ,texinfo-5)))))
338
339 (define-public gcc-4.9
340 (package (inherit gcc-4.7)
341 (version "4.9.4")
342 (source (origin
343 (method url-fetch)
344 (uri (string-append "mirror://gnu/gcc/gcc-"
345 version "/gcc-" version ".tar.bz2"))
346 (sha256
347 (base32
348 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
349 (patches (search-patches "gcc-arm-bug-71399.patch"
350 "gcc-libvtv-runpath.patch"))))))
351
352 (define-public gcc-5
353 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
354 ;; them in a VPATH build.
355 (package (inherit gcc-4.9)
356 (version "5.4.0")
357 (source (origin
358 (method url-fetch)
359 (uri (string-append "mirror://gnu/gcc/gcc-"
360 version "/gcc-" version ".tar.bz2"))
361 (sha256
362 (base32
363 "0fihlcy5hnksdxk0sn6bvgnyq8gfrgs8m794b1jxwd1dxinzg3b0"))
364 (patches (search-patches "gcc-5.0-libvtv-runpath.patch"))))))
365
366 (define-public gcc-6
367 (package
368 (inherit gcc-5)
369 (version "6.2.0")
370 (source (origin
371 (method url-fetch)
372 (uri (string-append "mirror://gnu/gcc/gcc-"
373 version "/gcc-" version ".tar.bz2"))
374 (sha256
375 (base32
376 "1idpf43988v1a6i8lw9ak1r7igcfg1bm5kn011iydlr2qygmhi4r"))
377 (patches (search-patches "gcc-5.0-libvtv-runpath.patch"))))))
378
379 ;; Note: When changing the default gcc version, update
380 ;; the gcc-toolchain-* definitions accordingly.
381 (define-public gcc gcc-4.9)
382
383 (define-public (make-libstdc++ gcc)
384 "Return a libstdc++ package based on GCC. The primary use case is when
385 using compilers other than GCC."
386 (package
387 (inherit gcc)
388 (name "libstdc++")
389 (arguments
390 `(#:out-of-source? #t
391 #:phases (alist-cons-before
392 'configure 'chdir
393 (lambda _
394 (chdir "libstdc++-v3"))
395 %standard-phases)
396 #:configure-flags `("--disable-libstdcxx-pch"
397 ,(string-append "--with-gxx-include-dir="
398 (assoc-ref %outputs "out")
399 "/include"))))
400 (outputs '("out" "debug"))
401 (inputs '())
402 (native-inputs '())
403 (propagated-inputs '())
404 (synopsis "GNU C++ standard library")))
405
406 (define-public libstdc++-4.9
407 (make-libstdc++ gcc-4.9))
408
409 (define (make-libiberty gcc)
410 "Return a libiberty package based on GCC."
411 (package
412 (inherit gcc)
413 (name "libiberty")
414 (arguments
415 `(#:out-of-source? #t
416 #:phases
417 (modify-phases %standard-phases
418 (add-before 'configure 'chdir
419 (lambda _
420 (chdir "libiberty")
421 #t))
422 (replace
423 'install
424 (lambda* (#:key outputs #:allow-other-keys)
425 (let* ((out (assoc-ref outputs "out"))
426 (lib (string-append out "/lib/"))
427 (include (string-append out "/include/")))
428 (mkdir-p lib)
429 (mkdir-p include)
430 (copy-file "libiberty.a"
431 (string-append lib "libiberty.a"))
432 (copy-file "../include/libiberty.h"
433 (string-append include "libiberty.h"))
434 #t))))))
435 (inputs '())
436 (outputs '("out"))
437 (native-inputs '())
438 (propagated-inputs '())
439 (synopsis "Collection of subroutines used by various GNU programs")))
440
441 (define-public libiberty
442 (make-libiberty gcc))
443
444 (define* (custom-gcc gcc name languages
445 #:optional
446 (search-paths (package-native-search-paths gcc))
447 #:key (separate-lib-output? #t))
448 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
449 as the 'native-search-paths' field."
450 (package (inherit gcc)
451 (name name)
452 (outputs (if separate-lib-output?
453 (package-outputs gcc)
454 (delete "lib" (package-outputs gcc))))
455 (native-search-paths search-paths)
456 (arguments
457 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
458 (guix build utils)
459 (ice-9 regex)
460 (srfi srfi-1)
461 (srfi srfi-26))
462 ,@(package-arguments gcc))
463 ((#:configure-flags flags)
464 `(cons (string-append "--enable-languages="
465 ,(string-join languages ","))
466 (remove (cut string-match "--enable-languages.*" <>)
467 ,flags)))
468 ((#:phases phases)
469 `(modify-phases ,phases
470 (add-after 'install 'remove-broken-or-conflicting-files
471 (lambda* (#:key outputs #:allow-other-keys)
472 (for-each delete-file
473 (find-files (string-append (assoc-ref outputs "out") "/bin")
474 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc.*)"))
475 #t))))))))
476
477 (define %generic-search-paths
478 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
479 ;; not considered "system headers", which means GCC can raise warnings for
480 ;; issues in those headers. 'CPATH' is the only one that works for
481 ;; front-ends not in the C family.
482 (list (search-path-specification
483 (variable "CPATH")
484 (files '("include")))
485 (search-path-specification
486 (variable "LIBRARY_PATH")
487 (files '("lib" "lib64")))))
488
489 (define-public gfortran-4.8
490 (custom-gcc gcc-4.8 "gfortran" '("fortran")
491 %generic-search-paths))
492
493 (define-public gfortran-4.9
494 (custom-gcc gcc-4.9 "gfortran" '("fortran")
495 %generic-search-paths))
496
497 (define-public gfortran
498 (custom-gcc gcc "gfortran" '("fortran")
499 %generic-search-paths))
500
501 (define-public gfortran-5
502 (custom-gcc gcc-5 "gfortran" '("fortran")
503 %generic-search-paths))
504
505 (define-public gccgo-4.9
506 (custom-gcc gcc-4.9 "gccgo" '("go")
507 %generic-search-paths
508 ;; Suppress the separate "lib" output, because otherwise the
509 ;; "lib" and "out" outputs would refer to each other, creating
510 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
511 #:separate-lib-output? #f))
512
513 (define javac.in
514 (origin
515 (method url-fetch)
516 (uri (string-append "http://sources.gentoo.org/cgi-bin/viewvc.cgi/"
517 "gentoo-x86/dev-java/gcj-jdk/files/javac.in?revision=1.1"))
518 (file-name "javac.in")
519 (sha256 (base32
520 "1c3dk4z5yfj6ic2fn3lyxs27n6pmn2wy9k0r1s17lnkf1bzkrciv"))))
521
522 (define-public gcj
523 (package (inherit gcc)
524 (name "gcj")
525 (inputs
526 `(("fastjar" ,fastjar)
527 ("perl" ,perl)
528 ("javac.in" ,javac.in)
529 ("ecj-bootstrap" ,ecj-bootstrap)
530 ,@(package-inputs gcc)))
531 (native-inputs
532 `(("dejagnu" ,dejagnu)
533 ,@(package-native-inputs gcc)))
534 (native-search-paths %generic-search-paths)
535
536 ;; Suppress the separate "lib" output, because otherwise the
537 ;; "lib" and "out" outputs would refer to each other, creating
538 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
539 (outputs
540 (delete "lib" (package-outputs gcc)))
541 (arguments
542 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
543 (guix build utils)
544 (ice-9 regex)
545 (srfi srfi-1)
546 (srfi srfi-26))
547 #:test-target "check-target-libjava"
548 ,@(package-arguments gcc))
549 ((#:tests? _) #t)
550 ((#:configure-flags flags)
551 `(let ((ecj (assoc-ref %build-inputs "ecj-bootstrap")))
552 `("--enable-java-home"
553 "--enable-gjdoc"
554 ,(string-append "--with-ecj-jar=" ecj)
555 "--enable-languages=java"
556 ,@(remove (cut string-match "--enable-languages.*" <>)
557 ,flags))))
558 ((#:phases phases)
559 `(modify-phases ,phases
560 (add-after
561 'unpack 'add-lib-output-to-rpath
562 (lambda _
563 (substitute* "libjava/Makefile.in"
564 (("libgcj_bc_dummy_LINK = .* -shared" line)
565 (string-append line " -Wl,-rpath=$(libdir)"))
566 (("libgcj(_bc)?_la_LDFLAGS =" ldflags _)
567 (string-append ldflags " -Wl,-rpath=$(libdir)")))))
568 (add-after
569 'unpack 'patch-testsuite
570 ;; dejagnu-1.6 removes the 'absolute' command
571 (lambda _
572 (substitute* "libjava/testsuite/lib/libjava.exp"
573 (("absolute") "file normalize"))
574 #t))
575 (add-after
576 'install 'install-javac-and-javap-wrappers
577 (lambda _
578 (let* ((javac (assoc-ref %build-inputs "javac.in"))
579 (ecj (assoc-ref %build-inputs "ecj-bootstrap"))
580 (gcj (assoc-ref %outputs "out"))
581 (gcjbin (string-append gcj "/bin/"))
582 (jvm (string-append gcj "/lib/jvm/"))
583 (target (string-append jvm "/bin/javac")))
584
585 (symlink (string-append gcjbin "jcf-dump")
586 (string-append jvm "/bin/javap"))
587
588 (copy-file ecj (string-append gcj "/share/java/ecj.jar"))
589
590 ;; Create javac wrapper from the template javac.in by
591 ;; replacing the @VARIABLES@ with paths.
592 (copy-file javac target)
593 (patch-shebang target)
594 (substitute* target
595 (("@JAVA@")
596 (string-append jvm "/bin/java"))
597 (("@ECJ_JAR@")
598 (string-append gcj "/share/java/ecj.jar"))
599 (("@RT_JAR@")
600 (string-append jvm "/jre/lib/rt.jar"))
601 (("@TOOLS_JAR@")
602 (string-append jvm "/lib/tools.jar")))
603 (chmod target #o755)
604 #t)))
605 (add-after
606 'install 'remove-broken-or-conflicting-files
607 (lambda _
608 (let ((out (assoc-ref %outputs "out")))
609 (for-each
610 delete-file
611 (append (find-files (string-append out "/lib/jvm/jre/lib")
612 "libjawt.so")
613 (find-files (string-append out "/bin")
614 ".*(c\\+\\+|cpp|g\\+\\+|gcc.*)"))))
615 #t))))))))
616
617 (define ecj-bootstrap
618 (origin
619 (method url-fetch)
620 (uri "ftp://sourceware.org/pub/java/ecj-4.9.jar")
621 (sha256
622 (base32
623 "1k9lgm3qamf6zy534pa2zwskr8mpiqrngbv1vw9j4y1ghrdyf1lm"))))
624
625 (define-public gcc-objc-4.8
626 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
627 (list (search-path-specification
628 (variable "OBJC_INCLUDE_PATH")
629 (files '("include")))
630 (search-path-specification
631 (variable "LIBRARY_PATH")
632 (files '("lib" "lib64"))))))
633
634 (define-public gcc-objc-4.9
635 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
636 (list (search-path-specification
637 (variable "OBJC_INCLUDE_PATH")
638 (files '("include")))
639 (search-path-specification
640 (variable "LIBRARY_PATH")
641 (files '("lib" "lib64"))))))
642
643 (define-public gcc-objc gcc-objc-4.9)
644
645 (define-public gcc-objc++-4.8
646 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
647 (list (search-path-specification
648 (variable "OBJCPLUS_INCLUDE_PATH")
649 (files '("include")))
650 (search-path-specification
651 (variable "LIBRARY_PATH")
652 (files '("lib" "lib64"))))))
653
654 (define-public gcc-objc++-4.9
655 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
656 (list (search-path-specification
657 (variable "OBJCPLUS_INCLUDE_PATH")
658 (files '("include")))
659 (search-path-specification
660 (variable "LIBRARY_PATH")
661 (files '("lib" "lib64"))))))
662
663 (define-public gcc-objc++ gcc-objc++-4.9)
664
665 (define (make-libstdc++-doc gcc)
666 "Return a package with the libstdc++ documentation for GCC."
667 (package
668 (inherit gcc)
669 (name "libstdc++-doc")
670 (version (package-version gcc))
671 (synopsis "GNU libstdc++ documentation")
672 (outputs '("out"))
673 (native-inputs `(("doxygen" ,doxygen)
674 ("texinfo" ,texinfo)
675 ("libxml2" ,libxml2)
676 ("libxslt" ,libxslt)
677 ("docbook-xml" ,docbook-xml)
678 ("docbook-xsl" ,docbook-xsl)
679 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
680 (inputs '())
681 (propagated-inputs '())
682 (arguments
683 '(#:out-of-source? #t
684 #:tests? #f ;it's just documentation
685 #:phases (modify-phases %standard-phases
686 (add-before 'configure 'chdir
687 (lambda _
688 (chdir "libstdc++-v3")))
689 (add-before 'configure 'set-xsl-directory
690 (lambda* (#:key inputs #:allow-other-keys)
691 (let ((docbook (assoc-ref inputs "docbook-xsl")))
692 (substitute* (find-files "doc"
693 "^Makefile\\.in$")
694 (("@XSL_STYLE_DIR@")
695 (string-append
696 docbook "/xml/xsl/"
697 (strip-store-file-name docbook)))))))
698 (replace 'build
699 (lambda _
700 ;; XXX: There's also a 'doc-info' target, but it
701 ;; relies on docbook2X, which itself relies on
702 ;; DocBook 4.1.2, which is not really usable
703 ;; (lacks a catalog.xml.)
704 (zero? (system* "make"
705 "doc-html"
706 "doc-man"))))
707 (replace 'install
708 (lambda* (#:key outputs #:allow-other-keys)
709 (let ((out (assoc-ref outputs "out")))
710 (zero? (system* "make"
711 "doc-install-html"
712 "doc-install-man"))))))))))
713
714 (define-public libstdc++-doc-4.9
715 (make-libstdc++-doc gcc-4.9))
716
717 (define-public libstdc++-doc-5
718 (make-libstdc++-doc gcc-5))
719
720 (define-public isl
721 (package
722 (name "isl")
723 (version "0.11.1")
724 (source (origin
725 (method url-fetch)
726 (uri (list (string-append
727 "http://isl.gforge.inria.fr/isl-"
728 version
729 ".tar.bz2")
730 (string-append %gcc-infrastructure
731 name "-" version ".tar.gz")))
732 (sha256
733 (base32
734 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
735 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))
736 (build-system gnu-build-system)
737 (inputs `(("gmp" ,gmp)))
738 (home-page "http://isl.gforge.inria.fr/")
739 (synopsis
740 "Manipulating sets and relations of integer points \
741 bounded by linear constraints")
742 (description
743 "isl is a library for manipulating sets and relations of integer points
744 bounded by linear constraints. Supported operations on sets include
745 intersection, union, set difference, emptiness check, convex hull, (integer)
746 affine hull, integer projection, computing the lexicographic minimum using
747 parametric integer programming, coalescing and parametric vertex
748 enumeration. It also includes an ILP solver based on generalized basis
749 reduction, transitive closures on maps (which may encode infinite graphs),
750 dependence analysis and bounds on piecewise step-polynomials.")
751 (license lgpl2.1+)))
752
753 (define-public cloog
754 (package
755 (name "cloog")
756 (version "0.18.0")
757 (source
758 (origin
759 (method url-fetch)
760 (uri (list (string-append
761 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
762 version
763 ".tar.gz")
764 (string-append %gcc-infrastructure
765 name "-" version ".tar.gz")))
766 (sha256
767 (base32
768 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
769 (file-name (string-append name "-" version ".tar.gz"))))
770 (build-system gnu-build-system)
771 (inputs `(("gmp" ,gmp)
772 ("isl" ,isl)))
773 (arguments '(#:configure-flags '("--with-isl=system")))
774 (home-page "http://www.cloog.org/")
775 (synopsis "Library to generate code for scanning Z-polyhedra")
776 (description
777 "CLooG is a free software library to generate code for scanning
778 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
779 reaches each integral point of one or more parameterized polyhedra.
780 CLooG has been originally written to solve the code generation problem
781 for optimizing compilers based on the polytope model. Nevertheless it
782 is used now in various area e.g., to build control automata for
783 high-level synthesis or to find the best polynomial approximation of a
784 function. CLooG may help in any situation where scanning polyhedra
785 matters. While the user has full control on generated code quality,
786 CLooG is designed to avoid control overhead and to produce a very
787 effective code.")
788 (license gpl2+)))
789
790 (define-public gnu-c-manual
791 (package
792 (name "gnu-c-manual")
793 (version "0.2.5")
794 (source (origin
795 (method url-fetch)
796 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
797 version ".tar.gz"))
798 (sha256
799 (base32
800 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
801 (build-system gnu-build-system)
802 (native-inputs `(("texinfo" ,texinfo)))
803 (arguments
804 '(#:phases (modify-phases %standard-phases
805 (delete 'configure)
806 (delete 'check)
807 (replace 'build
808 (lambda _
809 (zero? (system* "make"
810 "gnu-c-manual.info"
811 "gnu-c-manual.html"))))
812 (replace 'install
813 (lambda* (#:key outputs #:allow-other-keys)
814 (let* ((out (assoc-ref outputs "out"))
815 (info (string-append out "/share/info"))
816 (html (string-append
817 out "/share/doc/gnu-c-manual")))
818 (mkdir-p info)
819 (mkdir-p html)
820
821 (for-each (lambda (file)
822 (copy-file file
823 (string-append info "/"
824 file)))
825 (find-files "." "\\.info(-[0-9])?$"))
826 (for-each (lambda (file)
827 (copy-file file
828 (string-append html "/"
829 file)))
830 (find-files "." "\\.html$"))
831 #t))))))
832 (synopsis "Reference manual for the C programming language")
833 (description
834 "This is a reference manual for the C programming language, as
835 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
836 to be a tutorial of the language. Rather, it outlines all of the constructs
837 of the language. Library functions are not included.")
838 (home-page "http://www.gnu.org/software/gnu-c-manual")
839 (license fdl1.3+)))