gnu: glibc: Update to 2.31.
[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 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 ;;;
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)
27 #:use-module ((guix licenses)
28 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
29 #:use-module (gnu packages)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages multiprecision)
33 #:use-module (gnu packages texinfo)
34 #:use-module (gnu packages dejagnu)
35 #:use-module (gnu packages documentation)
36 #:use-module (gnu packages xml)
37 #:use-module (gnu packages docbook)
38 #:use-module (gnu packages graphviz)
39 #:use-module (gnu packages elf)
40 #:use-module (gnu packages perl)
41 #:use-module (guix packages)
42 #:use-module (guix download)
43 #:use-module (guix build-system gnu)
44 #:use-module (guix build-system trivial)
45 #:use-module (guix utils)
46 #:use-module (srfi srfi-1)
47 #:use-module (ice-9 regex))
48
49 (define %gcc-infrastructure
50 ;; Base URL for GCC's infrastructure.
51 "mirror://gcc/infrastructure/")
52
53 (define (gcc-configure-flags-for-triplet target)
54 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
55
56 The purpose of this procedure is to translate extended GNU triplets---e.g.,
57 where 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"))
63
64 ((string-match "^arm.*-gnueabihf$" target)
65 '("--with-arch=armv7-a"
66 "--with-float=hard"
67 "--with-mode=thumb"
68 "--with-fpu=neon"))
69
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
78 (else
79 ;; TODO: Add `arm.*-gnueabi', etc.
80 '())))
81
82 (define-public gcc-4.7
83 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
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))
93 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
94 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
95 '()))))
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))))
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"
114 "--with-system-zlib"
115
116 ;; No pre-compiled libstdc++ headers, to save space.
117 "--disable-libstdcxx-pch"
118
119 "--with-local-prefix=/no-gcc-local-prefix"
120
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
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
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))
140
141 (maybe-target-tools))))))
142 (hidden-package
143 (package
144 (name "gcc")
145 (version "4.7.4")
146 (source (origin
147 (method url-fetch)
148 (uri (string-append "mirror://gnu/gcc/gcc-"
149 version "/gcc-" version ".tar.bz2"))
150 (sha256
151 (base32
152 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
153 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
154 "gcc-fix-texi2pod.patch"))))
155 (build-system gnu-build-system)
156
157 ;; Separate out the run-time support libraries because all the
158 ;; dynamic-linked objects depend on it.
159 (outputs '("out" ;commands, etc. (60+ MiB)
160 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
161 "debug")) ;debug symbols of run-time libraries
162
163 (inputs `(("gmp" ,gmp)
164 ("mpfr" ,mpfr)
165 ("mpc" ,mpc)
166 ("libelf" ,libelf)
167 ("zlib" ,zlib)))
168
169 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
170 ;; Newer texinfos fail to build the manual, so we use an older one.
171 (native-inputs `(("perl" ,perl) ;for manpages
172 ("texinfo" ,texinfo-5)))
173
174 (arguments
175 `(#:out-of-source? #t
176 #:configure-flags ,(configure-flags)
177 #:make-flags
178 ;; None of the flags below are needed when doing a Canadian cross.
179 ;; TODO: Simplify this.
180 ,(if (%current-target-system)
181 (if stripped?
182 ''("CFLAGS=-g0 -O2")
183 ''())
184 `(let* ((libc (assoc-ref %build-inputs "libc"))
185 (libc-native (or (assoc-ref %build-inputs "libc-native")
186 libc)))
187 `(,@(if libc
188 (list (string-append "LDFLAGS_FOR_TARGET="
189 "-B" libc "/lib "
190 "-Wl,-dynamic-linker "
191 "-Wl," libc
192 ,(glibc-dynamic-linker)))
193 '())
194
195 ;; Native programs like 'genhooks' also need that right.
196 ,(string-append "LDFLAGS="
197 "-Wl,-rpath=" libc-native "/lib "
198 "-Wl,-dynamic-linker "
199 "-Wl," libc-native ,(glibc-dynamic-linker))
200 ,(string-append "BOOT_CFLAGS=-O2 "
201 ,(if stripped? "-g0" "-g")))))
202
203 #:tests? #f
204
205 #:phases
206 (modify-phases %standard-phases
207 (add-before 'configure 'pre-configure
208 (lambda* (#:key inputs outputs #:allow-other-keys)
209 (let ((libdir ,(libdir))
210 (libc (assoc-ref inputs "libc")))
211 (when libc
212 ;; The following is not performed for `--without-headers'
213 ;; cross-compiler builds.
214
215 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
216 ;; single line, to allow the next step to work properly.
217 (for-each
218 (lambda (x)
219 (substitute* (find-files "gcc/config"
220 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
221 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
222 line)))
223 '(1 2 3))
224
225 ;; Fix the dynamic linker's file name.
226 (substitute* (find-files "gcc/config"
227 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
228 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
229 _ gnu-user suffix)
230 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
231 gnu-user suffix
232 (string-append libc ,(glibc-dynamic-linker)))))
233
234 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
235 ;; `crt{begin,end}.o', which come with GCC.
236 (substitute* (find-files "gcc/config"
237 "^gnu-user.*\\.h$")
238 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
239 ;; Help libgcc_s.so be found (see also below.) Always use
240 ;; '-lgcc_s' so that libgcc_s.so is always found by those
241 ;; programs that use 'pthread_cancel' (glibc dlopens
242 ;; libgcc_s.so when pthread_cancel support is needed, but
243 ;; having it in the application's RUNPATH isn't enough; see
244 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
245 ;;
246 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
247 ;; later phase of %gcc-static. If you change the string
248 ;; below, make sure to update the relevant code in
249 ;; %gcc-static package as needed.
250 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
251 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
252 libc libc libdir suffix))
253 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
254 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
255 #define STANDARD_STARTFILE_PREFIX_2 \"\"
256 ~a"
257 libc line)))
258
259 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
260 ;; GNU_USER_* defines. Do the above for this case.
261 (substitute*
262 "gcc/config/rs6000/sysv4.h"
263 (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
264 (format #f "#define LIB_LINUX_SPEC \
265 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
266 libc libc libdir suffix))
267 (("#define STARTFILE_LINUX_SPEC.*$" line)
268 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
269 #define STANDARD_STARTFILE_PREFIX_2 \"\"
270 ~a"
271 libc line))))
272
273 ;; Don't retain a dependency on the build-time sed.
274 (substitute* "fixincludes/fixincl.x"
275 (("static char const sed_cmd_z\\[\\] =.*;")
276 "static char const sed_cmd_z[] = \"sed\";"))
277
278 ;; Aarch64 support didn't land in GCC until the 4.8 series.
279 (when (file-exists? "gcc/config/aarch64")
280 ;; Force Aarch64 libdir to be /lib and not /lib64
281 (substitute* "gcc/config/aarch64/t-aarch64-linux"
282 (("lib64") "lib")))
283
284 (when (file-exists? "libbacktrace")
285 ;; GCC 4.8+ comes with libbacktrace. By default it builds
286 ;; with -Werror, which fails with a -Wcast-qual error in glibc
287 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
288 (substitute* "libbacktrace/configure"
289 (("WARN_FLAGS=(.*)-Werror" _ flags)
290 (string-append "WARN_FLAGS=" flags)))
291
292 (when (file-exists? "libsanitizer/libbacktrace")
293 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
294 (substitute* "libsanitizer/libbacktrace/Makefile.in"
295 (("-Werror")
296 ""))))
297
298 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
299 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
300 ;; and <http://bugs.gnu.org/20358>.
301 (substitute* "libstdc++-v3/src/Makefile.in"
302 (("^OPT_LDFLAGS = ")
303 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
304
305 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
306 ;; circularity between "out" and "lib". (Note:
307 ;; --with-python-dir is useless because it imposes $(prefix) as
308 ;; the parent directory.)
309 (substitute* "libstdc++-v3/python/Makefile.in"
310 (("pythondir = .*$")
311 (string-append "pythondir = " libdir "/share"
312 "/gcc-$(gcc_version)/python\n")))
313
314 ;; Avoid another circularity between the outputs: this #define
315 ;; ends up in auto-host.h in the "lib" output, referring to
316 ;; "out". (This variable is used to augment cpp's search path,
317 ;; but there's nothing useful to look for here.)
318 (substitute* "gcc/config.in"
319 (("PREFIX_INCLUDE_DIR")
320 "PREFIX_INCLUDE_DIR_isnt_necessary_here"))
321 #t)))
322
323 (add-after 'configure 'post-configure
324 (lambda _
325 ;; Don't store configure flags, to avoid retaining references to
326 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
327 (substitute* "Makefile"
328 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
329 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))
330 #t)))))
331
332 (native-search-paths
333 ;; Use the language-specific variables rather than 'CPATH' because they
334 ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
335 ;; The intent is to allow headers that are in the search path to be
336 ;; treated as "system headers" (headers exempt from warnings) just like
337 ;; the typical /usr/include headers on an FHS system.
338 (list (search-path-specification
339 (variable "C_INCLUDE_PATH")
340 (files '("include")))
341 (search-path-specification
342 (variable "CPLUS_INCLUDE_PATH")
343 ;; Add 'include/c++' here so that <cstdlib>'s "#include_next
344 ;; <stdlib.h>" finds GCC's <stdlib.h>, not libc's.
345 (files '("include/c++" "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-4.9-libsanitizer-mode-size.patch"
406 "gcc-arm-bug-71399.patch"
407 "gcc-asan-missing-include.patch"
408 "gcc-libvtv-runpath.patch"
409 "gcc-fix-texi2pod.patch"))
410 (modules '((guix build utils)))
411 ;; This is required for building with glibc-2.26.
412 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
413 (snippet
414 '(begin
415 (for-each
416 (lambda (dir)
417 (substitute* (string-append "libgcc/config/"
418 dir "/linux-unwind.h")
419 (("struct ucontext") "ucontext_t")))
420 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
421 "pa" "sh" "tilepro" "xtensa"))
422 #t))))
423 ;; Override inherited texinfo-5 with latest version.
424 (native-inputs `(("perl" ,perl) ;for manpages
425 ("texinfo" ,texinfo)))))
426
427 (define-public gcc-5
428 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
429 ;; them in a VPATH build.
430 (package (inherit gcc-4.9)
431 (version "5.5.0")
432 (source (origin
433 (method url-fetch)
434 (uri (string-append "mirror://gnu/gcc/gcc-"
435 version "/gcc-" version ".tar.xz"))
436 (sha256
437 (base32
438 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
439 (patches (search-patches "gcc-arm-bug-71399.patch"
440 "gcc-libsanitizer-ustat.patch"
441 "gcc-strmov-store-file-names.patch"
442 "gcc-5.0-libvtv-runpath.patch"
443 "gcc-5-source-date-epoch-1.patch"
444 "gcc-5-source-date-epoch-2.patch"
445 "gcc-6-libsanitizer-mode-size.patch"
446 "gcc-fix-texi2pod.patch"))
447 (modules '((guix build utils)))
448 (snippet
449 ;; Fix 'libcc1/configure' error when cross-compiling GCC.
450 ;; Without that, 'libcc1/configure' wrongfully determines that
451 ;; '-rdynamic' support is missing because $gcc_cv_objdump is
452 ;; empty:
453 ;;
454 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
455 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
456 '(begin
457 (substitute* "libcc1/configure"
458 (("\\$gcc_cv_objdump -T")
459 "$OBJDUMP_FOR_TARGET -T"))
460 #t))))
461 (inputs
462 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
463 ("isl" ,isl-0.18)
464 ,@(package-inputs gcc-4.7)))))
465
466 (define-public gcc-6
467 (package
468 (inherit gcc-5)
469 (version "6.5.0")
470 (source (origin
471 (method url-fetch)
472 (uri (string-append "mirror://gnu/gcc/gcc-"
473 version "/gcc-" version ".tar.xz"))
474 (sha256
475 (base32
476 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
477 (patches (search-patches "gcc-strmov-store-file-names.patch"
478 "gcc-6-libsanitizer-mode-size.patch"
479 "gcc-6-source-date-epoch-1.patch"
480 "gcc-6-source-date-epoch-2.patch"
481 "gcc-5.0-libvtv-runpath.patch"))))
482 (inputs
483 `(("isl" ,isl)
484 ,@(package-inputs gcc-4.7)))))
485
486 (define-public gcc-7
487 (package
488 (inherit gcc-6)
489 (version "7.5.0")
490 (source (origin
491 (method url-fetch)
492 (uri (string-append "mirror://gnu/gcc/gcc-"
493 version "/gcc-" version ".tar.xz"))
494 (sha256
495 (base32
496 "0qg6kqc5l72hpnj4vr6l0p69qav0rh4anlkk3y55540zy3klc6dq"))
497 (patches (search-patches "gcc-strmov-store-file-names.patch"
498 "gcc-7-libsanitizer-mode-size.patch"
499 "gcc-5.0-libvtv-runpath.patch"))))
500 (description
501 "GCC is the GNU Compiler Collection. It provides compiler front-ends
502 for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
503 It also includes runtime support libraries for these languages.")))
504
505 (define-public gcc-8
506 (package
507 (inherit gcc-7)
508 (version "8.3.0")
509 (source (origin
510 (method url-fetch)
511 (uri (string-append "mirror://gnu/gcc/gcc-"
512 version "/gcc-" version ".tar.xz"))
513 (sha256
514 (base32
515 "0b3xv411xhlnjmin2979nxcbnidgvzqdf4nbhix99x60dkzavfk4"))
516 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
517 "gcc-8-libsanitizer-mode-size.patch"
518 "gcc-5.0-libvtv-runpath.patch"))))))
519
520 (define-public gcc-9
521 (package
522 (inherit gcc-8)
523 (version "9.2.0")
524 (source (origin
525 (method url-fetch)
526 (uri (string-append "mirror://gnu/gcc/gcc-"
527 version "/gcc-" version ".tar.xz"))
528 (sha256
529 (base32
530 "01mj3yk7z49i49168hg2cg7qs4bsccrrnv7pjmbdlf8j2a7z0vpa"))
531 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
532 "gcc-9-libsanitizer-mode-size.patch"
533 "gcc-9-asan-fix-limits-include.patch"
534 "gcc-5.0-libvtv-runpath.patch"))))))
535
536 ;; Note: When changing the default gcc version, update
537 ;; the gcc-toolchain-* definitions and the gfortran definition
538 ;; accordingly.
539 (define-public gcc gcc-7)
540
541 (define-public (make-libstdc++ gcc)
542 "Return a libstdc++ package based on GCC. The primary use case is when
543 using compilers other than GCC."
544 (package
545 (inherit gcc)
546 (name "libstdc++")
547 (arguments
548 `(#:out-of-source? #t
549 #:phases (alist-cons-before
550 'configure 'chdir
551 (lambda _
552 (chdir "libstdc++-v3")
553 #t)
554 %standard-phases)
555 #:configure-flags `("--disable-libstdcxx-pch"
556 ,(string-append "--with-gxx-include-dir="
557 (assoc-ref %outputs "out")
558 "/include"))))
559 (outputs '("out" "debug"))
560 (inputs '())
561 (native-inputs '())
562 (propagated-inputs '())
563 (synopsis "GNU C++ standard library")))
564
565 (define-public libstdc++-4.9
566 (make-libstdc++ gcc-4.9))
567
568 (define (make-libiberty gcc)
569 "Return a libiberty package based on GCC."
570 (package
571 (inherit gcc)
572 (name "libiberty")
573 (arguments
574 `(#:out-of-source? #t
575 #:phases
576 (modify-phases %standard-phases
577 (add-before 'configure 'chdir
578 (lambda _
579 (chdir "libiberty")
580 #t))
581 (replace
582 'install
583 (lambda* (#:key outputs #:allow-other-keys)
584 (let* ((out (assoc-ref outputs "out"))
585 (lib (string-append out "/lib/"))
586 (include (string-append out "/include/")))
587 (mkdir-p lib)
588 (mkdir-p include)
589 (copy-file "libiberty.a"
590 (string-append lib "libiberty.a"))
591 (copy-file "../include/libiberty.h"
592 (string-append include "libiberty.h"))
593 #t))))))
594 (inputs '())
595 (outputs '("out"))
596 (native-inputs '())
597 (propagated-inputs '())
598 (synopsis "Collection of subroutines used by various GNU programs")))
599
600 (define-public libiberty
601 (make-libiberty gcc))
602
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
608 as the 'native-search-paths' field."
609 (package (inherit gcc)
610 (name name)
611 (outputs (if separate-lib-output?
612 (package-outputs gcc)
613 (delete "lib" (package-outputs gcc))))
614 (native-search-paths search-paths)
615 (properties (alist-delete 'hidden? (package-properties gcc)))
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.*" <>)
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")
634 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
635 #t))))))))
636
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
649 (define-public gfortran-4.8
650 (hidden-package
651 (custom-gcc gcc-4.8 "gfortran" '("fortran")
652 %generic-search-paths)))
653
654 (define-public gfortran-4.9
655 (hidden-package
656 (custom-gcc gcc-4.9 "gfortran" '("fortran")
657 %generic-search-paths)))
658
659 (define-public gfortran-5
660 (hidden-package
661 (custom-gcc gcc-5 "gfortran" '("fortran")
662 %generic-search-paths)))
663
664 (define-public gfortran-6
665 (hidden-package
666 (custom-gcc gcc-6 "gfortran" '("fortran")
667 %generic-search-paths)))
668
669 (define-public gfortran-7
670 (hidden-package
671 (custom-gcc gcc-7 "gfortran" '("fortran")
672 %generic-search-paths)))
673
674 (define-public gfortran-8
675 (hidden-package
676 (custom-gcc gcc-8 "gfortran" '("fortran")
677 %generic-search-paths)))
678
679 (define-public gfortran-9
680 (hidden-package
681 (custom-gcc gcc-9 "gfortran" '("fortran")
682 %generic-search-paths)))
683
684 (define-public gfortran
685 ;; Note: Update this when GCC changes! We cannot use
686 ;; (custom-gcc gcc "fortran" …) because that would lead to a package object
687 ;; that is not 'eq?' with GFORTRAN-5, and thus 'fold-packages' would
688 ;; report two gfortran@5 that are in fact identical.
689 gfortran-7)
690
691 (define-public gccgo-4.9
692 (custom-gcc gcc-4.9 "gccgo" '("go")
693 %generic-search-paths
694 ;; Suppress the separate "lib" output, because otherwise the
695 ;; "lib" and "out" outputs would refer to each other, creating
696 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
697 #:separate-lib-output? #f))
698
699 (define-public gcc-objc-4.8
700 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
701 (list (search-path-specification
702 (variable "OBJC_INCLUDE_PATH")
703 (files '("include")))
704 (search-path-specification
705 (variable "LIBRARY_PATH")
706 (files '("lib" "lib64"))))))
707
708 (define-public gcc-objc-4.9
709 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
710 (list (search-path-specification
711 (variable "OBJC_INCLUDE_PATH")
712 (files '("include")))
713 (search-path-specification
714 (variable "LIBRARY_PATH")
715 (files '("lib" "lib64"))))))
716
717 (define-public gcc-objc-5
718 (custom-gcc gcc-5 "gcc-objc" '("objc")
719 (list (search-path-specification
720 (variable "OBJC_INCLUDE_PATH")
721 (files '("include")))
722 (search-path-specification
723 (variable "LIBRARY_PATH")
724 (files '("lib" "lib64"))))))
725
726 (define-public gcc-objc-6
727 (custom-gcc gcc-6 "gcc-objc" '("objc")
728 (list (search-path-specification
729 (variable "OBJC_INCLUDE_PATH")
730 (files '("include")))
731 (search-path-specification
732 (variable "LIBRARY_PATH")
733 (files '("lib" "lib64"))))))
734
735 (define-public gcc-objc-7
736 (custom-gcc gcc-7 "gcc-objc" '("objc")
737 (list (search-path-specification
738 (variable "OBJC_INCLUDE_PATH")
739 (files '("include")))
740 (search-path-specification
741 (variable "LIBRARY_PATH")
742 (files '("lib" "lib64"))))))
743
744 (define-public gcc-objc-8
745 (custom-gcc gcc-8 "gcc-objc" '("objc")
746 (list (search-path-specification
747 (variable "OBJC_INCLUDE_PATH")
748 (files '("include")))
749 (search-path-specification
750 (variable "LIBRARY_PATH")
751 (files '("lib" "lib64"))))))
752
753 (define-public gcc-objc gcc-objc-7)
754
755 (define-public gcc-objc++-4.8
756 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
757 (list (search-path-specification
758 (variable "OBJCPLUS_INCLUDE_PATH")
759 (files '("include")))
760 (search-path-specification
761 (variable "LIBRARY_PATH")
762 (files '("lib" "lib64"))))))
763
764 (define-public gcc-objc++-4.9
765 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
766 (list (search-path-specification
767 (variable "OBJCPLUS_INCLUDE_PATH")
768 (files '("include")))
769 (search-path-specification
770 (variable "LIBRARY_PATH")
771 (files '("lib" "lib64"))))))
772
773 (define-public gcc-objc++-5
774 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
775 (list (search-path-specification
776 (variable "OBJCPLUS_INCLUDE_PATH")
777 (files '("include")))
778 (search-path-specification
779 (variable "LIBRARY_PATH")
780 (files '("lib" "lib64"))))))
781
782 (define-public gcc-objc++-6
783 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
784 (list (search-path-specification
785 (variable "OBJCPLUS_INCLUDE_PATH")
786 (files '("include")))
787 (search-path-specification
788 (variable "LIBRARY_PATH")
789 (files '("lib" "lib64"))))))
790
791 (define-public gcc-objc++-7
792 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
793 (list (search-path-specification
794 (variable "OBJCPLUS_INCLUDE_PATH")
795 (files '("include")))
796 (search-path-specification
797 (variable "LIBRARY_PATH")
798 (files '("lib" "lib64"))))))
799
800 (define-public gcc-objc++-8
801 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
802 (list (search-path-specification
803 (variable "OBJCPLUS_INCLUDE_PATH")
804 (files '("include")))
805 (search-path-specification
806 (variable "LIBRARY_PATH")
807 (files '("lib" "lib64"))))))
808
809 (define-public gcc-objc++ gcc-objc++-7)
810
811 (define (make-libstdc++-doc gcc)
812 "Return a package with the libstdc++ documentation for GCC."
813 (package
814 (inherit gcc)
815 (name "libstdc++-doc")
816 (version (package-version gcc))
817 (synopsis "GNU libstdc++ documentation")
818 (outputs '("out"))
819 (native-inputs `(("doxygen" ,doxygen)
820 ("texinfo" ,texinfo)
821 ("libxml2" ,libxml2)
822 ("libxslt" ,libxslt)
823 ("docbook-xml" ,docbook-xml)
824 ("docbook-xsl" ,docbook-xsl)
825 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
826 (inputs '())
827 (propagated-inputs '())
828 (arguments
829 '(#:out-of-source? #t
830 #:tests? #f ;it's just documentation
831 #:phases (modify-phases %standard-phases
832 (add-before 'configure 'chdir
833 (lambda _
834 (chdir "libstdc++-v3")
835 #t))
836 (add-before 'configure 'set-xsl-directory
837 (lambda* (#:key inputs #:allow-other-keys)
838 (let ((docbook (assoc-ref inputs "docbook-xsl")))
839 (substitute* (find-files "doc"
840 "^Makefile\\.in$")
841 (("@XSL_STYLE_DIR@")
842 (string-append
843 docbook "/xml/xsl/"
844 (strip-store-file-name docbook))))
845 #t)))
846 (replace 'build
847 (lambda _
848 ;; XXX: There's also a 'doc-info' target, but it
849 ;; relies on docbook2X, which itself relies on
850 ;; DocBook 4.1.2, which is not really usable
851 ;; (lacks a catalog.xml.)
852 (invoke "make"
853 "doc-html"
854 "doc-man")))
855 (replace 'install
856 (lambda* (#:key outputs #:allow-other-keys)
857 (let ((out (assoc-ref outputs "out")))
858 (invoke "make"
859 "doc-install-html"
860 "doc-install-man")))))))
861 (properties (alist-delete 'hidden? (package-properties gcc)))))
862
863 (define-public libstdc++-doc-5
864 (make-libstdc++-doc gcc-5))
865
866 (define-public libstdc++-doc-9
867 (make-libstdc++-doc gcc-9))
868
869 (define-public isl
870 (package
871 (name "isl")
872 (version "0.22.1")
873 (source (origin
874 (method url-fetch)
875 (uri (list (string-append
876 "http://isl.gforge.inria.fr/isl-"
877 version
878 ".tar.bz2")
879 (string-append %gcc-infrastructure
880 name "-" version ".tar.bz2")))
881 (sha256
882 (base32
883 "1kf54jib0nind1pvakblnfhimmwzm0y1llz8470ag0di5vwqwrhs"))))
884 (build-system gnu-build-system)
885 (inputs `(("gmp" ,gmp)))
886 (home-page "http://isl.gforge.inria.fr/")
887 (synopsis
888 "Manipulating sets and relations of integer points \
889 bounded by linear constraints")
890 (description
891 "isl is a library for manipulating sets and relations of integer points
892 bounded by linear constraints. Supported operations on sets include
893 intersection, union, set difference, emptiness check, convex hull, (integer)
894 affine hull, integer projection, computing the lexicographic minimum using
895 parametric integer programming, coalescing and parametric vertex
896 enumeration. It also includes an ILP solver based on generalized basis
897 reduction, transitive closures on maps (which may encode infinite graphs),
898 dependence analysis and bounds on piecewise step-polynomials.")
899 (license lgpl2.1+)))
900
901 (define-public isl-0.18
902 (package
903 (inherit isl)
904 (version "0.18")
905 (source (origin
906 (method url-fetch)
907 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
908 version ".tar.bz2")
909 (string-append %gcc-infrastructure
910 "isl-" version ".tar.bz2")))
911 (sha256
912 (base32
913 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
914
915 (define-public isl-0.11
916 (package
917 (inherit isl)
918 (name "isl")
919 (version "0.11.1")
920 (source (origin
921 (method url-fetch)
922 (uri (list (string-append
923 "http://isl.gforge.inria.fr/isl-"
924 version
925 ".tar.bz2")
926 (string-append %gcc-infrastructure
927 name "-" version ".tar.bz2")))
928 (sha256
929 (base32
930 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
931 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
932
933 (define-public cloog
934 (package
935 (name "cloog")
936 (version "0.18.0")
937 (source
938 (origin
939 (method url-fetch)
940 (uri (list (string-append
941 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
942 version
943 ".tar.gz")
944 (string-append %gcc-infrastructure
945 name "-" version ".tar.gz")))
946 (sha256
947 (base32
948 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
949 (file-name (string-append name "-" version ".tar.gz"))))
950 (build-system gnu-build-system)
951 (inputs `(("gmp" ,gmp)
952 ("isl" ,isl-0.11)))
953 (arguments '(#:configure-flags '("--with-isl=system")))
954 (home-page "http://www.cloog.org/")
955 (synopsis "Library to generate code for scanning Z-polyhedra")
956 (description
957 "CLooG is a free software library to generate code for scanning
958 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
959 reaches each integral point of one or more parameterized polyhedra.
960 CLooG has been originally written to solve the code generation problem
961 for optimizing compilers based on the polytope model. Nevertheless it
962 is used now in various area e.g., to build control automata for
963 high-level synthesis or to find the best polynomial approximation of a
964 function. CLooG may help in any situation where scanning polyhedra
965 matters. While the user has full control on generated code quality,
966 CLooG is designed to avoid control overhead and to produce a very
967 effective code.")
968 (license gpl2+)))
969
970 (define-public gnu-c-manual
971 (package
972 (name "gnu-c-manual")
973 (version "0.2.5")
974 (source (origin
975 (method url-fetch)
976 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
977 version ".tar.gz"))
978 (sha256
979 (base32
980 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
981 (build-system gnu-build-system)
982 (native-inputs `(("texinfo" ,texinfo)))
983 (arguments
984 '(#:phases (modify-phases %standard-phases
985 (delete 'configure)
986 (delete 'check)
987 (replace 'build
988 (lambda _
989 (invoke "make"
990 "gnu-c-manual.info"
991 "gnu-c-manual.html")))
992 (replace 'install
993 (lambda* (#:key outputs #:allow-other-keys)
994 (let* ((out (assoc-ref outputs "out"))
995 (info (string-append out "/share/info"))
996 (html (string-append
997 out "/share/doc/gnu-c-manual")))
998 (mkdir-p info)
999 (mkdir-p html)
1000
1001 (for-each (lambda (file)
1002 (copy-file file
1003 (string-append info "/"
1004 file)))
1005 (find-files "." "\\.info(-[0-9])?$"))
1006 (for-each (lambda (file)
1007 (copy-file file
1008 (string-append html "/"
1009 file)))
1010 (find-files "." "\\.html$"))
1011 #t))))))
1012 (synopsis "Reference manual for the C programming language")
1013 (description
1014 "This is a reference manual for the C programming language, as
1015 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
1016 to be a tutorial of the language. Rather, it outlines all of the constructs
1017 of the language. Library functions are not included.")
1018 (home-page "https://www.gnu.org/software/gnu-c-manual/")
1019 (license fdl1.3+)))