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