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