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, 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>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages gcc)
30 #:use-module ((guix licenses)
31 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
32 #:use-module (gnu packages)
33 #:use-module (gnu packages bootstrap)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages multiprecision)
36 #:use-module (gnu packages texinfo)
37 #:use-module (gnu packages dejagnu)
38 #:use-module (gnu packages documentation)
39 #:use-module (gnu packages xml)
40 #:use-module (gnu packages docbook)
41 #:use-module (gnu packages graphviz)
42 #:use-module (gnu packages elf)
43 #:use-module (gnu packages perl)
44 #:use-module (guix packages)
45 #:use-module (guix download)
46 #:use-module (guix build-system gnu)
47 #:use-module (guix build-system trivial)
48 #:use-module (guix utils)
49 #:use-module (srfi srfi-1)
50 #:use-module (ice-9 regex))
52 (define %gcc-infrastructure
53 ;; Base URL for GCC's infrastructure.
54 "mirror://gcc/infrastructure/")
56 (define (gcc-configure-flags-for-triplet target)
57 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
59 The purpose of this procedure is to translate extended GNU triplets---e.g.,
60 where the OS part is overloaded to denote a specific ABI---into GCC
61 `configure' options. We take extended GNU triplets that glibc recognizes."
62 (cond ((string-match "^mips64el.*gnuabin?64$" target)
63 ;; Triplets recognized by glibc as denoting the N64 ABI; see
64 ;; ports/sysdeps/mips/preconfigure.
67 ((string-match "^arm.*-gnueabihf$" target)
68 '("--with-arch=armv7-a"
73 ((and (string-suffix? "-gnu" target)
74 (not (string-contains target "-linux")))
75 ;; Cross-compilation of libcilkrts in GCC 5.5.0 to GNU/Hurd fails
77 ;; libcilkrts/runtime/os-unix.c:388:2: error: #error "Unknown architecture"
78 ;; Cilk has been removed from GCC 8 anyway.
79 '("--disable-libcilkrts"))
82 ;; TODO: Add `arm.*-gnueabi', etc.
85 (define-public gcc-4.7
86 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
89 ;; Return the `_FOR_TARGET' variables that are needed when
90 ;; cross-compiling GCC.
91 (let ((target (%current-target-system)))
93 (map (lambda (var tool)
94 (string-append (string-append var "_FOR_TARGET")
96 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
97 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
100 (let ((base '(or (assoc-ref outputs "lib")
101 (assoc-ref outputs "out"))))
103 ;; Return the directory that contains lib/libgcc_s.so et al.
104 (if (%current-target-system)
105 `(string-append ,base "/" ,(%current-target-system))
109 ;; This is terrible. Since we have two levels of quasiquotation,
110 ;; we have to do this convoluted thing just so we can insert the
111 ;; contents of (maybe-target-tools).
115 "--enable-languages=c,c++"
119 ;; No pre-compiled libstdc++ headers, to save space.
120 "--disable-libstdcxx-pch"
122 "--with-local-prefix=/no-gcc-local-prefix"
124 ;; With a separate "lib" output, the build system
125 ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force
126 ;; it. (Don't use a versioned sub-directory, that's
128 ,(string-append "--with-gxx-include-dir="
129 (assoc-ref %outputs "out")
132 ,(let ((libc (assoc-ref %build-inputs "libc")))
134 (string-append "--with-native-system-header-dir=" libc
136 "--without-headers")))
138 ;; Pass the right options for the target triplet.
140 (or (%current-target-system)
141 (nix-system->gnu-triplet (%current-system)))))
142 (gcc-configure-flags-for-triplet triplet))
144 (maybe-target-tools))))))
151 (uri (string-append "mirror://gnu/gcc/gcc-"
152 version "/gcc-" version ".tar.bz2"))
155 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
156 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
157 "gcc-fix-texi2pod.patch"))))
158 (build-system gnu-build-system)
160 ;; Separate out the run-time support libraries because all the
161 ;; dynamic-linked objects depend on it.
162 (outputs '("out" ;commands, etc. (60+ MiB)
163 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
164 "debug")) ;debug symbols of run-time libraries
166 (inputs `(("gmp" ,gmp)
172 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
173 ;; Newer texinfos fail to build the manual, so we use an older one.
174 (native-inputs `(("perl" ,perl) ;for manpages
175 ("texinfo" ,texinfo-5)))
178 `(#:out-of-source? #t
179 #:configure-flags ,(configure-flags)
181 ;; None of the flags below are needed when doing a Canadian cross.
182 ;; TODO: Simplify this.
183 ,(if (%current-target-system)
187 `(let* ((libc (assoc-ref %build-inputs "libc"))
188 (libc-native (or (assoc-ref %build-inputs "libc-native")
191 (list (string-append "LDFLAGS_FOR_TARGET="
193 "-Wl,-dynamic-linker "
195 ,(glibc-dynamic-linker)))
198 ;; Native programs like 'genhooks' also need that right.
199 ,(string-append "LDFLAGS="
200 "-Wl,-rpath=" libc-native "/lib "
201 "-Wl,-dynamic-linker "
202 "-Wl," libc-native ,(glibc-dynamic-linker))
203 ,(string-append "BOOT_CFLAGS=-O2 "
204 ,(if stripped? "-g0" "-g")))))
209 (modify-phases %standard-phases
210 (add-before 'configure 'pre-configure
211 (lambda* (#:key inputs outputs #:allow-other-keys)
212 (let ((libdir ,(libdir))
213 (libc (assoc-ref inputs "libc")))
215 ;; The following is not performed for `--without-headers'
216 ;; cross-compiler builds.
218 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
219 ;; single line, to allow the next step to work properly.
222 (substitute* (find-files "gcc/config"
223 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
224 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
228 ;; Fix the dynamic linker's file name.
229 (substitute* (find-files "gcc/config"
230 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
231 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
233 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
235 (string-append libc ,(glibc-dynamic-linker)))))
237 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
238 ;; `crt{begin,end}.o', which come with GCC.
239 (substitute* (find-files "gcc/config"
241 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
242 ;; Help libgcc_s.so be found (see also below.) Always use
243 ;; '-lgcc_s' so that libgcc_s.so is always found by those
244 ;; programs that use 'pthread_cancel' (glibc dlopens
245 ;; libgcc_s.so when pthread_cancel support is needed, but
246 ;; having it in the application's RUNPATH isn't enough; see
247 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
249 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
250 ;; later phase of %gcc-static. If you change the string
251 ;; below, make sure to update the relevant code in
252 ;; %gcc-static package as needed.
253 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
254 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
255 libc libc libdir suffix))
256 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
257 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
258 #define STANDARD_STARTFILE_PREFIX_2 \"\"
262 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
263 ;; GNU_USER_* defines. Do the above for this case.
265 "gcc/config/rs6000/sysv4.h"
266 (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
267 (format #f "#define LIB_LINUX_SPEC \
268 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
269 libc libc libdir suffix))
270 (("#define STARTFILE_LINUX_SPEC.*$" line)
271 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
272 #define STANDARD_STARTFILE_PREFIX_2 \"\"
276 ;; Don't retain a dependency on the build-time sed.
277 (substitute* "fixincludes/fixincl.x"
278 (("static char const sed_cmd_z\\[\\] =.*;")
279 "static char const sed_cmd_z[] = \"sed\";"))
281 ;; Aarch64 support didn't land in GCC until the 4.8 series.
282 (when (file-exists? "gcc/config/aarch64")
283 ;; Force Aarch64 libdir to be /lib and not /lib64
284 (substitute* "gcc/config/aarch64/t-aarch64-linux"
287 (when (file-exists? "libbacktrace")
288 ;; GCC 4.8+ comes with libbacktrace. By default it builds
289 ;; with -Werror, which fails with a -Wcast-qual error in glibc
290 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
291 (substitute* "libbacktrace/configure"
292 (("WARN_FLAGS=(.*)-Werror" _ flags)
293 (string-append "WARN_FLAGS=" flags)))
295 (when (file-exists? "libsanitizer/libbacktrace")
296 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
297 (substitute* "libsanitizer/libbacktrace/Makefile.in"
301 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
302 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
303 ;; and <http://bugs.gnu.org/20358>.
304 (substitute* "libstdc++-v3/src/Makefile.in"
306 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
308 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
309 ;; circularity between "out" and "lib". (Note:
310 ;; --with-python-dir is useless because it imposes $(prefix) as
311 ;; the parent directory.)
312 (substitute* "libstdc++-v3/python/Makefile.in"
314 (string-append "pythondir = " libdir "/share"
315 "/gcc-$(gcc_version)/python\n")))
317 ;; Avoid another circularity between the outputs: this #define
318 ;; ends up in auto-host.h in the "lib" output, referring to
319 ;; "out". (This variable is used to augment cpp's search path,
320 ;; but there's nothing useful to look for here.)
321 (substitute* "gcc/config.in"
322 (("PREFIX_INCLUDE_DIR")
323 "PREFIX_INCLUDE_DIR_isnt_necessary_here"))
326 (add-after 'configure 'post-configure
328 ;; Don't store configure flags, to avoid retaining references to
329 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
330 (substitute* "Makefile"
331 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
332 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))
336 ;; Use the language-specific variables rather than 'CPATH' because they
337 ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
338 ;; The intent is to allow headers that are in the search path to be
339 ;; treated as "system headers" (headers exempt from warnings) just like
340 ;; the typical /usr/include headers on an FHS system.
341 (list (search-path-specification
342 (variable "C_INCLUDE_PATH")
343 (files '("include")))
344 (search-path-specification
345 (variable "CPLUS_INCLUDE_PATH")
346 ;; Add 'include/c++' here so that <cstdlib>'s "#include_next
347 ;; <stdlib.h>" finds GCC's <stdlib.h>, not libc's.
348 (files '("include/c++" "include")))
349 (search-path-specification
350 (variable "LIBRARY_PATH")
351 (files '("lib" "lib64")))))
353 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
354 (synopsis "GNU Compiler Collection")
356 "GCC is the GNU Compiler Collection. It provides compiler front-ends
357 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
358 Go. It also includes runtime support libraries for these languages.")
360 (supported-systems (delete "aarch64-linux" %supported-systems))
361 (home-page "https://gcc.gnu.org/")))))
363 (define-public gcc-4.8
364 (package (inherit gcc-4.7)
368 (uri (string-append "mirror://gnu/gcc/gcc-"
369 version "/gcc-" version ".tar.bz2"))
372 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
373 (patches (search-patches "gcc-arm-link-spec-fix.patch"
374 "gcc-4.8-libsanitizer-fix.patch"
375 "gcc-asan-missing-include.patch"
376 "gcc-fix-texi2pod.patch"))
377 (modules '((guix build utils)))
378 ;; This is required for building with glibc-2.26.
379 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
384 (substitute* (string-append "libgcc/config/"
385 dir "/linux-unwind.h")
386 (("struct ucontext") "ucontext_t")))
387 '("aarch64" "alpha" "bfin" "i386" "m68k"
388 "pa" "sh" "tilepro" "xtensa"))
390 (supported-systems %supported-systems)
394 ,@(package-inputs gcc-4.7)))))
396 (define-public gcc-4.9
397 (package (inherit gcc-4.8)
401 (uri (string-append "mirror://gnu/gcc/gcc-"
402 version "/gcc-" version ".tar.bz2"))
405 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
406 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
407 "gcc-4.9-libsanitizer-ustat.patch"
408 "gcc-4.9-libsanitizer-mode-size.patch"
409 "gcc-arm-bug-71399.patch"
410 "gcc-asan-missing-include.patch"
411 "gcc-libvtv-runpath.patch"
412 "gcc-fix-texi2pod.patch"))
413 (modules '((guix build utils)))
414 ;; This is required for building with glibc-2.26.
415 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
420 (substitute* (string-append "libgcc/config/"
421 dir "/linux-unwind.h")
422 (("struct ucontext") "ucontext_t")))
423 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
424 "pa" "sh" "tilepro" "xtensa"))
426 ;; Override inherited texinfo-5 with latest version.
427 (native-inputs `(("perl" ,perl) ;for manpages
428 ("texinfo" ,texinfo)))
430 (if (%current-target-system)
431 (package-arguments gcc-4.8)
432 ;; For native builds of GCC 4.9 and GCC 5, the C++ include path needs
433 ;; to be adjusted so it does not interfere with GCC's own build processes.
434 (substitute-keyword-arguments (package-arguments gcc-4.8)
435 ((#:modules modules %gnu-build-system-modules)
439 `(modify-phases ,phases
440 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
441 (lambda* (#:key inputs #:allow-other-keys)
442 (let ((libc (assoc-ref inputs "libc"))
443 (gcc (assoc-ref inputs "gcc")))
444 (setenv "CPLUS_INCLUDE_PATH"
445 (string-join (fold delete
446 (string-split (getenv "CPLUS_INCLUDE_PATH")
448 (list (string-append libc "/include")
449 (string-append gcc "/include/c++")))
452 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
453 (getenv "CPLUS_INCLUDE_PATH"))
457 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
458 ;; them in a VPATH build.
459 (package (inherit gcc-4.9)
463 (uri (string-append "mirror://gnu/gcc/gcc-"
464 version "/gcc-" version ".tar.xz"))
467 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
468 (patches (search-patches "gcc-arm-bug-71399.patch"
469 "gcc-libsanitizer-ustat.patch"
470 "gcc-strmov-store-file-names.patch"
471 "gcc-5.0-libvtv-runpath.patch"
472 "gcc-5-source-date-epoch-1.patch"
473 "gcc-5-source-date-epoch-2.patch"
474 "gcc-6-libsanitizer-mode-size.patch"
475 "gcc-fix-texi2pod.patch"
477 (modules '((guix build utils)))
479 ;; Fix 'libcc1/configure' error when cross-compiling GCC.
480 ;; Without that, 'libcc1/configure' wrongfully determines that
481 ;; '-rdynamic' support is missing because $gcc_cv_objdump is
484 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
485 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
487 (substitute* "libcc1/configure"
488 (("\\$gcc_cv_objdump -T")
489 "$OBJDUMP_FOR_TARGET -T"))
492 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
494 ,@(package-inputs gcc-4.7)))))
502 (uri (string-append "mirror://gnu/gcc/gcc-"
503 version "/gcc-" version ".tar.xz"))
506 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
507 (patches (search-patches "gcc-strmov-store-file-names.patch"
508 "gcc-6-libsanitizer-mode-size.patch"
509 "gcc-6-source-date-epoch-1.patch"
510 "gcc-6-source-date-epoch-2.patch"
511 "gcc-5.0-libvtv-runpath.patch"))))
513 ;; GCC 4.9 and 5 has a workaround that is not needed for GCC 6 and later.
514 (arguments (package-arguments gcc-4.8))
519 ;; XXX: This gross hack allows us to have libstdc++'s <bits/c++config.h>
520 ;; in the search path, thereby avoiding misconfiguration of libstdc++:
521 ;; <https://bugs.gnu.org/42392>.
522 ("libstdc++" ,libstdc++-headers)
524 ,@(package-inputs gcc-4.7)))))
532 (uri (string-append "mirror://gnu/gcc/gcc-"
533 version "/gcc-" version ".tar.xz"))
536 "0qg6kqc5l72hpnj4vr6l0p69qav0rh4anlkk3y55540zy3klc6dq"))
537 (patches (search-patches "gcc-strmov-store-file-names.patch"
538 "gcc-7-libsanitizer-mode-size.patch"
539 "gcc-5.0-libvtv-runpath.patch"))))
541 "GCC is the GNU Compiler Collection. It provides compiler front-ends
542 for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
543 It also includes runtime support libraries for these languages.")))
551 (uri (string-append "mirror://gnu/gcc/gcc-"
552 version "/gcc-" version ".tar.xz"))
555 "1m1d3gfix56w4aq8myazzfffkl8bqcrx4jhhapnjf7qfs596w2p3"))
556 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
557 "gcc-5.0-libvtv-runpath.patch"))))))
565 (uri (string-append "mirror://gnu/gcc/gcc-"
566 version "/gcc-" version ".tar.xz"))
569 "1la2yy27ziasyf0jvzk58y1i5b5bq2h176qil550bxhifs39gqbi"))
570 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
571 "gcc-9-asan-fix-limits-include.patch"
572 "gcc-5.0-libvtv-runpath.patch"))))))
574 (define-public gcc-10
580 (uri (string-append "mirror://gnu/gcc/gcc-"
581 version "/gcc-" version ".tar.xz"))
584 "130xdkhmz1bc2kzx061s3sfwk36xah1fw5w332c0nzwwpdl47pdq"))
585 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
586 "gcc-5.0-libvtv-runpath.patch"))))))
588 ;; Note: When changing the default gcc version, update
589 ;; the gcc-toolchain-* definitions and the gfortran definition
591 (define-public gcc gcc-7)
593 (define-public (make-libstdc++ gcc)
594 "Return a libstdc++ package based on GCC. The primary use case is when
595 using compilers other than GCC."
600 `(#:out-of-source? #t
601 #:phases (alist-cons-before
604 (chdir "libstdc++-v3")
607 #:configure-flags `("--disable-libstdcxx-pch"
608 ,(string-append "--with-gxx-include-dir="
609 (assoc-ref %outputs "out")
611 (outputs '("out" "debug"))
614 (propagated-inputs '())
615 (synopsis "GNU C++ standard library")))
618 ;; Libstdc++ matching the default GCC.
619 (make-libstdc++ gcc))
621 (define libstdc++-headers
622 ;; XXX: This package is for internal use to work around
623 ;; <https://bugs.gnu.org/42392> (see above). The main difference compared
624 ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>
625 ;; is right under include/c++ and not under
626 ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).
629 (name "libstdc++-headers")
631 (build-system trivial-build-system)
633 '(#:builder (let* ((out (assoc-ref %outputs "out"))
634 (libstdc++ (assoc-ref %build-inputs "libstdc++")))
636 (mkdir (string-append out "/include"))
637 (symlink (string-append libstdc++ "/include")
638 (string-append out "/include/c++")))))
639 (inputs `(("libstdc++" ,libstdc++)))
640 (synopsis "Headers of GNU libstdc++")))
642 (define-public libstdc++-4.9
643 (make-libstdc++ gcc-4.9))
645 (define (make-libiberty gcc)
646 "Return a libiberty package based on GCC."
651 `(#:out-of-source? #t
653 (modify-phases %standard-phases
654 (add-before 'configure 'chdir
659 (lambda* (#:key outputs #:allow-other-keys)
660 (let* ((out (assoc-ref outputs "out"))
661 (lib (string-append out "/lib/"))
662 (include (string-append out "/include/")))
663 (install-file "libiberty.a" lib)
664 (install-file "../include/libiberty.h" include))
669 (propagated-inputs '())
671 (synopsis "Collection of subroutines used by various GNU programs")))
673 (define-public libiberty
674 (make-libiberty gcc))
676 (define* (custom-gcc gcc name languages
678 (search-paths (package-native-search-paths gcc))
679 #:key (separate-lib-output? #t))
680 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
681 as the 'native-search-paths' field."
682 (package (inherit gcc)
684 (outputs (if separate-lib-output?
685 (package-outputs gcc)
686 (delete "lib" (package-outputs gcc))))
687 (native-search-paths search-paths)
688 (properties (alist-delete 'hidden? (package-properties gcc)))
690 (substitute-keyword-arguments (package-arguments gcc)
691 ((#:modules modules %gnu-build-system-modules)
696 ((#:configure-flags flags)
697 `(cons (string-append "--enable-languages="
698 ,(string-join languages ","))
699 (remove (cut string-match "--enable-languages.*" <>)
702 `(modify-phases ,phases
703 (add-after 'install 'remove-broken-or-conflicting-files
704 (lambda* (#:key outputs #:allow-other-keys)
705 (for-each delete-file
706 (find-files (string-append (assoc-ref outputs "out") "/bin")
707 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
710 (define %generic-search-paths
711 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
712 ;; not considered "system headers", which means GCC can raise warnings for
713 ;; issues in those headers. 'CPATH' is the only one that works for
714 ;; front-ends not in the C family.
715 (list (search-path-specification
717 (files '("include")))
718 (search-path-specification
719 (variable "LIBRARY_PATH")
720 (files '("lib" "lib64")))))
722 (define-public gfortran
726 ;; XXX: Remove LIBSTDC++-HEADERS from the inputs just to
727 ;; avoid a rebuild of all the GFORTRAN dependents.
728 ;; TODO: Remove this hack on the next rebuild cycle.
729 (inputs (alist-delete "libstdc++" (package-inputs gcc))))
730 "gfortran" '("fortran")
731 %generic-search-paths)))
733 (define-public gdc-10
735 (custom-gcc gcc-10 "gdc" '("d")
736 %generic-search-paths)))
738 (define-public libgccjit
742 (outputs (delete "lib" (package-outputs gcc)))
743 (properties (alist-delete 'hidden? (package-properties gcc)))
745 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
750 ,@(package-arguments gcc))
751 ((#:configure-flags flags)
752 `(append `("--enable-host-shared"
753 ,(string-append "--enable-languages=jit"))
754 (remove (cut string-match "--enable-languages.*" <>)
757 `(modify-phases ,phases
758 (add-after 'install 'remove-broken-or-conflicting-files
759 (lambda* (#:key outputs #:allow-other-keys)
760 (for-each delete-file
761 (find-files (string-append (assoc-ref outputs "out") "/bin")
762 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
764 (synopsis "GCC library generating machine code on-the-fly at runtime")
766 "This package is part of the GNU Compiler Collection and provides an
767 embeddable library for generating machine code on-the-fly at runtime. This
768 shared library can then be dynamically-linked into bytecode interpreters and
769 other such programs that want to generate machine code on-the-fly at run-time.
770 It can also be used for ahead-of-time code generation for building standalone
771 compilers. The just-in-time (jit) part of the name is now something of a
775 (define-public gccgo-4.9
778 (synopsis "Go frontend to GCC")
780 "This package is part of the GNU Compiler Collection and
781 provides the GNU compiler for the Go programming language."))
783 %generic-search-paths
784 ;; Suppress the separate "lib" output, because otherwise the
785 ;; "lib" and "out" outputs would refer to each other, creating
786 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
787 #:separate-lib-output? #f))
789 (define %objc-search-paths
790 (list (search-path-specification
791 (variable "OBJC_INCLUDE_PATH")
792 (files '("include")))
793 (search-path-specification
794 (variable "LIBRARY_PATH")
795 (files '("lib" "lib64")))))
797 (define-public gcc-objc-4.8
798 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
801 (define-public gcc-objc-4.9
802 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
805 (define-public gcc-objc-5
806 (custom-gcc gcc-5 "gcc-objc" '("objc")
809 (define-public gcc-objc-6
810 (custom-gcc gcc-6 "gcc-objc" '("objc")
813 (define-public gcc-objc-7
814 (custom-gcc gcc-7 "gcc-objc" '("objc")
817 (define-public gcc-objc-8
818 (custom-gcc gcc-8 "gcc-objc" '("objc")
821 (define-public gcc-objc-9
822 (custom-gcc gcc-9 "gcc-objc" '("objc")
825 (define-public gcc-objc-10
826 (custom-gcc gcc-10 "gcc-objc" '("objc")
829 (define-public gcc-objc gcc-objc-7)
831 (define %objc++-search-paths
832 (list (search-path-specification
833 (variable "OBJCPLUS_INCLUDE_PATH")
834 (files '("include")))
835 (search-path-specification
836 (variable "LIBRARY_PATH")
837 (files '("lib" "lib64")))))
839 (define-public gcc-objc++-4.8
840 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
841 %objc++-search-paths))
843 (define-public gcc-objc++-4.9
844 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
845 %objc++-search-paths))
847 (define-public gcc-objc++-5
848 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
849 %objc++-search-paths))
851 (define-public gcc-objc++-6
852 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
853 %objc++-search-paths))
855 (define-public gcc-objc++-7
856 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
857 %objc++-search-paths))
859 (define-public gcc-objc++-8
860 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
861 %objc++-search-paths))
863 (define-public gcc-objc++-9
864 (custom-gcc gcc-9 "gcc-objc++" '("obj-c++")
865 %objc++-search-paths))
867 (define-public gcc-objc++-10
868 (custom-gcc gcc-10 "gcc-objc++" '("obj-c++")
869 %objc++-search-paths))
871 (define-public gcc-objc++ gcc-objc++-7)
873 (define (make-libstdc++-doc gcc)
874 "Return a package with the libstdc++ documentation for GCC."
877 (name "libstdc++-doc")
878 (version (package-version gcc))
879 (synopsis "GNU libstdc++ documentation")
881 (native-inputs `(("doxygen" ,doxygen)
885 ("docbook-xml" ,docbook-xml)
886 ("docbook-xsl" ,docbook-xsl)
887 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
889 (propagated-inputs '())
891 '(#:out-of-source? #t
892 #:tests? #f ;it's just documentation
893 #:phases (modify-phases %standard-phases
894 (add-before 'configure 'chdir
896 (chdir "libstdc++-v3")
898 (add-before 'configure 'set-xsl-directory
899 (lambda* (#:key inputs #:allow-other-keys)
900 (let ((docbook (assoc-ref inputs "docbook-xsl")))
901 (substitute* (find-files "doc"
906 (strip-store-file-name docbook))))
910 ;; XXX: There's also a 'doc-info' target, but it
911 ;; relies on docbook2X, which itself relies on
912 ;; DocBook 4.1.2, which is not really usable
913 ;; (lacks a catalog.xml.)
918 (lambda* (#:key outputs #:allow-other-keys)
919 (let ((out (assoc-ref outputs "out")))
922 "doc-install-man")))))))
923 (properties (alist-delete 'hidden? (package-properties gcc)))))
925 (define-public libstdc++-doc-5
926 (make-libstdc++-doc gcc-5))
928 (define-public libstdc++-doc-9
929 (make-libstdc++-doc gcc-9))
937 (uri (list (string-append
938 "http://isl.gforge.inria.fr/isl-"
941 (string-append %gcc-infrastructure
942 name "-" version ".tar.bz2")))
945 "1kf54jib0nind1pvakblnfhimmwzm0y1llz8470ag0di5vwqwrhs"))))
946 (build-system gnu-build-system)
947 (outputs '("out" "static"))
949 '(#:phases (modify-phases %standard-phases
950 (add-after 'install 'move-static-library
951 (lambda* (#:key outputs #:allow-other-keys)
952 (let* ((out (assoc-ref outputs "out"))
953 (static (assoc-ref outputs "static"))
954 (source (string-append out "/lib/libisl.a"))
955 (target (string-append static "/lib/libisl.a")))
956 (mkdir-p (dirname target))
960 ;; Remove reference to libisl.a from the .la file so
961 ;; libtool looks for it in the usual locations.
962 (substitute* (string-append out "/lib/libisl.la")
966 (inputs `(("gmp" ,gmp)))
967 (home-page "http://isl.gforge.inria.fr/")
969 "Manipulating sets and relations of integer points \
970 bounded by linear constraints")
972 "isl is a library for manipulating sets and relations of integer points
973 bounded by linear constraints. Supported operations on sets include
974 intersection, union, set difference, emptiness check, convex hull, (integer)
975 affine hull, integer projection, computing the lexicographic minimum using
976 parametric integer programming, coalescing and parametric vertex
977 enumeration. It also includes an ILP solver based on generalized basis
978 reduction, transitive closures on maps (which may encode infinite graphs),
979 dependence analysis and bounds on piecewise step-polynomials.")
982 (define-public isl-0.18
988 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
990 (string-append %gcc-infrastructure
991 "isl-" version ".tar.bz2")))
994 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
996 (define-public isl-0.11
1003 (uri (list (string-append
1004 "http://isl.gforge.inria.fr/isl-"
1007 (string-append %gcc-infrastructure
1008 name "-" version ".tar.bz2")))
1011 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
1012 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
1014 (define-public cloog
1021 (uri (list (string-append
1022 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
1025 (string-append %gcc-infrastructure
1026 name "-" version ".tar.gz")))
1029 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
1030 (file-name (string-append name "-" version ".tar.gz"))))
1031 (build-system gnu-build-system)
1032 (inputs `(("gmp" ,gmp)
1034 (arguments '(#:configure-flags '("--with-isl=system")))
1035 (home-page "http://www.cloog.org/")
1036 (synopsis "Library to generate code for scanning Z-polyhedra")
1038 "CLooG is a free software library to generate code for scanning
1039 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
1040 reaches each integral point of one or more parameterized polyhedra.
1041 CLooG has been originally written to solve the code generation problem
1042 for optimizing compilers based on the polytope model. Nevertheless it
1043 is used now in various area e.g., to build control automata for
1044 high-level synthesis or to find the best polynomial approximation of a
1045 function. CLooG may help in any situation where scanning polyhedra
1046 matters. While the user has full control on generated code quality,
1047 CLooG is designed to avoid control overhead and to produce a very
1051 (define-public gnu-c-manual
1053 (name "gnu-c-manual")
1057 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1061 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
1062 (build-system gnu-build-system)
1063 (native-inputs `(("texinfo" ,texinfo)))
1065 '(#:phases (modify-phases %standard-phases
1072 "gnu-c-manual.html")))
1074 (lambda* (#:key outputs #:allow-other-keys)
1075 (let* ((out (assoc-ref outputs "out"))
1076 (info (string-append out "/share/info"))
1077 (html (string-append
1078 out "/share/doc/gnu-c-manual")))
1082 (for-each (lambda (file)
1084 (string-append info "/"
1086 (find-files "." "\\.info(-[0-9])?$"))
1087 (for-each (lambda (file)
1089 (string-append html "/"
1091 (find-files "." "\\.html$"))
1093 (synopsis "Reference manual for the C programming language")
1095 "This is a reference manual for the C programming language, as
1096 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
1097 to be a tutorial of the language. Rather, it outlines all of the constructs
1098 of the language. Library functions are not included.")
1099 (home-page "https://www.gnu.org/software/gnu-c-manual/")