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