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