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, 2021 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, 2020 Marius Bakke <mbakke@fastmail.com>
10 ;;; Copyright © 2020 Joseph LaFreniere <joseph@lafreniere.xyz>
11 ;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
12 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
13 ;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
15 ;;; This file is part of GNU Guix.
17 ;;; GNU Guix is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
22 ;;; GNU Guix is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30 (define-module (gnu packages gcc)
31 #:use-module ((guix licenses)
32 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
33 #:use-module (gnu packages)
34 #:use-module (gnu packages bootstrap)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages multiprecision)
37 #:use-module (gnu packages texinfo)
38 #:use-module (gnu packages dejagnu)
39 #:use-module (gnu packages documentation)
40 #:use-module (gnu packages xml)
41 #:use-module (gnu packages docbook)
42 #:use-module (gnu packages graphviz)
43 #:use-module (gnu packages elf)
44 #:use-module (gnu packages perl)
45 #:use-module (guix packages)
46 #:use-module (guix download)
47 #:use-module (guix build-system gnu)
48 #:use-module (guix build-system trivial)
49 #:use-module (guix utils)
50 #:use-module (srfi srfi-1)
51 #:use-module (ice-9 regex))
53 (define %gcc-infrastructure
54 ;; Base URL for GCC's infrastructure.
55 "mirror://gcc/infrastructure/")
57 (define (gcc-configure-flags-for-triplet target)
58 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
60 The purpose of this procedure is to translate extended GNU triplets---e.g.,
61 where the OS part is overloaded to denote a specific ABI---into GCC
62 `configure' options. We take extended GNU triplets that glibc recognizes."
63 (cond ((string-match "^mips64el.*gnuabin?64$" target)
64 ;; Triplets recognized by glibc as denoting the N64 ABI; see
65 ;; ports/sysdeps/mips/preconfigure.
68 ((string-match "^arm.*-gnueabihf$" target)
69 '("--with-arch=armv7-a"
74 ((and (string-suffix? "-gnu" target)
75 (not (string-contains target "-linux")))
76 ;; Cross-compilation of libcilkrts in GCC 5.5.0 to GNU/Hurd fails
78 ;; libcilkrts/runtime/os-unix.c:388:2: error: #error "Unknown architecture"
79 ;; Cilk has been removed from GCC 8 anyway.
80 '("--disable-libcilkrts"))
83 ;; TODO: Add `arm.*-gnueabi', etc.
86 (define-public gcc-4.7
87 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
90 ;; Return the `_FOR_TARGET' variables that are needed when
91 ;; cross-compiling GCC.
92 (let ((target (%current-target-system)))
94 (map (lambda (var tool)
95 (string-append (string-append var "_FOR_TARGET")
97 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
98 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
101 (let ((base '(or (assoc-ref outputs "lib")
102 (assoc-ref outputs "out"))))
104 ;; Return the directory that contains lib/libgcc_s.so et al.
105 (if (%current-target-system)
106 `(string-append ,base "/" ,(%current-target-system))
110 ;; This is terrible. Since we have two levels of quasiquotation,
111 ;; we have to do this convoluted thing just so we can insert the
112 ;; contents of (maybe-target-tools).
116 "--enable-languages=c,c++"
120 ;; No pre-compiled libstdc++ headers, to save space.
121 "--disable-libstdcxx-pch"
123 "--with-local-prefix=/no-gcc-local-prefix"
125 ;; With a separate "lib" output, the build system
126 ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force
127 ;; it. (Don't use a versioned sub-directory, that's
129 ,(string-append "--with-gxx-include-dir="
130 (assoc-ref %outputs "out")
133 ,(let ((libc (assoc-ref %build-inputs "libc")))
135 (string-append "--with-native-system-header-dir=" libc
137 "--without-headers")))
139 ;; Pass the right options for the target triplet.
141 (or (%current-target-system)
142 (nix-system->gnu-triplet (%current-system)))))
143 (gcc-configure-flags-for-triplet triplet))
145 (maybe-target-tools))))))
152 (uri (string-append "mirror://gnu/gcc/gcc-"
153 version "/gcc-" version ".tar.bz2"))
156 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
157 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
158 "gcc-fix-texi2pod.patch"))))
159 (build-system gnu-build-system)
161 ;; Separate out the run-time support libraries because all the
162 ;; dynamic-linked objects depend on it.
163 (outputs '("out" ;commands, etc. (60+ MiB)
164 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
165 "debug")) ;debug symbols of run-time libraries
167 (inputs `(("gmp" ,gmp)
173 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
174 ;; Newer texinfos fail to build the manual, so we use an older one.
175 (native-inputs `(("perl" ,perl) ;for manpages
176 ("texinfo" ,texinfo-5)))
179 `(#:out-of-source? #t
180 #:configure-flags ,(configure-flags)
182 ;; None of the flags below are needed when doing a Canadian cross.
183 ;; TODO: Simplify this.
184 ,(if (%current-target-system)
188 `(let* ((libc (assoc-ref %build-inputs "libc"))
189 (libc-native (or (assoc-ref %build-inputs "libc-native")
192 (list (string-append "LDFLAGS_FOR_TARGET="
194 "-Wl,-dynamic-linker "
196 ,(glibc-dynamic-linker)))
199 ;; Native programs like 'genhooks' also need that right.
200 ,(string-append "LDFLAGS="
201 "-Wl,-rpath=" libc-native "/lib "
202 "-Wl,-dynamic-linker "
203 "-Wl," libc-native ,(glibc-dynamic-linker))
204 ,(string-append "BOOT_CFLAGS=-O2 "
205 ,(if stripped? "-g0" "-g")))))
210 (modify-phases %standard-phases
211 (add-before 'configure 'pre-configure
212 (lambda* (#:key inputs outputs #:allow-other-keys)
213 (let ((libdir ,(libdir))
214 (libc (assoc-ref inputs "libc")))
216 ;; The following is not performed for `--without-headers'
217 ;; cross-compiler builds.
219 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
220 ;; single line, to allow the next step to work properly.
223 (substitute* (find-files "gcc/config"
224 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
225 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
229 ;; Fix the dynamic linker's file name.
230 (substitute* (find-files "gcc/config"
231 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
232 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
234 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
236 (string-append libc ,(glibc-dynamic-linker)))))
238 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
239 ;; `crt{begin,end}.o', which come with GCC.
240 (substitute* (find-files "gcc/config"
242 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
243 ;; Help libgcc_s.so be found (see also below.) Always use
244 ;; '-lgcc_s' so that libgcc_s.so is always found by those
245 ;; programs that use 'pthread_cancel' (glibc dlopens
246 ;; libgcc_s.so when pthread_cancel support is needed, but
247 ;; having it in the application's RUNPATH isn't enough; see
248 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
250 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
251 ;; later phase of %gcc-static. If you change the string
252 ;; below, make sure to update the relevant code in
253 ;; %gcc-static package as needed.
254 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
255 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
256 libc libc libdir suffix))
257 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
258 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
259 #define STANDARD_STARTFILE_PREFIX_2 \"\"
263 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
264 ;; GNU_USER_* defines. Do the above for this case.
266 "gcc/config/rs6000/sysv4.h"
267 (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
268 (format #f "#define LIB_LINUX_SPEC \
269 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
270 libc libc libdir suffix))
271 (("#define STARTFILE_LINUX_SPEC.*$" line)
272 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
273 #define STANDARD_STARTFILE_PREFIX_2 \"\"
277 ;; TODO: Make this unconditional in core-updates.
278 ,@(if (target-powerpc?)
279 `((when (file-exists? "gcc/config/rs6000")
280 ;; Force powerpc libdir to be /lib and not /lib64
281 (substitute* (find-files "gcc/config/rs6000")
282 (("/lib64") "/lib"))))
285 ;; Don't retain a dependency on the build-time sed.
286 (substitute* "fixincludes/fixincl.x"
287 (("static char const sed_cmd_z\\[\\] =.*;")
288 "static char const sed_cmd_z[] = \"sed\";"))
290 ;; Aarch64 support didn't land in GCC until the 4.8 series.
291 (when (file-exists? "gcc/config/aarch64")
292 ;; Force Aarch64 libdir to be /lib and not /lib64
293 (substitute* "gcc/config/aarch64/t-aarch64-linux"
296 (when (file-exists? "libbacktrace")
297 ;; GCC 4.8+ comes with libbacktrace. By default it builds
298 ;; with -Werror, which fails with a -Wcast-qual error in glibc
299 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
300 (substitute* "libbacktrace/configure"
301 (("WARN_FLAGS=(.*)-Werror" _ flags)
302 (string-append "WARN_FLAGS=" flags)))
304 (when (file-exists? "libsanitizer/libbacktrace")
305 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
306 (substitute* "libsanitizer/libbacktrace/Makefile.in"
310 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
311 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
312 ;; and <http://bugs.gnu.org/20358>.
313 (substitute* "libstdc++-v3/src/Makefile.in"
315 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
317 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
318 ;; circularity between "out" and "lib". (Note:
319 ;; --with-python-dir is useless because it imposes $(prefix) as
320 ;; the parent directory.)
321 (substitute* "libstdc++-v3/python/Makefile.in"
323 (string-append "pythondir = " libdir "/share"
324 "/gcc-$(gcc_version)/python\n")))
326 ;; Avoid another circularity between the outputs: this #define
327 ;; ends up in auto-host.h in the "lib" output, referring to
328 ;; "out". (This variable is used to augment cpp's search path,
329 ;; but there's nothing useful to look for here.)
330 (substitute* "gcc/config.in"
331 (("PREFIX_INCLUDE_DIR")
332 "PREFIX_INCLUDE_DIR_isnt_necessary_here"))
335 (add-after 'configure 'post-configure
337 ;; Don't store configure flags, to avoid retaining references to
338 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
339 (substitute* "Makefile"
340 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
341 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))
345 ;; Use the language-specific variables rather than 'CPATH' because they
346 ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
347 ;; The intent is to allow headers that are in the search path to be
348 ;; treated as "system headers" (headers exempt from warnings) just like
349 ;; the typical /usr/include headers on an FHS system.
350 (list (search-path-specification
351 (variable "C_INCLUDE_PATH")
352 (files '("include")))
353 (search-path-specification
354 (variable "CPLUS_INCLUDE_PATH")
355 ;; Add 'include/c++' here so that <cstdlib>'s "#include_next
356 ;; <stdlib.h>" finds GCC's <stdlib.h>, not libc's.
357 (files '("include/c++" "include")))
358 (search-path-specification
359 (variable "LIBRARY_PATH")
360 (files '("lib" "lib64")))))
362 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
363 (synopsis "GNU Compiler Collection")
365 "GCC is the GNU Compiler Collection. It provides compiler front-ends
366 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
367 Go. It also includes runtime support libraries for these languages.")
369 (supported-systems (delete "aarch64-linux" %supported-systems))
370 (home-page "https://gcc.gnu.org/")))))
372 (define-public gcc-4.8
373 (package (inherit gcc-4.7)
377 (uri (string-append "mirror://gnu/gcc/gcc-"
378 version "/gcc-" version ".tar.bz2"))
381 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
382 (patches (search-patches "gcc-arm-link-spec-fix.patch"
383 "gcc-4.8-libsanitizer-fix.patch"
384 "gcc-asan-missing-include.patch"
385 "gcc-fix-texi2pod.patch"))
386 (modules '((guix build utils)))
387 ;; This is required for building with glibc-2.26.
388 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
393 (substitute* (string-append "libgcc/config/"
394 dir "/linux-unwind.h")
395 (("struct ucontext") "ucontext_t")))
396 '("aarch64" "alpha" "bfin" "i386" "m68k"
397 "pa" "sh" "tilepro" "xtensa"))
399 (supported-systems %supported-systems)
403 ,@(package-inputs gcc-4.7)))))
405 (define-public gcc-4.9
406 (package (inherit gcc-4.8)
410 (uri (string-append "mirror://gnu/gcc/gcc-"
411 version "/gcc-" version ".tar.bz2"))
414 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
415 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
416 "gcc-4.9-libsanitizer-ustat.patch"
417 "gcc-4.9-libsanitizer-mode-size.patch"
418 "gcc-arm-bug-71399.patch"
419 "gcc-asan-missing-include.patch"
420 "gcc-libvtv-runpath.patch"
421 "gcc-fix-texi2pod.patch"))
422 (modules '((guix build utils)))
423 ;; This is required for building with glibc-2.26.
424 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
429 (substitute* (string-append "libgcc/config/"
430 dir "/linux-unwind.h")
431 (("struct ucontext") "ucontext_t")))
432 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
433 "pa" "sh" "tilepro" "xtensa"))
435 ;; Override inherited texinfo-5 with latest version.
436 (native-inputs `(("perl" ,perl) ;for manpages
437 ("texinfo" ,texinfo)))
439 (if (%current-target-system)
440 (package-arguments gcc-4.8)
441 ;; For native builds of GCC 4.9 and GCC 5, the C++ include path needs
442 ;; to be adjusted so it does not interfere with GCC's own build processes.
443 (substitute-keyword-arguments (package-arguments gcc-4.8)
444 ((#:modules modules %gnu-build-system-modules)
448 `(modify-phases ,phases
449 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
450 (lambda* (#:key inputs #:allow-other-keys)
451 (let ((libc (assoc-ref inputs "libc"))
452 (gcc (assoc-ref inputs "gcc")))
453 (setenv "CPLUS_INCLUDE_PATH"
454 (string-join (fold delete
455 (string-split (getenv "CPLUS_INCLUDE_PATH")
457 (list (string-append libc "/include")
458 (string-append gcc "/include/c++")))
461 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
462 (getenv "CPLUS_INCLUDE_PATH"))
466 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
467 ;; them in a VPATH build.
468 (package (inherit gcc-4.9)
472 (uri (string-append "mirror://gnu/gcc/gcc-"
473 version "/gcc-" version ".tar.xz"))
476 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
477 (patches (search-patches "gcc-arm-bug-71399.patch"
478 "gcc-libsanitizer-ustat.patch"
479 "gcc-strmov-store-file-names.patch"
480 "gcc-5.0-libvtv-runpath.patch"
481 "gcc-5-source-date-epoch-1.patch"
482 "gcc-5-source-date-epoch-2.patch"
483 "gcc-6-libsanitizer-mode-size.patch"
484 "gcc-fix-texi2pod.patch"
486 (modules '((guix build utils)))
488 ;; Fix 'libcc1/configure' error when cross-compiling GCC.
489 ;; Without that, 'libcc1/configure' wrongfully determines that
490 ;; '-rdynamic' support is missing because $gcc_cv_objdump is
493 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
494 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
496 (substitute* "libcc1/configure"
497 (("\\$gcc_cv_objdump -T")
498 "$OBJDUMP_FOR_TARGET -T"))
501 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
503 ,@(package-inputs gcc-4.7)))))
511 (uri (string-append "mirror://gnu/gcc/gcc-"
512 version "/gcc-" version ".tar.xz"))
515 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
516 (patches (search-patches "gcc-strmov-store-file-names.patch"
517 "gcc-6-libsanitizer-mode-size.patch"
518 "gcc-6-source-date-epoch-1.patch"
519 "gcc-6-source-date-epoch-2.patch"
520 "gcc-5.0-libvtv-runpath.patch"))))
522 ;; GCC 4.9 and 5 has a workaround that is not needed for GCC 6 and later.
523 (arguments (package-arguments gcc-4.8))
528 ;; XXX: This gross hack allows us to have libstdc++'s <bits/c++config.h>
529 ;; in the search path, thereby avoiding misconfiguration of libstdc++:
530 ;; <https://bugs.gnu.org/42392>.
531 ("libstdc++" ,libstdc++-headers)
533 ,@(package-inputs gcc-4.7)))))
541 (uri (string-append "mirror://gnu/gcc/gcc-"
542 version "/gcc-" version ".tar.xz"))
545 "0qg6kqc5l72hpnj4vr6l0p69qav0rh4anlkk3y55540zy3klc6dq"))
546 (patches (search-patches "gcc-strmov-store-file-names.patch"
547 "gcc-7-libsanitizer-mode-size.patch"
548 "gcc-5.0-libvtv-runpath.patch"))))
550 "GCC is the GNU Compiler Collection. It provides compiler front-ends
551 for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
552 It also includes runtime support libraries for these languages.")))
560 (uri (string-append "mirror://gnu/gcc/gcc-"
561 version "/gcc-" version ".tar.xz"))
564 "1m1d3gfix56w4aq8myazzfffkl8bqcrx4jhhapnjf7qfs596w2p3"))
565 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
566 "gcc-5.0-libvtv-runpath.patch"))))))
574 (uri (string-append "mirror://gnu/gcc/gcc-"
575 version "/gcc-" version ".tar.xz"))
578 "1la2yy27ziasyf0jvzk58y1i5b5bq2h176qil550bxhifs39gqbi"))
579 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
580 "gcc-9-asan-fix-limits-include.patch"
581 "gcc-5.0-libvtv-runpath.patch"))))))
583 (define-public gcc-10
589 (uri (string-append "mirror://gnu/gcc/gcc-"
590 version "/gcc-" version ".tar.xz"))
593 "130xdkhmz1bc2kzx061s3sfwk36xah1fw5w332c0nzwwpdl47pdq"))
594 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
595 "gcc-5.0-libvtv-runpath.patch"))))))
597 ;; Note: When changing the default gcc version, update
598 ;; the gcc-toolchain-* definitions.
599 (define-public gcc gcc-7)
601 (define-public (make-libstdc++ gcc)
602 "Return a libstdc++ package based on GCC. The primary use case is when
603 using compilers other than GCC."
608 `(#:out-of-source? #t
610 ;; TODO: Use the target-powerpc arm for everyone.
611 ,(if (target-powerpc?)
612 `(modify-phases %standard-phases
613 ;; Force rs6000 (i.e., powerpc) libdir to be /lib and not /lib64.
614 (add-before 'chdir 'fix-rs6000-libdir
616 (when (file-exists? "gcc/config/rs6000")
617 (substitute* (find-files "gcc/config/rs6000")
618 (("/lib64") "/lib")))
620 (add-before 'configure 'chdir
622 (chdir "libstdc++-v3")
624 `(alist-cons-before 'configure 'chdir
626 (chdir "libstdc++-v3")
630 #:configure-flags `("--disable-libstdcxx-pch"
631 ,(string-append "--with-gxx-include-dir="
632 (assoc-ref %outputs "out")
634 (outputs '("out" "debug"))
637 (propagated-inputs '())
638 (synopsis "GNU C++ standard library")))
641 ;; Libstdc++ matching the default GCC.
642 (make-libstdc++ gcc))
644 (define libstdc++-headers
645 ;; XXX: This package is for internal use to work around
646 ;; <https://bugs.gnu.org/42392> (see above). The main difference compared
647 ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>
648 ;; is right under include/c++ and not under
649 ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).
652 (name "libstdc++-headers")
654 (build-system trivial-build-system)
656 '(#:builder (let* ((out (assoc-ref %outputs "out"))
657 (libstdc++ (assoc-ref %build-inputs "libstdc++")))
659 (mkdir (string-append out "/include"))
660 (symlink (string-append libstdc++ "/include")
661 (string-append out "/include/c++")))))
662 (inputs `(("libstdc++" ,libstdc++)))
663 (synopsis "Headers of GNU libstdc++")))
665 (define-public libstdc++-4.9
666 (make-libstdc++ gcc-4.9))
668 (define (make-libiberty gcc)
669 "Return a libiberty package based on GCC."
674 `(#:out-of-source? #t
676 (modify-phases %standard-phases
677 (add-before 'configure 'chdir
682 (lambda* (#:key outputs #:allow-other-keys)
683 (let* ((out (assoc-ref outputs "out"))
684 (lib (string-append out "/lib/"))
685 (include (string-append out "/include/")))
686 (install-file "libiberty.a" lib)
687 (install-file "../include/libiberty.h" include))
692 (propagated-inputs '())
694 (synopsis "Collection of subroutines used by various GNU programs")))
696 (define-public libiberty
697 (make-libiberty gcc))
699 (define* (custom-gcc gcc name languages
701 (search-paths (package-native-search-paths gcc))
702 #:key (separate-lib-output? #t))
703 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
704 as the 'native-search-paths' field."
705 (package (inherit gcc)
707 (outputs (if separate-lib-output?
708 (package-outputs gcc)
709 (delete "lib" (package-outputs gcc))))
710 (native-search-paths search-paths)
711 (properties (alist-delete 'hidden? (package-properties gcc)))
713 (substitute-keyword-arguments (package-arguments gcc)
714 ((#:modules modules %gnu-build-system-modules)
719 ((#:configure-flags flags)
720 `(cons (string-append "--enable-languages="
721 ,(string-join languages ","))
722 (remove (cut string-match "--enable-languages.*" <>)
725 `(modify-phases ,phases
726 (add-after 'install 'remove-broken-or-conflicting-files
727 (lambda* (#:key outputs #:allow-other-keys)
728 (for-each delete-file
729 (find-files (string-append (assoc-ref outputs "out") "/bin")
730 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
733 (define %generic-search-paths
734 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
735 ;; not considered "system headers", which means GCC can raise warnings for
736 ;; issues in those headers. 'CPATH' is the only one that works for
737 ;; front-ends not in the C family.
738 (list (search-path-specification
740 (files '("include")))
741 (search-path-specification
742 (variable "LIBRARY_PATH")
743 (files '("lib" "lib64")))))
745 (define-public gfortran
749 ;; XXX: Remove LIBSTDC++-HEADERS from the inputs just to
750 ;; avoid a rebuild of all the GFORTRAN dependents.
751 ;; TODO: Remove this hack on the next rebuild cycle.
752 (inputs (alist-delete "libstdc++" (package-inputs gcc))))
753 "gfortran" '("fortran")
754 %generic-search-paths)))
756 (define-public gdc-10
758 (custom-gcc gcc-10 "gdc" '("d")
759 %generic-search-paths)))
761 (define-public libgccjit
765 (outputs (delete "lib" (package-outputs gcc)))
766 (properties (alist-delete 'hidden? (package-properties gcc)))
768 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
773 ,@(package-arguments gcc))
774 ((#:configure-flags flags)
775 `(append `("--enable-host-shared"
776 ,(string-append "--enable-languages=jit"))
777 (remove (cut string-match "--enable-languages.*" <>)
780 `(modify-phases ,phases
781 (add-after 'install 'remove-broken-or-conflicting-files
782 (lambda* (#:key outputs #:allow-other-keys)
783 (for-each delete-file
784 (find-files (string-append (assoc-ref outputs "out") "/bin")
785 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
787 (synopsis "GCC library generating machine code on-the-fly at runtime")
789 "This package is part of the GNU Compiler Collection and provides an
790 embeddable library for generating machine code on-the-fly at runtime. This
791 shared library can then be dynamically-linked into bytecode interpreters and
792 other such programs that want to generate machine code on-the-fly at run-time.
793 It can also be used for ahead-of-time code generation for building standalone
794 compilers. The just-in-time (jit) part of the name is now something of a
798 (define-public gccgo-4.9
801 (synopsis "Go frontend to GCC")
803 "This package is part of the GNU Compiler Collection and
804 provides the GNU compiler for the Go programming language."))
806 %generic-search-paths
807 ;; Suppress the separate "lib" output, because otherwise the
808 ;; "lib" and "out" outputs would refer to each other, creating
809 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
810 #:separate-lib-output? #f))
812 (define %objc-search-paths
813 (list (search-path-specification
814 (variable "OBJC_INCLUDE_PATH")
815 (files '("include")))
816 (search-path-specification
817 (variable "LIBRARY_PATH")
818 (files '("lib" "lib64")))))
820 (define-public gcc-objc-4.8
821 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
824 (define-public gcc-objc-4.9
825 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
828 (define-public gcc-objc-5
829 (custom-gcc gcc-5 "gcc-objc" '("objc")
832 (define-public gcc-objc-6
833 (custom-gcc gcc-6 "gcc-objc" '("objc")
836 (define-public gcc-objc-7
837 (custom-gcc gcc-7 "gcc-objc" '("objc")
840 (define-public gcc-objc-8
841 (custom-gcc gcc-8 "gcc-objc" '("objc")
844 (define-public gcc-objc-9
845 (custom-gcc gcc-9 "gcc-objc" '("objc")
848 (define-public gcc-objc-10
849 (custom-gcc gcc-10 "gcc-objc" '("objc")
852 (define-public gcc-objc gcc-objc-7)
854 (define %objc++-search-paths
855 (list (search-path-specification
856 (variable "OBJCPLUS_INCLUDE_PATH")
857 (files '("include")))
858 (search-path-specification
859 (variable "LIBRARY_PATH")
860 (files '("lib" "lib64")))))
862 (define-public gcc-objc++-4.8
863 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
864 %objc++-search-paths))
866 (define-public gcc-objc++-4.9
867 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
868 %objc++-search-paths))
870 (define-public gcc-objc++-5
871 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
872 %objc++-search-paths))
874 (define-public gcc-objc++-6
875 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
876 %objc++-search-paths))
878 (define-public gcc-objc++-7
879 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
880 %objc++-search-paths))
882 (define-public gcc-objc++-8
883 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
884 %objc++-search-paths))
886 (define-public gcc-objc++-9
887 (custom-gcc gcc-9 "gcc-objc++" '("obj-c++")
888 %objc++-search-paths))
890 (define-public gcc-objc++-10
891 (custom-gcc gcc-10 "gcc-objc++" '("obj-c++")
892 %objc++-search-paths))
894 (define-public gcc-objc++ gcc-objc++-7)
896 (define (make-libstdc++-doc gcc)
897 "Return a package with the libstdc++ documentation for GCC."
900 (name "libstdc++-doc")
901 (version (package-version gcc))
902 (synopsis "GNU libstdc++ documentation")
904 (native-inputs `(("doxygen" ,doxygen)
908 ("docbook-xml" ,docbook-xml)
909 ("docbook-xsl" ,docbook-xsl)
910 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
912 (propagated-inputs '())
914 '(#:out-of-source? #t
915 #:tests? #f ;it's just documentation
916 #:phases (modify-phases %standard-phases
917 (add-before 'configure 'chdir
919 (chdir "libstdc++-v3")
921 (add-before 'configure 'set-xsl-directory
922 (lambda* (#:key inputs #:allow-other-keys)
923 (let ((docbook (assoc-ref inputs "docbook-xsl")))
924 (substitute* (find-files "doc"
929 (strip-store-file-name docbook))))
933 ;; XXX: There's also a 'doc-info' target, but it
934 ;; relies on docbook2X, which itself relies on
935 ;; DocBook 4.1.2, which is not really usable
936 ;; (lacks a catalog.xml.)
941 (lambda* (#:key outputs #:allow-other-keys)
942 (let ((out (assoc-ref outputs "out")))
945 "doc-install-man")))))))
946 (properties (alist-delete 'hidden? (package-properties gcc)))))
948 (define-public libstdc++-doc-5
949 (make-libstdc++-doc gcc-5))
951 (define-public libstdc++-doc-9
952 (make-libstdc++-doc gcc-9))
960 (uri (list (string-append
961 "http://isl.gforge.inria.fr/isl-"
964 (string-append %gcc-infrastructure
965 name "-" version ".tar.bz2")))
968 "1kf54jib0nind1pvakblnfhimmwzm0y1llz8470ag0di5vwqwrhs"))))
969 (build-system gnu-build-system)
970 (outputs '("out" "static"))
972 '(#:phases (modify-phases %standard-phases
973 (add-after 'install 'move-static-library
974 (lambda* (#:key outputs #:allow-other-keys)
975 (let* ((out (assoc-ref outputs "out"))
976 (static (assoc-ref outputs "static"))
977 (source (string-append out "/lib/libisl.a"))
978 (target (string-append static "/lib/libisl.a")))
979 (mkdir-p (dirname target))
983 ;; Remove reference to libisl.a from the .la file so
984 ;; libtool looks for it in the usual locations.
985 (substitute* (string-append out "/lib/libisl.la")
989 (inputs `(("gmp" ,gmp)))
990 (home-page "http://isl.gforge.inria.fr/")
992 "Manipulating sets and relations of integer points \
993 bounded by linear constraints")
995 "isl is a library for manipulating sets and relations of integer points
996 bounded by linear constraints. Supported operations on sets include
997 intersection, union, set difference, emptiness check, convex hull, (integer)
998 affine hull, integer projection, computing the lexicographic minimum using
999 parametric integer programming, coalescing and parametric vertex
1000 enumeration. It also includes an ILP solver based on generalized basis
1001 reduction, transitive closures on maps (which may encode infinite graphs),
1002 dependence analysis and bounds on piecewise step-polynomials.")
1003 (license lgpl2.1+)))
1005 (define-public isl-0.18
1011 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
1013 (string-append %gcc-infrastructure
1014 "isl-" version ".tar.bz2")))
1017 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
1019 (define-public isl-0.11
1026 (uri (list (string-append
1027 "http://isl.gforge.inria.fr/isl-"
1030 (string-append %gcc-infrastructure
1031 name "-" version ".tar.bz2")))
1034 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
1035 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
1037 (define-public cloog
1044 (uri (list (string-append
1045 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
1048 (string-append %gcc-infrastructure
1049 name "-" version ".tar.gz")))
1052 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
1053 (file-name (string-append name "-" version ".tar.gz"))))
1054 (build-system gnu-build-system)
1055 (inputs `(("gmp" ,gmp)
1057 (arguments '(#:configure-flags '("--with-isl=system")))
1058 (home-page "http://www.cloog.org/")
1059 (synopsis "Library to generate code for scanning Z-polyhedra")
1061 "CLooG is a free software library to generate code for scanning
1062 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
1063 reaches each integral point of one or more parameterized polyhedra.
1064 CLooG has been originally written to solve the code generation problem
1065 for optimizing compilers based on the polytope model. Nevertheless it
1066 is used now in various area e.g., to build control automata for
1067 high-level synthesis or to find the best polynomial approximation of a
1068 function. CLooG may help in any situation where scanning polyhedra
1069 matters. While the user has full control on generated code quality,
1070 CLooG is designed to avoid control overhead and to produce a very
1074 (define-public gnu-c-manual
1076 (name "gnu-c-manual")
1080 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1084 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
1085 (build-system gnu-build-system)
1086 (native-inputs `(("texinfo" ,texinfo)))
1088 '(#:phases (modify-phases %standard-phases
1095 "gnu-c-manual.html")))
1097 (lambda* (#:key outputs #:allow-other-keys)
1098 (let* ((out (assoc-ref outputs "out"))
1099 (info (string-append out "/share/info"))
1100 (html (string-append
1101 out "/share/doc/gnu-c-manual")))
1105 (for-each (lambda (file)
1107 (string-append info "/"
1109 (find-files "." "\\.info(-[0-9])?$"))
1110 (for-each (lambda (file)
1112 (string-append html "/"
1114 (find-files "." "\\.html$"))
1116 (synopsis "Reference manual for the C programming language")
1118 "This is a reference manual for the C programming language, as
1119 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
1120 to be a tutorial of the language. Rather, it outlines all of the constructs
1121 of the language. Library functions are not included.")
1122 (home-page "https://www.gnu.org/software/gnu-c-manual/")