gnu: gcc: Add 10.1.0.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
6 ;;; Copyright © 2015, 2016, 2017, 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll@gmail.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
10 ;;; Copyright © 2020 Joseph LaFreniere <joseph@lafreniere.xyz>
11 ;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
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)
29 #:use-module ((guix licenses)
30 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
31 #:use-module (gnu packages)
32 #:use-module (gnu packages bootstrap)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages multiprecision)
35 #:use-module (gnu packages texinfo)
36 #:use-module (gnu packages dejagnu)
37 #:use-module (gnu packages documentation)
38 #:use-module (gnu packages xml)
39 #:use-module (gnu packages docbook)
40 #:use-module (gnu packages graphviz)
41 #:use-module (gnu packages elf)
42 #:use-module (gnu packages perl)
43 #:use-module (guix packages)
44 #:use-module (guix download)
45 #:use-module (guix build-system gnu)
46 #:use-module (guix build-system trivial)
47 #:use-module (guix utils)
48 #:use-module (srfi srfi-1)
49 #:use-module (ice-9 regex))
50
51 (define %gcc-infrastructure
52 ;; Base URL for GCC's infrastructure.
53 "mirror://gcc/infrastructure/")
54
55 (define (gcc-configure-flags-for-triplet target)
56 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
57
58 The purpose of this procedure is to translate extended GNU triplets---e.g.,
59 where 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"))
65
66 ((string-match "^arm.*-gnueabihf$" target)
67 '("--with-arch=armv7-a"
68 "--with-float=hard"
69 "--with-mode=thumb"
70 "--with-fpu=neon"))
71
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
80 (else
81 ;; TODO: Add `arm.*-gnueabi', etc.
82 '())))
83
84 (define-public gcc-4.7
85 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
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))
95 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
96 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
97 '()))))
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))))
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"
116 "--with-system-zlib"
117
118 ;; No pre-compiled libstdc++ headers, to save space.
119 "--disable-libstdcxx-pch"
120
121 "--with-local-prefix=/no-gcc-local-prefix"
122
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
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
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))
142
143 (maybe-target-tools))))))
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)
221 (substitute* (find-files "gcc/config"
222 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
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 \
253 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
254 libc libc libdir suffix))
255 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
256 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
257 #define STANDARD_STARTFILE_PREFIX_2 \"\"
258 ~a"
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 \
267 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
268 libc libc libdir suffix))
269 (("#define STARTFILE_LINUX_SPEC.*$" line)
270 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
271 #define STANDARD_STARTFILE_PREFIX_2 \"\"
272 ~a"
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
354 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
355 Go. It also includes runtime support libraries for these languages.")
356 (license gpl3+)
357 (supported-systems (delete "aarch64-linux" %supported-systems))
358 (home-page "https://gcc.gnu.org/")))))
359
360 (define-public gcc-4.8
361 (package (inherit gcc-4.7)
362 (version "4.8.5")
363 (source (origin
364 (method url-fetch)
365 (uri (string-append "mirror://gnu/gcc/gcc-"
366 version "/gcc-" version ".tar.bz2"))
367 (sha256
368 (base32
369 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
370 (patches (search-patches "gcc-arm-link-spec-fix.patch"
371 "gcc-4.8-libsanitizer-fix.patch"
372 "gcc-asan-missing-include.patch"
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
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))))
387 (supported-systems %supported-systems)
388 (inputs
389 `(("isl" ,isl-0.11)
390 ("cloog" ,cloog)
391 ,@(package-inputs gcc-4.7)))))
392
393 (define-public gcc-4.9
394 (package (inherit gcc-4.8)
395 (version "4.9.4")
396 (source (origin
397 (method url-fetch)
398 (uri (string-append "mirror://gnu/gcc/gcc-"
399 version "/gcc-" version ".tar.bz2"))
400 (sha256
401 (base32
402 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
403 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
404 "gcc-4.9-libsanitizer-ustat.patch"
405 "gcc-arm-bug-71399.patch"
406 "gcc-asan-missing-include.patch"
407 "gcc-libvtv-runpath.patch"
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
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))))
422 ;; Override inherited texinfo-5 with latest version.
423 (native-inputs `(("perl" ,perl) ;for manpages
424 ("texinfo" ,texinfo)))))
425
426 (define-public gcc-5
427 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
428 ;; them in a VPATH build.
429 (package (inherit gcc-4.9)
430 (version "5.5.0")
431 (source (origin
432 (method url-fetch)
433 (uri (string-append "mirror://gnu/gcc/gcc-"
434 version "/gcc-" version ".tar.xz"))
435 (sha256
436 (base32
437 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
438 (patches (search-patches "gcc-arm-bug-71399.patch"
439 "gcc-libsanitizer-ustat.patch"
440 "gcc-strmov-store-file-names.patch"
441 "gcc-5.0-libvtv-runpath.patch"
442 "gcc-5-source-date-epoch-1.patch"
443 "gcc-5-source-date-epoch-2.patch"
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
454 '(begin
455 (substitute* "libcc1/configure"
456 (("\\$gcc_cv_objdump -T")
457 "$OBJDUMP_FOR_TARGET -T"))
458 #t))))
459 (inputs
460 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
461 ("isl" ,isl-0.18)
462 ,@(package-inputs gcc-4.7)))))
463
464 (define-public gcc-6
465 (package
466 (inherit gcc-5)
467 (version "6.5.0")
468 (source (origin
469 (method url-fetch)
470 (uri (string-append "mirror://gnu/gcc/gcc-"
471 version "/gcc-" version ".tar.xz"))
472 (sha256
473 (base32
474 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
475 (patches (search-patches "gcc-strmov-store-file-names.patch"
476 "gcc-6-source-date-epoch-1.patch"
477 "gcc-6-source-date-epoch-2.patch"
478 "gcc-5.0-libvtv-runpath.patch"))))
479 (inputs
480 `(("isl" ,isl)
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")))))))
492
493 (define-public gcc-7
494 (package
495 (inherit gcc-6)
496 (version "7.4.0")
497 (source (origin
498 (method url-fetch)
499 (uri (string-append "mirror://gnu/gcc/gcc-"
500 version "/gcc-" version ".tar.xz"))
501 (sha256
502 (base32
503 "0lgy170b0pp60j9cczqkmaqyjjb584vfamj4c30swd7k0j6y5pgd"))
504 (patches (search-patches "gcc-strmov-store-file-names.patch"
505 "gcc-5.0-libvtv-runpath.patch"))))
506 (description
507 "GCC is the GNU Compiler Collection. It provides compiler front-ends
508 for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
509 It also includes runtime support libraries for these languages.")))
510
511 (define-public gcc-8
512 (package
513 (inherit gcc-7)
514 (version "8.4.0")
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
521 "1m1d3gfix56w4aq8myazzfffkl8bqcrx4jhhapnjf7qfs596w2p3"))
522 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
523 "gcc-5.0-libvtv-runpath.patch"))))))
524
525 (define-public gcc-9
526 (package
527 (inherit gcc-8)
528 (version "9.3.0")
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
535 "1la2yy27ziasyf0jvzk58y1i5b5bq2h176qil550bxhifs39gqbi"))
536 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
537 "gcc-9-asan-fix-limits-include.patch"
538 "gcc-5.0-libvtv-runpath.patch"))))))
539
540 (define-public gcc-10
541 (package
542 (inherit gcc-8)
543 (version "10.1.0")
544 (source (origin
545 (method url-fetch)
546 (uri (string-append "mirror://gnu/gcc/gcc-"
547 version "/gcc-" version ".tar.xz"))
548 (sha256
549 (base32
550 "18kyds3ss4j7in8shlsbmjafdhin400mq739d0dnyrabhhiqm2dn"))
551 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
552 "gcc-5.0-libvtv-runpath.patch"))))))
553
554 ;; Note: When changing the default gcc version, update
555 ;; the gcc-toolchain-* definitions and the gfortran definition
556 ;; accordingly.
557 (define-public gcc gcc-7)
558
559 (define-public (make-libstdc++ gcc)
560 "Return a libstdc++ package based on GCC. The primary use case is when
561 using compilers other than GCC."
562 (package
563 (inherit gcc)
564 (name "libstdc++")
565 (arguments
566 `(#:out-of-source? #t
567 #:phases (alist-cons-before
568 'configure 'chdir
569 (lambda _
570 (chdir "libstdc++-v3")
571 #t)
572 %standard-phases)
573 #:configure-flags `("--disable-libstdcxx-pch"
574 ,(string-append "--with-gxx-include-dir="
575 (assoc-ref %outputs "out")
576 "/include"))))
577 (outputs '("out" "debug"))
578 (inputs '())
579 (native-inputs '())
580 (propagated-inputs '())
581 (synopsis "GNU C++ standard library")))
582
583 (define-public libstdc++-4.9
584 (make-libstdc++ gcc-4.9))
585
586 (define (make-libiberty gcc)
587 "Return a libiberty package based on GCC."
588 (package
589 (inherit gcc)
590 (name "libiberty")
591 (arguments
592 `(#:out-of-source? #t
593 #:phases
594 (modify-phases %standard-phases
595 (add-before 'configure 'chdir
596 (lambda _
597 (chdir "libiberty")
598 #t))
599 (replace 'install
600 (lambda* (#:key outputs #:allow-other-keys)
601 (let* ((out (assoc-ref outputs "out"))
602 (lib (string-append out "/lib/"))
603 (include (string-append out "/include/")))
604 (install-file "libiberty.a" lib)
605 (install-file "../include/libiberty.h" include))
606 #t)))))
607 (inputs '())
608 (outputs '("out"))
609 (native-inputs '())
610 (propagated-inputs '())
611 (properties '())
612 (synopsis "Collection of subroutines used by various GNU programs")))
613
614 (define-public libiberty
615 (make-libiberty gcc))
616
617 (define* (custom-gcc gcc name languages
618 #:optional
619 (search-paths (package-native-search-paths gcc))
620 #:key (separate-lib-output? #t))
621 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
622 as the 'native-search-paths' field."
623 (package (inherit gcc)
624 (name name)
625 (outputs (if separate-lib-output?
626 (package-outputs gcc)
627 (delete "lib" (package-outputs gcc))))
628 (native-search-paths search-paths)
629 (properties (alist-delete 'hidden? (package-properties gcc)))
630 (arguments
631 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
632 (guix build utils)
633 (ice-9 regex)
634 (srfi srfi-1)
635 (srfi srfi-26))
636 ,@(package-arguments gcc))
637 ((#:configure-flags flags)
638 `(cons (string-append "--enable-languages="
639 ,(string-join languages ","))
640 (remove (cut string-match "--enable-languages.*" <>)
641 ,flags)))
642 ((#:phases phases)
643 `(modify-phases ,phases
644 (add-after 'install 'remove-broken-or-conflicting-files
645 (lambda* (#:key outputs #:allow-other-keys)
646 (for-each delete-file
647 (find-files (string-append (assoc-ref outputs "out") "/bin")
648 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
649 #t))))))))
650
651 (define %generic-search-paths
652 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
653 ;; not considered "system headers", which means GCC can raise warnings for
654 ;; issues in those headers. 'CPATH' is the only one that works for
655 ;; front-ends not in the C family.
656 (list (search-path-specification
657 (variable "CPATH")
658 (files '("include")))
659 (search-path-specification
660 (variable "LIBRARY_PATH")
661 (files '("lib" "lib64")))))
662
663 (define-public gfortran-4.8
664 (hidden-package
665 (custom-gcc gcc-4.8 "gfortran" '("fortran")
666 %generic-search-paths)))
667
668 (define-public gfortran-4.9
669 (hidden-package
670 (custom-gcc gcc-4.9 "gfortran" '("fortran")
671 %generic-search-paths)))
672
673 (define-public gfortran-5
674 (hidden-package
675 (custom-gcc gcc-5 "gfortran" '("fortran")
676 %generic-search-paths)))
677
678 (define-public gfortran-6
679 (hidden-package
680 (custom-gcc gcc-6 "gfortran" '("fortran")
681 %generic-search-paths)))
682
683 (define-public gfortran-7
684 (hidden-package
685 (custom-gcc gcc-7 "gfortran" '("fortran")
686 %generic-search-paths)))
687
688 (define-public gfortran-8
689 (hidden-package
690 (custom-gcc gcc-8 "gfortran" '("fortran")
691 %generic-search-paths)))
692
693 (define-public gfortran-9
694 (hidden-package
695 (custom-gcc gcc-9 "gfortran" '("fortran")
696 %generic-search-paths)))
697
698 (define-public gfortran
699 ;; Note: Update this when GCC changes! We cannot use
700 ;; (custom-gcc gcc "fortran" …) because that would lead to a package object
701 ;; that is not 'eq?' with GFORTRAN-5, and thus 'fold-packages' would
702 ;; report two gfortran@5 that are in fact identical.
703 gfortran-7)
704
705 (define-public libgccjit
706 (package
707 (inherit gcc-9)
708 (name "libgccjit")
709 (outputs (delete "lib" (package-outputs gcc)))
710 (properties (alist-delete 'hidden? (package-properties gcc)))
711 (arguments
712 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
713 (guix build utils)
714 (ice-9 regex)
715 (srfi srfi-1)
716 (srfi srfi-26))
717 ,@(package-arguments gcc))
718 ((#:configure-flags flags)
719 `(append `("--enable-host-shared"
720 ,(string-append "--enable-languages=jit"))
721 (remove (cut string-match "--enable-languages.*" <>)
722 ,flags)))
723 ((#:phases phases)
724 `(modify-phases ,phases
725 (add-after 'install 'remove-broken-or-conflicting-files
726 (lambda* (#:key outputs #:allow-other-keys)
727 (for-each delete-file
728 (find-files (string-append (assoc-ref outputs "out") "/bin")
729 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
730 #t))))))))
731
732
733 (define-public gccgo-4.9
734 (custom-gcc gcc-4.9 "gccgo" '("go")
735 %generic-search-paths
736 ;; Suppress the separate "lib" output, because otherwise the
737 ;; "lib" and "out" outputs would refer to each other, creating
738 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
739 #:separate-lib-output? #f))
740
741 (define-public gcc-objc-4.8
742 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
743 (list (search-path-specification
744 (variable "OBJC_INCLUDE_PATH")
745 (files '("include")))
746 (search-path-specification
747 (variable "LIBRARY_PATH")
748 (files '("lib" "lib64"))))))
749
750 (define-public gcc-objc-4.9
751 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
752 (list (search-path-specification
753 (variable "OBJC_INCLUDE_PATH")
754 (files '("include")))
755 (search-path-specification
756 (variable "LIBRARY_PATH")
757 (files '("lib" "lib64"))))))
758
759 (define-public gcc-objc-5
760 (custom-gcc gcc-5 "gcc-objc" '("objc")
761 (list (search-path-specification
762 (variable "OBJC_INCLUDE_PATH")
763 (files '("include")))
764 (search-path-specification
765 (variable "LIBRARY_PATH")
766 (files '("lib" "lib64"))))))
767
768 (define-public gcc-objc-6
769 (custom-gcc gcc-6 "gcc-objc" '("objc")
770 (list (search-path-specification
771 (variable "OBJC_INCLUDE_PATH")
772 (files '("include")))
773 (search-path-specification
774 (variable "LIBRARY_PATH")
775 (files '("lib" "lib64"))))))
776
777 (define-public gcc-objc-7
778 (custom-gcc gcc-7 "gcc-objc" '("objc")
779 (list (search-path-specification
780 (variable "OBJC_INCLUDE_PATH")
781 (files '("include")))
782 (search-path-specification
783 (variable "LIBRARY_PATH")
784 (files '("lib" "lib64"))))))
785
786 (define-public gcc-objc-8
787 (custom-gcc gcc-8 "gcc-objc" '("objc")
788 (list (search-path-specification
789 (variable "OBJC_INCLUDE_PATH")
790 (files '("include")))
791 (search-path-specification
792 (variable "LIBRARY_PATH")
793 (files '("lib" "lib64"))))))
794
795 (define-public gcc-objc gcc-objc-7)
796
797 (define-public gcc-objc++-4.8
798 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
799 (list (search-path-specification
800 (variable "OBJCPLUS_INCLUDE_PATH")
801 (files '("include")))
802 (search-path-specification
803 (variable "LIBRARY_PATH")
804 (files '("lib" "lib64"))))))
805
806 (define-public gcc-objc++-4.9
807 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
808 (list (search-path-specification
809 (variable "OBJCPLUS_INCLUDE_PATH")
810 (files '("include")))
811 (search-path-specification
812 (variable "LIBRARY_PATH")
813 (files '("lib" "lib64"))))))
814
815 (define-public gcc-objc++-5
816 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
817 (list (search-path-specification
818 (variable "OBJCPLUS_INCLUDE_PATH")
819 (files '("include")))
820 (search-path-specification
821 (variable "LIBRARY_PATH")
822 (files '("lib" "lib64"))))))
823
824 (define-public gcc-objc++-6
825 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
826 (list (search-path-specification
827 (variable "OBJCPLUS_INCLUDE_PATH")
828 (files '("include")))
829 (search-path-specification
830 (variable "LIBRARY_PATH")
831 (files '("lib" "lib64"))))))
832
833 (define-public gcc-objc++-7
834 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
835 (list (search-path-specification
836 (variable "OBJCPLUS_INCLUDE_PATH")
837 (files '("include")))
838 (search-path-specification
839 (variable "LIBRARY_PATH")
840 (files '("lib" "lib64"))))))
841
842 (define-public gcc-objc++-8
843 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
844 (list (search-path-specification
845 (variable "OBJCPLUS_INCLUDE_PATH")
846 (files '("include")))
847 (search-path-specification
848 (variable "LIBRARY_PATH")
849 (files '("lib" "lib64"))))))
850
851 (define-public gcc-objc++ gcc-objc++-7)
852
853 (define (make-libstdc++-doc gcc)
854 "Return a package with the libstdc++ documentation for GCC."
855 (package
856 (inherit gcc)
857 (name "libstdc++-doc")
858 (version (package-version gcc))
859 (synopsis "GNU libstdc++ documentation")
860 (outputs '("out"))
861 (native-inputs `(("doxygen" ,doxygen)
862 ("texinfo" ,texinfo)
863 ("libxml2" ,libxml2)
864 ("libxslt" ,libxslt)
865 ("docbook-xml" ,docbook-xml)
866 ("docbook-xsl" ,docbook-xsl)
867 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
868 (inputs '())
869 (propagated-inputs '())
870 (arguments
871 '(#:out-of-source? #t
872 #:tests? #f ;it's just documentation
873 #:phases (modify-phases %standard-phases
874 (add-before 'configure 'chdir
875 (lambda _
876 (chdir "libstdc++-v3")
877 #t))
878 (add-before 'configure 'set-xsl-directory
879 (lambda* (#:key inputs #:allow-other-keys)
880 (let ((docbook (assoc-ref inputs "docbook-xsl")))
881 (substitute* (find-files "doc"
882 "^Makefile\\.in$")
883 (("@XSL_STYLE_DIR@")
884 (string-append
885 docbook "/xml/xsl/"
886 (strip-store-file-name docbook))))
887 #t)))
888 (replace 'build
889 (lambda _
890 ;; XXX: There's also a 'doc-info' target, but it
891 ;; relies on docbook2X, which itself relies on
892 ;; DocBook 4.1.2, which is not really usable
893 ;; (lacks a catalog.xml.)
894 (invoke "make"
895 "doc-html"
896 "doc-man")))
897 (replace 'install
898 (lambda* (#:key outputs #:allow-other-keys)
899 (let ((out (assoc-ref outputs "out")))
900 (invoke "make"
901 "doc-install-html"
902 "doc-install-man")))))))
903 (properties (alist-delete 'hidden? (package-properties gcc)))))
904
905 (define-public libstdc++-doc-5
906 (make-libstdc++-doc gcc-5))
907
908 (define-public libstdc++-doc-9
909 (make-libstdc++-doc gcc-9))
910
911 (define-public isl
912 (package
913 (name "isl")
914 (version "0.21")
915 (source (origin
916 (method url-fetch)
917 (uri (list (string-append
918 "http://isl.gforge.inria.fr/isl-"
919 version
920 ".tar.bz2")
921 (string-append %gcc-infrastructure
922 name "-" version ".tar.bz2")))
923 (sha256
924 (base32
925 "0ng8l3q1px9lkzb44nxnzhh6fhdbclrwng9xs2v9m8yii8gs336i"))))
926 (build-system gnu-build-system)
927 (inputs `(("gmp" ,gmp)))
928 (home-page "http://isl.gforge.inria.fr/")
929 (synopsis
930 "Manipulating sets and relations of integer points \
931 bounded by linear constraints")
932 (description
933 "isl is a library for manipulating sets and relations of integer points
934 bounded by linear constraints. Supported operations on sets include
935 intersection, union, set difference, emptiness check, convex hull, (integer)
936 affine hull, integer projection, computing the lexicographic minimum using
937 parametric integer programming, coalescing and parametric vertex
938 enumeration. It also includes an ILP solver based on generalized basis
939 reduction, transitive closures on maps (which may encode infinite graphs),
940 dependence analysis and bounds on piecewise step-polynomials.")
941 (license lgpl2.1+)))
942
943 (define-public isl-0.18
944 (package
945 (inherit isl)
946 (version "0.18")
947 (source (origin
948 (method url-fetch)
949 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
950 version ".tar.bz2")
951 (string-append %gcc-infrastructure
952 "isl-" version ".tar.bz2")))
953 (sha256
954 (base32
955 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
956
957 (define-public isl-0.11
958 (package
959 (inherit isl)
960 (name "isl")
961 (version "0.11.1")
962 (source (origin
963 (method url-fetch)
964 (uri (list (string-append
965 "http://isl.gforge.inria.fr/isl-"
966 version
967 ".tar.bz2")
968 (string-append %gcc-infrastructure
969 name "-" version ".tar.bz2")))
970 (sha256
971 (base32
972 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
973 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
974
975 (define-public cloog
976 (package
977 (name "cloog")
978 (version "0.18.0")
979 (source
980 (origin
981 (method url-fetch)
982 (uri (list (string-append
983 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
984 version
985 ".tar.gz")
986 (string-append %gcc-infrastructure
987 name "-" version ".tar.gz")))
988 (sha256
989 (base32
990 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
991 (file-name (string-append name "-" version ".tar.gz"))))
992 (build-system gnu-build-system)
993 (inputs `(("gmp" ,gmp)
994 ("isl" ,isl-0.11)))
995 (arguments '(#:configure-flags '("--with-isl=system")))
996 (home-page "http://www.cloog.org/")
997 (synopsis "Library to generate code for scanning Z-polyhedra")
998 (description
999 "CLooG is a free software library to generate code for scanning
1000 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
1001 reaches each integral point of one or more parameterized polyhedra.
1002 CLooG has been originally written to solve the code generation problem
1003 for optimizing compilers based on the polytope model. Nevertheless it
1004 is used now in various area e.g., to build control automata for
1005 high-level synthesis or to find the best polynomial approximation of a
1006 function. CLooG may help in any situation where scanning polyhedra
1007 matters. While the user has full control on generated code quality,
1008 CLooG is designed to avoid control overhead and to produce a very
1009 effective code.")
1010 (license gpl2+)))
1011
1012 (define-public gnu-c-manual
1013 (package
1014 (name "gnu-c-manual")
1015 (version "0.2.5")
1016 (source (origin
1017 (method url-fetch)
1018 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1019 version ".tar.gz"))
1020 (sha256
1021 (base32
1022 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
1023 (build-system gnu-build-system)
1024 (native-inputs `(("texinfo" ,texinfo)))
1025 (arguments
1026 '(#:phases (modify-phases %standard-phases
1027 (delete 'configure)
1028 (delete 'check)
1029 (replace 'build
1030 (lambda _
1031 (invoke "make"
1032 "gnu-c-manual.info"
1033 "gnu-c-manual.html")))
1034 (replace 'install
1035 (lambda* (#:key outputs #:allow-other-keys)
1036 (let* ((out (assoc-ref outputs "out"))
1037 (info (string-append out "/share/info"))
1038 (html (string-append
1039 out "/share/doc/gnu-c-manual")))
1040 (mkdir-p info)
1041 (mkdir-p html)
1042
1043 (for-each (lambda (file)
1044 (copy-file file
1045 (string-append info "/"
1046 file)))
1047 (find-files "." "\\.info(-[0-9])?$"))
1048 (for-each (lambda (file)
1049 (copy-file file
1050 (string-append html "/"
1051 file)))
1052 (find-files "." "\\.html$"))
1053 #t))))))
1054 (synopsis "Reference manual for the C programming language")
1055 (description
1056 "This is a reference manual for the C programming language, as
1057 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
1058 to be a tutorial of the language. Rather, it outlines all of the constructs
1059 of the language. Library functions are not included.")
1060 (home-page "https://www.gnu.org/software/gnu-c-manual/")
1061 (license fdl1.3+)))