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