gnu: Add goxel.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
6 ;;; Copyright © 2015, 2016, 2017, 2018, 2020 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll@gmail.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018, 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 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
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.
20 ;;;
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.
25 ;;;
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/>.
28
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))
51
52 (define %gcc-infrastructure
53 ;; Base URL for GCC's infrastructure.
54 "mirror://gcc/infrastructure/")
55
56 (define (gcc-configure-flags-for-triplet target)
57 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
58
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.
65 '("--with-abi=64"))
66
67 ((string-match "^arm.*-gnueabihf$" target)
68 '("--with-arch=armv7-a"
69 "--with-float=hard"
70 "--with-mode=thumb"
71 "--with-fpu=neon"))
72
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
76 ;; with:
77 ;; libcilkrts/runtime/os-unix.c:388:2: error: #error "Unknown architecture"
78 ;; Cilk has been removed from GCC 8 anyway.
79 '("--disable-libcilkrts"))
80
81 (else
82 ;; TODO: Add `arm.*-gnueabi', etc.
83 '())))
84
85 (define-public gcc-4.7
86 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
87 (maybe-target-tools
88 (lambda ()
89 ;; Return the `_FOR_TARGET' variables that are needed when
90 ;; cross-compiling GCC.
91 (let ((target (%current-target-system)))
92 (if target
93 (map (lambda (var tool)
94 (string-append (string-append var "_FOR_TARGET")
95 "=" target "-" tool))
96 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
97 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
98 '()))))
99 (libdir
100 (let ((base '(or (assoc-ref outputs "lib")
101 (assoc-ref outputs "out"))))
102 (lambda ()
103 ;; Return the directory that contains lib/libgcc_s.so et al.
104 (if (%current-target-system)
105 `(string-append ,base "/" ,(%current-target-system))
106 base))))
107 (configure-flags
108 (lambda ()
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).
112 (list 'quasiquote
113 (append
114 '("--enable-plugin"
115 "--enable-languages=c,c++"
116 "--disable-multilib"
117 "--with-system-zlib"
118
119 ;; No pre-compiled libstdc++ headers, to save space.
120 "--disable-libstdcxx-pch"
121
122 "--with-local-prefix=/no-gcc-local-prefix"
123
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
127 ;; unnecessary.)
128 ,(string-append "--with-gxx-include-dir="
129 (assoc-ref %outputs "out")
130 "/include/c++")
131
132 ,(let ((libc (assoc-ref %build-inputs "libc")))
133 (if libc
134 (string-append "--with-native-system-header-dir=" libc
135 "/include")
136 "--without-headers")))
137
138 ;; Pass the right options for the target triplet.
139 (let ((triplet
140 (or (%current-target-system)
141 (nix-system->gnu-triplet (%current-system)))))
142 (gcc-configure-flags-for-triplet triplet))
143
144 (maybe-target-tools))))))
145 (hidden-package
146 (package
147 (name "gcc")
148 (version "4.7.4")
149 (source (origin
150 (method url-fetch)
151 (uri (string-append "mirror://gnu/gcc/gcc-"
152 version "/gcc-" version ".tar.bz2"))
153 (sha256
154 (base32
155 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
156 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
157 "gcc-fix-texi2pod.patch"))))
158 (build-system gnu-build-system)
159
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
165
166 (inputs `(("gmp" ,gmp)
167 ("mpfr" ,mpfr)
168 ("mpc" ,mpc)
169 ("libelf" ,libelf)
170 ("zlib" ,zlib)))
171
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)))
176
177 (arguments
178 `(#:out-of-source? #t
179 #:configure-flags ,(configure-flags)
180 #:make-flags
181 ;; None of the flags below are needed when doing a Canadian cross.
182 ;; TODO: Simplify this.
183 ,(if (%current-target-system)
184 (if stripped?
185 ''("CFLAGS=-g0 -O2")
186 ''())
187 `(let* ((libc (assoc-ref %build-inputs "libc"))
188 (libc-native (or (assoc-ref %build-inputs "libc-native")
189 libc)))
190 `(,@(if libc
191 (list (string-append "LDFLAGS_FOR_TARGET="
192 "-B" libc "/lib "
193 "-Wl,-dynamic-linker "
194 "-Wl," libc
195 ,(glibc-dynamic-linker)))
196 '())
197
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")))))
205
206 #:tests? #f
207
208 #:phases
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")))
214 (when libc
215 ;; The following is not performed for `--without-headers'
216 ;; cross-compiler builds.
217
218 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
219 ;; single line, to allow the next step to work properly.
220 (for-each
221 (lambda (x)
222 (substitute* (find-files "gcc/config"
223 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
224 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
225 line)))
226 '(1 2 3))
227
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]*).*$"
232 _ gnu-user suffix)
233 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
234 gnu-user suffix
235 (string-append libc ,(glibc-dynamic-linker)))))
236
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"
240 "^gnu-user.*\\.h$")
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>.)
248 ;;
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 \"\"
259 ~a"
260 libc line)))
261
262 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
263 ;; GNU_USER_* defines. Do the above for this case.
264 (substitute*
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 \"\"
273 ~a"
274 libc line))))
275
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\";"))
280
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"
285 (("lib64") "lib")))
286
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)))
294
295 (when (file-exists? "libsanitizer/libbacktrace")
296 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
297 (substitute* "libsanitizer/libbacktrace/Makefile.in"
298 (("-Werror")
299 ""))))
300
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"
305 (("^OPT_LDFLAGS = ")
306 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
307
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"
313 (("pythondir = .*$")
314 (string-append "pythondir = " libdir "/share"
315 "/gcc-$(gcc_version)/python\n")))
316
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"))
324 #t)))
325
326 (add-after 'configure 'post-configure
327 (lambda _
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"))
333 #t)))))
334
335 (native-search-paths
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")))))
352
353 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
354 (synopsis "GNU Compiler Collection")
355 (description
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.")
359 (license gpl3+)
360 (supported-systems (delete "aarch64-linux" %supported-systems))
361 (home-page "https://gcc.gnu.org/")))))
362
363 (define-public gcc-4.8
364 (package (inherit gcc-4.7)
365 (version "4.8.5")
366 (source (origin
367 (method url-fetch)
368 (uri (string-append "mirror://gnu/gcc/gcc-"
369 version "/gcc-" version ".tar.bz2"))
370 (sha256
371 (base32
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
380 (snippet
381 '(begin
382 (for-each
383 (lambda (dir)
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"))
389 #t))))
390 (supported-systems %supported-systems)
391 (inputs
392 `(("isl" ,isl-0.11)
393 ("cloog" ,cloog)
394 ,@(package-inputs gcc-4.7)))))
395
396 (define-public gcc-4.9
397 (package (inherit gcc-4.8)
398 (version "4.9.4")
399 (source (origin
400 (method url-fetch)
401 (uri (string-append "mirror://gnu/gcc/gcc-"
402 version "/gcc-" version ".tar.bz2"))
403 (sha256
404 (base32
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
416 (snippet
417 '(begin
418 (for-each
419 (lambda (dir)
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"))
425 #t))))
426 ;; Override inherited texinfo-5 with latest version.
427 (native-inputs `(("perl" ,perl) ;for manpages
428 ("texinfo" ,texinfo)))
429 (arguments
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)
436 `((srfi srfi-1)
437 ,@modules))
438 ((#:phases phases)
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")
447 #\:)
448 (list (string-append libc "/include")
449 (string-append gcc "/include/c++")))
450 ":"))
451 (format #t
452 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
453 (getenv "CPLUS_INCLUDE_PATH"))
454 #t))))))))))
455
456 (define-public gcc-5
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)
460 (version "5.5.0")
461 (source (origin
462 (method url-fetch)
463 (uri (string-append "mirror://gnu/gcc/gcc-"
464 version "/gcc-" version ".tar.xz"))
465 (sha256
466 (base32
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"
476 "gcc-5-hurd.patch"))
477 (modules '((guix build utils)))
478 (snippet
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
482 ;; empty:
483 ;;
484 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
485 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
486 '(begin
487 (substitute* "libcc1/configure"
488 (("\\$gcc_cv_objdump -T")
489 "$OBJDUMP_FOR_TARGET -T"))
490 #t))))
491 (inputs
492 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
493 ("isl" ,isl-0.18)
494 ,@(package-inputs gcc-4.7)))))
495
496 (define-public gcc-6
497 (package
498 (inherit gcc-5)
499 (version "6.5.0")
500 (source (origin
501 (method url-fetch)
502 (uri (string-append "mirror://gnu/gcc/gcc-"
503 version "/gcc-" version ".tar.xz"))
504 (sha256
505 (base32
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"))))
512
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))
515
516 (inputs
517 `(("isl" ,isl)
518
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)
523
524 ,@(package-inputs gcc-4.7)))))
525
526 (define-public gcc-7
527 (package
528 (inherit gcc-6)
529 (version "7.5.0")
530 (source (origin
531 (method url-fetch)
532 (uri (string-append "mirror://gnu/gcc/gcc-"
533 version "/gcc-" version ".tar.xz"))
534 (sha256
535 (base32
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"))))
540 (description
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.")))
544
545 (define-public gcc-8
546 (package
547 (inherit gcc-7)
548 (version "8.4.0")
549 (source (origin
550 (method url-fetch)
551 (uri (string-append "mirror://gnu/gcc/gcc-"
552 version "/gcc-" version ".tar.xz"))
553 (sha256
554 (base32
555 "1m1d3gfix56w4aq8myazzfffkl8bqcrx4jhhapnjf7qfs596w2p3"))
556 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
557 "gcc-5.0-libvtv-runpath.patch"))))))
558
559 (define-public gcc-9
560 (package
561 (inherit gcc-8)
562 (version "9.3.0")
563 (source (origin
564 (method url-fetch)
565 (uri (string-append "mirror://gnu/gcc/gcc-"
566 version "/gcc-" version ".tar.xz"))
567 (sha256
568 (base32
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"))))))
573
574 (define-public gcc-10
575 (package
576 (inherit gcc-8)
577 (version "10.2.0")
578 (source (origin
579 (method url-fetch)
580 (uri (string-append "mirror://gnu/gcc/gcc-"
581 version "/gcc-" version ".tar.xz"))
582 (sha256
583 (base32
584 "130xdkhmz1bc2kzx061s3sfwk36xah1fw5w332c0nzwwpdl47pdq"))
585 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
586 "gcc-5.0-libvtv-runpath.patch"))))))
587
588 ;; Note: When changing the default gcc version, update
589 ;; the gcc-toolchain-* definitions and the gfortran definition
590 ;; accordingly.
591 (define-public gcc gcc-7)
592
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."
596 (package
597 (inherit gcc)
598 (name "libstdc++")
599 (arguments
600 `(#:out-of-source? #t
601 #:phases (alist-cons-before
602 'configure 'chdir
603 (lambda _
604 (chdir "libstdc++-v3")
605 #t)
606 %standard-phases)
607 #:configure-flags `("--disable-libstdcxx-pch"
608 ,(string-append "--with-gxx-include-dir="
609 (assoc-ref %outputs "out")
610 "/include"))))
611 (outputs '("out" "debug"))
612 (inputs '())
613 (native-inputs '())
614 (propagated-inputs '())
615 (synopsis "GNU C++ standard library")))
616
617 (define libstdc++
618 ;; Libstdc++ matching the default GCC.
619 (make-libstdc++ gcc))
620
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).
627 (package
628 (inherit libstdc++)
629 (name "libstdc++-headers")
630 (outputs '("out"))
631 (build-system trivial-build-system)
632 (arguments
633 '(#:builder (let* ((out (assoc-ref %outputs "out"))
634 (libstdc++ (assoc-ref %build-inputs "libstdc++")))
635 (mkdir out)
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++")))
641
642 (define-public libstdc++-4.9
643 (make-libstdc++ gcc-4.9))
644
645 (define (make-libiberty gcc)
646 "Return a libiberty package based on GCC."
647 (package
648 (inherit gcc)
649 (name "libiberty")
650 (arguments
651 `(#:out-of-source? #t
652 #:phases
653 (modify-phases %standard-phases
654 (add-before 'configure 'chdir
655 (lambda _
656 (chdir "libiberty")
657 #t))
658 (replace 'install
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))
665 #t)))))
666 (inputs '())
667 (outputs '("out"))
668 (native-inputs '())
669 (propagated-inputs '())
670 (properties '())
671 (synopsis "Collection of subroutines used by various GNU programs")))
672
673 (define-public libiberty
674 (make-libiberty gcc))
675
676 (define* (custom-gcc gcc name languages
677 #:optional
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)
683 (name name)
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)))
689 (arguments
690 (substitute-keyword-arguments (package-arguments gcc)
691 ((#:modules modules %gnu-build-system-modules)
692 `(,@modules
693 (srfi srfi-1)
694 (srfi srfi-26)
695 (ice-9 regex)))
696 ((#:configure-flags flags)
697 `(cons (string-append "--enable-languages="
698 ,(string-join languages ","))
699 (remove (cut string-match "--enable-languages.*" <>)
700 ,flags)))
701 ((#:phases phases)
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-.*)"))
708 #t))))))))
709
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
716 (variable "CPATH")
717 (files '("include")))
718 (search-path-specification
719 (variable "LIBRARY_PATH")
720 (files '("lib" "lib64")))))
721
722 (define-public gfortran
723 (hidden-package
724 (custom-gcc (package
725 (inherit gcc)
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)))
732
733 (define-public gdc-10
734 (hidden-package
735 (custom-gcc gcc-10 "gdc" '("d")
736 %generic-search-paths)))
737
738 (define-public libgccjit
739 (package
740 (inherit gcc-9)
741 (name "libgccjit")
742 (outputs (delete "lib" (package-outputs gcc)))
743 (properties (alist-delete 'hidden? (package-properties gcc)))
744 (arguments
745 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
746 (guix build utils)
747 (ice-9 regex)
748 (srfi srfi-1)
749 (srfi srfi-26))
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.*" <>)
755 ,flags)))
756 ((#:phases phases)
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-.*)"))
763 #t))))))
764 (synopsis "GCC library generating machine code on-the-fly at runtime")
765 (description
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
772 misnomer.")))
773
774
775 (define-public gccgo-4.9
776 (custom-gcc (package
777 (inherit gcc-4.9)
778 (synopsis "Go frontend to GCC")
779 (description
780 "This package is part of the GNU Compiler Collection and
781 provides the GNU compiler for the Go programming language."))
782 "gccgo" '("go")
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))
788
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")))))
796
797 (define-public gcc-objc-4.8
798 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
799 %objc-search-paths))
800
801 (define-public gcc-objc-4.9
802 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
803 %objc-search-paths))
804
805 (define-public gcc-objc-5
806 (custom-gcc gcc-5 "gcc-objc" '("objc")
807 %objc-search-paths))
808
809 (define-public gcc-objc-6
810 (custom-gcc gcc-6 "gcc-objc" '("objc")
811 %objc-search-paths))
812
813 (define-public gcc-objc-7
814 (custom-gcc gcc-7 "gcc-objc" '("objc")
815 %objc-search-paths))
816
817 (define-public gcc-objc-8
818 (custom-gcc gcc-8 "gcc-objc" '("objc")
819 %objc-search-paths))
820
821 (define-public gcc-objc-9
822 (custom-gcc gcc-9 "gcc-objc" '("objc")
823 %objc-search-paths))
824
825 (define-public gcc-objc-10
826 (custom-gcc gcc-10 "gcc-objc" '("objc")
827 %objc-search-paths))
828
829 (define-public gcc-objc gcc-objc-7)
830
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")))))
838
839 (define-public gcc-objc++-4.8
840 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
841 %objc++-search-paths))
842
843 (define-public gcc-objc++-4.9
844 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
845 %objc++-search-paths))
846
847 (define-public gcc-objc++-5
848 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
849 %objc++-search-paths))
850
851 (define-public gcc-objc++-6
852 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
853 %objc++-search-paths))
854
855 (define-public gcc-objc++-7
856 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
857 %objc++-search-paths))
858
859 (define-public gcc-objc++-8
860 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
861 %objc++-search-paths))
862
863 (define-public gcc-objc++-9
864 (custom-gcc gcc-9 "gcc-objc++" '("obj-c++")
865 %objc++-search-paths))
866
867 (define-public gcc-objc++-10
868 (custom-gcc gcc-10 "gcc-objc++" '("obj-c++")
869 %objc++-search-paths))
870
871 (define-public gcc-objc++ gcc-objc++-7)
872
873 (define (make-libstdc++-doc gcc)
874 "Return a package with the libstdc++ documentation for GCC."
875 (package
876 (inherit gcc)
877 (name "libstdc++-doc")
878 (version (package-version gcc))
879 (synopsis "GNU libstdc++ documentation")
880 (outputs '("out"))
881 (native-inputs `(("doxygen" ,doxygen)
882 ("texinfo" ,texinfo)
883 ("libxml2" ,libxml2)
884 ("libxslt" ,libxslt)
885 ("docbook-xml" ,docbook-xml)
886 ("docbook-xsl" ,docbook-xsl)
887 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
888 (inputs '())
889 (propagated-inputs '())
890 (arguments
891 '(#:out-of-source? #t
892 #:tests? #f ;it's just documentation
893 #:phases (modify-phases %standard-phases
894 (add-before 'configure 'chdir
895 (lambda _
896 (chdir "libstdc++-v3")
897 #t))
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"
902 "^Makefile\\.in$")
903 (("@XSL_STYLE_DIR@")
904 (string-append
905 docbook "/xml/xsl/"
906 (strip-store-file-name docbook))))
907 #t)))
908 (replace 'build
909 (lambda _
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.)
914 (invoke "make"
915 "doc-html"
916 "doc-man")))
917 (replace 'install
918 (lambda* (#:key outputs #:allow-other-keys)
919 (let ((out (assoc-ref outputs "out")))
920 (invoke "make"
921 "doc-install-html"
922 "doc-install-man")))))))
923 (properties (alist-delete 'hidden? (package-properties gcc)))))
924
925 (define-public libstdc++-doc-5
926 (make-libstdc++-doc gcc-5))
927
928 (define-public libstdc++-doc-9
929 (make-libstdc++-doc gcc-9))
930
931 (define-public isl
932 (package
933 (name "isl")
934 (version "0.22.1")
935 (source (origin
936 (method url-fetch)
937 (uri (list (string-append
938 "http://isl.gforge.inria.fr/isl-"
939 version
940 ".tar.bz2")
941 (string-append %gcc-infrastructure
942 name "-" version ".tar.bz2")))
943 (sha256
944 (base32
945 "1kf54jib0nind1pvakblnfhimmwzm0y1llz8470ag0di5vwqwrhs"))))
946 (build-system gnu-build-system)
947 (outputs '("out" "static"))
948 (arguments
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))
957 (link source target)
958 (delete-file source)
959
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")
963 (("^old_library=.*")
964 "old_library=''\n"))
965 #t))))))
966 (inputs `(("gmp" ,gmp)))
967 (home-page "http://isl.gforge.inria.fr/")
968 (synopsis
969 "Manipulating sets and relations of integer points \
970 bounded by linear constraints")
971 (description
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.")
980 (license lgpl2.1+)))
981
982 (define-public isl-0.18
983 (package
984 (inherit isl)
985 (version "0.18")
986 (source (origin
987 (method url-fetch)
988 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
989 version ".tar.bz2")
990 (string-append %gcc-infrastructure
991 "isl-" version ".tar.bz2")))
992 (sha256
993 (base32
994 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
995
996 (define-public isl-0.11
997 (package
998 (inherit isl)
999 (name "isl")
1000 (version "0.11.1")
1001 (source (origin
1002 (method url-fetch)
1003 (uri (list (string-append
1004 "http://isl.gforge.inria.fr/isl-"
1005 version
1006 ".tar.bz2")
1007 (string-append %gcc-infrastructure
1008 name "-" version ".tar.bz2")))
1009 (sha256
1010 (base32
1011 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
1012 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
1013
1014 (define-public cloog
1015 (package
1016 (name "cloog")
1017 (version "0.18.0")
1018 (source
1019 (origin
1020 (method url-fetch)
1021 (uri (list (string-append
1022 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
1023 version
1024 ".tar.gz")
1025 (string-append %gcc-infrastructure
1026 name "-" version ".tar.gz")))
1027 (sha256
1028 (base32
1029 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
1030 (file-name (string-append name "-" version ".tar.gz"))))
1031 (build-system gnu-build-system)
1032 (inputs `(("gmp" ,gmp)
1033 ("isl" ,isl-0.11)))
1034 (arguments '(#:configure-flags '("--with-isl=system")))
1035 (home-page "http://www.cloog.org/")
1036 (synopsis "Library to generate code for scanning Z-polyhedra")
1037 (description
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
1048 effective code.")
1049 (license gpl2+)))
1050
1051 (define-public gnu-c-manual
1052 (package
1053 (name "gnu-c-manual")
1054 (version "0.2.5")
1055 (source (origin
1056 (method url-fetch)
1057 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1058 version ".tar.gz"))
1059 (sha256
1060 (base32
1061 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
1062 (build-system gnu-build-system)
1063 (native-inputs `(("texinfo" ,texinfo)))
1064 (arguments
1065 '(#:phases (modify-phases %standard-phases
1066 (delete 'configure)
1067 (delete 'check)
1068 (replace 'build
1069 (lambda _
1070 (invoke "make"
1071 "gnu-c-manual.info"
1072 "gnu-c-manual.html")))
1073 (replace 'install
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")))
1079 (mkdir-p info)
1080 (mkdir-p html)
1081
1082 (for-each (lambda (file)
1083 (copy-file file
1084 (string-append info "/"
1085 file)))
1086 (find-files "." "\\.info(-[0-9])?$"))
1087 (for-each (lambda (file)
1088 (copy-file file
1089 (string-append html "/"
1090 file)))
1091 (find-files "." "\\.html$"))
1092 #t))))))
1093 (synopsis "Reference manual for the C programming language")
1094 (description
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/")
1100 (license fdl1.3+)))