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