gnu: guix: Update development snapshot to 71e2065.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
CommitLineData
e9c0b944 1;;; GNU Guix --- Functional package management for GNU
61af1014 2;;; Copyright © 2012, 2013, 2014, 2015 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>
b431e3a0 6;;; Copyright © 2015 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)
98b385d1
LC
32 #:use-module (gnu packages doxygen)
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
LC
155
156 ;; GCC is one of the few packages that doesn't ship .info files.
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"))
7e35b9dd 331 (patches (list (search-patch "gcc-arm-link-spec-fix.patch")))))))
3b401612 332
571aa6cd 333(define-public gcc-4.9
7e35b9dd 334 (package (inherit gcc-4.8)
6f317fa3 335 (version "4.9.3")
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
6f317fa3
MW
342 "0zmnm00d2a1hsd41g34bhvxzvxisa2l584q3p447bd91lfjv4ci3"))
343 (patches (list (search-patch "gcc-libvtv-runpath.patch")))))))
571aa6cd 344
629f4d2e 345(define-public gcc-5
7e35b9dd 346 (package (inherit gcc-4.9)
b431e3a0 347 (version "5.3.0")
60e2d5fe 348 (source (origin
7e35b9dd
LC
349 (method url-fetch)
350 (uri (string-append "mirror://gnu/gcc/gcc-"
351 version "/gcc-" version ".tar.bz2"))
352 (sha256
353 (base32
b431e3a0 354 "1ny4smkp5bzs3cp8ss7pl6lk8yss0d9m4av1mvdp72r1x695akxq"))
9a7143b7 355 (patches (list (search-patch "gcc-5.0-libvtv-runpath.patch")))))))
60e2d5fe 356
eed67cbb
RW
357(define-public gcc gcc-4.9)
358
d0abf829
LC
359(define-public (make-libstdc++ gcc)
360 "Return a libstdc++ package based on GCC. The primary use case is when
361using compilers other than GCC."
362 (package
363 (inherit gcc)
364 (name "libstdc++")
365 (arguments
366 `(#:out-of-source? #t
367 #:phases (alist-cons-before
368 'configure 'chdir
369 (lambda _
370 (chdir "libstdc++-v3"))
371 %standard-phases)
372 #:configure-flags `("--disable-libstdcxx-pch"
373 ,(string-append "--with-gxx-include-dir="
374 (assoc-ref %outputs "out")
375 "/include"))))
376 (outputs '("out" "debug"))
377 (inputs '())
378 (native-inputs '())
379 (propagated-inputs '())
380 (synopsis "GNU C++ standard library")))
381
382(define-public libstdc++-4.9
383 (make-libstdc++ gcc-4.9))
384
2b6b6d13
RW
385(define (make-libiberty gcc)
386 "Return a libiberty package based on GCC."
387 (package
388 (inherit gcc)
389 (name "libiberty")
390 (arguments
391 `(#:out-of-source? #t
392 #:phases
393 (modify-phases %standard-phases
394 (add-before 'configure 'chdir
395 (lambda _
396 (chdir "libiberty")
397 #t))
398 (replace
399 'install
400 (lambda* (#:key outputs #:allow-other-keys)
401 (let* ((out (assoc-ref outputs "out"))
402 (lib (string-append out "/lib/"))
403 (include (string-append out "/include/")))
404 (mkdir-p lib)
405 (mkdir-p include)
406 (copy-file "libiberty.a"
407 (string-append lib "libiberty.a"))
408 (copy-file "../include/libiberty.h"
409 (string-append include "libiberty.h"))
410 #t))))))
411 (inputs '())
412 (outputs '("out"))
413 (native-inputs '())
414 (propagated-inputs '())
415 (synopsis "Collection of subroutines used by various GNU programs")))
416
417(define-public libiberty
418 (make-libiberty gcc))
419
009b53fd
LC
420(define* (custom-gcc gcc name languages
421 #:optional
422 (search-paths (package-native-search-paths gcc))
423 #:key (separate-lib-output? #t))
424 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
425as the 'native-search-paths' field."
fdd6c726
NK
426 (package (inherit gcc)
427 (name name)
c4df90a5
MW
428 (outputs (if separate-lib-output?
429 (package-outputs gcc)
430 (delete "lib" (package-outputs gcc))))
009b53fd 431 (native-search-paths search-paths)
fdd6c726
NK
432 (arguments
433 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
434 (guix build utils)
435 (ice-9 regex)
436 (srfi srfi-1)
437 (srfi srfi-26))
438 ,@(package-arguments gcc))
439 ((#:configure-flags flags)
440 `(cons (string-append "--enable-languages="
441 ,(string-join languages ","))
442 (remove (cut string-match "--enable-languages.*" <>)
82f145ef
RW
443 ,flags)))
444 ((#:phases phases)
445 `(modify-phases ,phases
446 (add-after 'install 'remove-broken-or-conflicting-files
447 (lambda* (#:key outputs #:allow-other-keys)
448 (for-each delete-file
449 (find-files (string-append (assoc-ref outputs "out") "/bin")
450 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc.*)"))
451 #t))))))))
fdd6c726 452
009b53fd
LC
453(define %generic-search-paths
454 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
455 ;; not considered "system headers", which means GCC can raise warnings for
456 ;; issues in those headers. 'CPATH' is the only one that works for
457 ;; front-ends not in the C family.
458 (list (search-path-specification
459 (variable "CPATH")
460 (files '("include")))
461 (search-path-specification
462 (variable "LIBRARY_PATH")
463 (files '("lib" "lib64")))))
464
fdd6c726 465(define-public gfortran-4.8
009b53fd
LC
466 (custom-gcc gcc-4.8 "gfortran" '("fortran")
467 %generic-search-paths))
fdd6c726 468
c69a8b7b 469(define-public gfortran-4.9
009b53fd
LC
470 (custom-gcc gcc-4.9 "gfortran" '("fortran")
471 %generic-search-paths))
c69a8b7b 472
eed67cbb 473(define-public gfortran
009b53fd
LC
474 (custom-gcc gcc "gfortran" '("fortran")
475 %generic-search-paths))
eed67cbb 476
e61d9e39 477(define-public gfortran-5
009b53fd
LC
478 (custom-gcc gcc-5 "gfortran" '("fortran")
479 %generic-search-paths))
e61d9e39 480
c8732e19
EF
481(define-public gccgo-4.9
482 (custom-gcc gcc-4.9 "gccgo" '("go")
009b53fd 483 %generic-search-paths
c4df90a5
MW
484 ;; Suppress the separate "lib" output, because otherwise the
485 ;; "lib" and "out" outputs would refer to each other, creating
486 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
487 #:separate-lib-output? #f))
fdd6c726 488
ed2b1c4f
AE
489(define javac.in
490 (origin
491 (method url-fetch)
492 (uri (string-append "http://sources.gentoo.org/cgi-bin/viewvc.cgi/"
61af1014
LC
493 "gentoo-x86/dev-java/gcj-jdk/files/javac.in?revision=1.1"))
494 (file-name "javac.in")
ed2b1c4f
AE
495 (sha256 (base32
496 "1c3dk4z5yfj6ic2fn3lyxs27n6pmn2wy9k0r1s17lnkf1bzkrciv"))))
497
397dbde8
RW
498(define-public gcj
499 (package (inherit gcc)
74574fd1
RW
500 (name "gcj")
501 (inputs
502 `(("fastjar" ,fastjar)
503 ("perl" ,perl)
ed2b1c4f 504 ("javac.in" ,javac.in)
397dbde8
RW
505 ("ecj-bootstrap" ,ecj-bootstrap)
506 ,@(package-inputs gcc)))
c364a287
RW
507 (native-inputs
508 `(("dejagnu" ,dejagnu)
509 ,@(package-native-inputs gcc)))
009b53fd
LC
510 (native-search-paths %generic-search-paths)
511
74574fd1
RW
512 ;; Suppress the separate "lib" output, because otherwise the
513 ;; "lib" and "out" outputs would refer to each other, creating
514 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
515 (outputs
397dbde8 516 (delete "lib" (package-outputs gcc)))
74574fd1
RW
517 (arguments
518 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
519 (guix build utils)
520 (ice-9 regex)
521 (srfi srfi-1)
522 (srfi srfi-26))
c364a287
RW
523 #:test-target "check-target-libjava"
524 ,@(package-arguments gcc))
525 ((#:tests? _) #t)
74574fd1
RW
526 ((#:configure-flags flags)
527 `(let ((ecj (assoc-ref %build-inputs "ecj-bootstrap")))
528 `("--enable-java-home"
529 "--enable-gjdoc"
530 ,(string-append "--with-ecj-jar=" ecj)
531 "--enable-languages=java"
532 ,@(remove (cut string-match "--enable-languages.*" <>)
533 ,flags))))
ad12c43e
RW
534 ((#:phases phases)
535 `(modify-phases ,phases
536 (add-after
537 'unpack 'add-lib-output-to-rpath
538 (lambda _
539 (substitute* "libjava/Makefile.in"
540 (("libgcj_bc_dummy_LINK = .* -shared" line)
541 (string-append line " -Wl,-rpath=$(libdir)"))
542 (("libgcj(_bc)?_la_LDFLAGS =" ldflags _)
543 (string-append ldflags " -Wl,-rpath=$(libdir)")))))
544 (add-after
545 'install 'install-javac-and-javap-wrappers
546 (lambda _
547 (let* ((javac (assoc-ref %build-inputs "javac.in"))
548 (ecj (assoc-ref %build-inputs "ecj-bootstrap"))
549 (gcj (assoc-ref %outputs "out"))
550 (gcjbin (string-append gcj "/bin/"))
551 (jvm (string-append gcj "/lib/jvm/"))
552 (target (string-append jvm "/bin/javac")))
553
554 (symlink (string-append gcjbin "jcf-dump")
555 (string-append jvm "/bin/javap"))
556
557 (copy-file ecj (string-append gcj "/share/java/ecj.jar"))
558
559 ;; Create javac wrapper from the template javac.in by
560 ;; replacing the @VARIABLES@ with paths.
561 (copy-file javac target)
562 (patch-shebang target)
563 (substitute* target
564 (("@JAVA@")
565 (string-append jvm "/bin/java"))
566 (("@ECJ_JAR@")
567 (string-append gcj "/share/java/ecj.jar"))
568 (("@RT_JAR@")
569 (string-append jvm "/jre/lib/rt.jar"))
570 (("@TOOLS_JAR@")
571 (string-append jvm "/lib/tools.jar")))
572 (chmod target #o755)
573 #t)))
574 (add-after
5f6887e8
RW
575 'install 'remove-broken-or-conflicting-files
576 (lambda _
577 (let ((out (assoc-ref %outputs "out")))
578 (for-each
579 delete-file
580 (append (find-files (string-append out "/lib/jvm/jre/lib")
581 "libjawt.so")
582 (find-files (string-append out "/bin")
583 ".*(c\\+\\+|cpp|g\\+\\+|gcc.*)"))))
ad12c43e 584 #t))))))))
74574fd1 585
397dbde8 586(define ecj-bootstrap
74574fd1
RW
587 (origin
588 (method url-fetch)
397dbde8 589 (uri "ftp://sourceware.org/pub/java/ecj-4.9.jar")
74574fd1
RW
590 (sha256
591 (base32
397dbde8 592 "1k9lgm3qamf6zy534pa2zwskr8mpiqrngbv1vw9j4y1ghrdyf1lm"))))
74574fd1 593
fdd6c726 594(define-public gcc-objc-4.8
009b53fd
LC
595 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
596 (list (search-path-specification
597 (variable "OBJC_INCLUDE_PATH")
598 (files '("include")))
599 (search-path-specification
600 (variable "LIBRARY_PATH")
601 (files '("lib" "lib64"))))))
fdd6c726
NK
602
603(define-public gcc-objc++-4.8
009b53fd
LC
604 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
605 (list (search-path-specification
606 (variable "OBJCPLUS_INCLUDE_PATH")
607 (files '("include")))
608 (search-path-specification
609 (variable "LIBRARY_PATH")
610 (files '("lib" "lib64"))))))
fdd6c726 611
98b385d1
LC
612(define (make-libstdc++-doc gcc)
613 "Return a package with the libstdc++ documentation for GCC."
614 (package
615 (inherit gcc)
616 (name "libstdc++-doc")
617 (version (package-version gcc))
618 (synopsis "GNU libstdc++ documentation")
619 (outputs '("out"))
620 (native-inputs `(("doxygen" ,doxygen)
621 ("texinfo" ,texinfo)
622 ("libxml2" ,libxml2)
623 ("libxslt" ,libxslt)
624 ("docbook-xml" ,docbook-xml)
625 ("docbook-xsl" ,docbook-xsl)
626 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
627 (inputs '())
628 (propagated-inputs '())
629 (arguments
630 '(#:out-of-source? #t
631 #:tests? #f ;it's just documentation
632 #:phases (modify-phases %standard-phases
633 (add-before 'configure 'chdir
634 (lambda _
635 (chdir "libstdc++-v3")))
636 (add-before 'configure 'set-xsl-directory
637 (lambda* (#:key inputs #:allow-other-keys)
638 (let ((docbook (assoc-ref inputs "docbook-xsl")))
639 (substitute* (find-files "doc"
640 "^Makefile\\.in$")
641 (("@XSL_STYLE_DIR@")
642 (string-append
643 docbook "/xml/xsl/"
b7c7c03e 644 (strip-store-file-name docbook)))))))
98b385d1
LC
645 (replace 'build
646 (lambda _
647 ;; XXX: There's also a 'doc-info' target, but it
648 ;; relies on docbook2X, which itself relies on
649 ;; DocBook 4.1.2, which is not really usable
650 ;; (lacks a catalog.xml.)
651 (zero? (system* "make"
652 "doc-html"
653 "doc-man"))))
654 (replace 'install
655 (lambda* (#:key outputs #:allow-other-keys)
656 (let ((out (assoc-ref outputs "out")))
657 (zero? (system* "make"
658 "doc-install-html"
659 "doc-install-man"))))))))))
660
661(define-public libstdc++-doc-4.9
662 (make-libstdc++-doc gcc-4.9))
663
629f4d2e
MW
664(define-public libstdc++-doc-5
665 (make-libstdc++-doc gcc-5))
98b385d1 666
832abc76
LC
667(define-public isl
668 (package
669 (name "isl")
670 (version "0.11.1")
671 (source (origin
672 (method url-fetch)
673 (uri (list (string-append
590a4904 674 "http://isl.gforge.inria.fr/isl-"
832abc76
LC
675 version
676 ".tar.bz2")
677 (string-append %gcc-infrastructure
678 name "-" version ".tar.gz")))
679 (sha256
680 (base32
681 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))))
682 (build-system gnu-build-system)
683 (inputs `(("gmp" ,gmp)))
590a4904 684 (home-page "http://isl.gforge.inria.fr/")
832abc76 685 (synopsis
9e771e3b
LC
686 "Manipulating sets and relations of integer points \
687bounded by linear constraints")
832abc76
LC
688 (description
689 "isl is a library for manipulating sets and relations of integer points
35b9e423 690bounded by linear constraints. Supported operations on sets include
832abc76
LC
691intersection, union, set difference, emptiness check, convex hull, (integer)
692affine hull, integer projection, computing the lexicographic minimum using
693parametric integer programming, coalescing and parametric vertex
35b9e423 694enumeration. It also includes an ILP solver based on generalized basis
832abc76
LC
695reduction, transitive closures on maps (which may encode infinite graphs),
696dependence analysis and bounds on piecewise step-polynomials.")
697 (license lgpl2.1+)))
698
699(define-public cloog
700 (package
701 (name "cloog")
702 (version "0.18.0")
703 (source
704 (origin
705 (method url-fetch)
706 (uri (list (string-append
707 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
708 version
709 ".tar.gz")
710 (string-append %gcc-infrastructure
711 name "-" version ".tar.gz")))
712 (sha256
713 (base32
714 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
715 (file-name (string-append name "-" version ".tar.gz"))))
716 (build-system gnu-build-system)
717 (inputs `(("gmp" ,gmp)
718 ("isl" ,isl)))
719 (arguments '(#:configure-flags '("--with-isl=system")))
720 (home-page "http://www.cloog.org/")
9e771e3b 721 (synopsis "Library to generate code for scanning Z-polyhedra")
832abc76
LC
722 (description
723 "CLooG is a free software library to generate code for scanning
724Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
725reaches each integral point of one or more parameterized polyhedra.
726CLooG has been originally written to solve the code generation problem
727for optimizing compilers based on the polytope model. Nevertheless it
728is used now in various area e.g., to build control automata for
729high-level synthesis or to find the best polynomial approximation of a
730function. CLooG may help in any situation where scanning polyhedra
731matters. While the user has full control on generated code quality,
732CLooG is designed to avoid control overhead and to produce a very
733effective code.")
734 (license gpl2+)))
5c126b64 735
50c7a1e2
LC
736(define-public gnu-c-manual
737 (package
738 (name "gnu-c-manual")
739 (version "0.2.4")
740 (source (origin
741 (method url-fetch)
742 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
743 version ".tar.gz"))
744 (sha256
745 (base32
746 "0cf4503shr7hxkbrjfi9dky6q2lqk95bgbgbjmvj2s2x312kakd9"))))
747 (build-system gnu-build-system)
748 (native-inputs `(("texinfo" ,texinfo)))
749 (arguments
750 '(#:phases (modify-phases %standard-phases
751 (delete 'configure)
752 (delete 'check)
753 (replace 'build
754 (lambda _
755 (zero? (system* "make"
756 "gnu-c-manual.info"
757 "gnu-c-manual.html"))))
758 (replace 'install
759 (lambda* (#:key outputs #:allow-other-keys)
760 (let* ((out (assoc-ref outputs "out"))
761 (info (string-append out "/share/info"))
762 (html (string-append
763 out "/share/doc/gnu-c-manual")))
764 (mkdir-p info)
765 (mkdir-p html)
766
767 (for-each (lambda (file)
768 (copy-file file
769 (string-append info "/"
770 file)))
771 (find-files "." "\\.info(-[0-9])?$"))
772 (for-each (lambda (file)
773 (copy-file file
774 (string-append html "/"
775 file)))
776 (find-files "." "\\.html$"))
777 #t))))))
778 (synopsis "Reference manual for the C programming language")
779 (description
780 "This is a reference manual for the C programming language, as
781implemented by the GNU C Compiler (gcc). As a reference, it is not intended
782to be a tutorial of the language. Rather, it outlines all of the constructs
783of the language. Library functions are not included.")
784 (home-page "http://www.gnu.org/software/gnu-c-manual")
785 (license fdl1.3+)))