gnu: dnsmasq: Update to 2.87.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
CommitLineData
e9c0b944 1;;; GNU Guix --- Functional package management for GNU
66f12401 2;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
f888d5bb 3;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
b69156ef 4;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus <rekado@elephly.net>
ed2b1c4f 5;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
c31eed71 6;;; Copyright © 2015, 2016, 2017, 2018, 2020, 2021, 2022 Efraim Flashner <efraim@flashner.co.il>
fc649d0a 7;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll@gmail.com>
ba81ca6a 8;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
5d8a4354 9;;; Copyright © 2018, 2020 Marius Bakke <mbakke@fastmail.com>
76d2b9a2 10;;; Copyright © 2020 Joseph LaFreniere <joseph@lafreniere.xyz>
0f7e6964 11;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
a4fe16ee 12;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
cac88b28 13;;; Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
ef590de6 14;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
9017c240 15;;; Copyright © 2022 Greg Hogan <code@greghogan.com>
e9c0b944
LC
16;;;
17;;; This file is part of GNU Guix.
18;;;
19;;; GNU Guix is free software; you can redistribute it and/or modify it
20;;; under the terms of the GNU General Public License as published by
21;;; the Free Software Foundation; either version 3 of the License, or (at
22;;; your option) any later version.
23;;;
24;;; GNU Guix is distributed in the hope that it will be useful, but
25;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27;;; GNU General Public License for more details.
28;;;
29;;; You should have received a copy of the GNU General Public License
30;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31
32(define-module (gnu packages gcc)
c6d7e299 33 #:use-module ((guix licenses)
50c7a1e2 34 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
e9c0b944
LC
35 #:use-module (gnu packages)
36 #:use-module (gnu packages bootstrap)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages multiprecision)
c8ebc821 39 #:use-module (gnu packages texinfo)
c364a287 40 #:use-module (gnu packages dejagnu)
99828fa7 41 #:use-module (gnu packages documentation)
98b385d1
LC
42 #:use-module (gnu packages xml)
43 #:use-module (gnu packages docbook)
44 #:use-module (gnu packages graphviz)
3e778ad3 45 #:use-module (gnu packages elf)
38cf2ba0 46 #:use-module (gnu packages perl)
e9c0b944
LC
47 #:use-module (guix packages)
48 #:use-module (guix download)
ca16cb96 49 #:use-module (guix build-system gnu)
74574fd1 50 #:use-module (guix build-system trivial)
eeedb328 51 #:use-module (guix gexp)
fdd6c726 52 #:use-module (guix utils)
e052c7e1 53 #:use-module (srfi srfi-1)
3f929203 54 #:use-module (ice-9 match)
ca16cb96 55 #:use-module (ice-9 regex))
e9c0b944 56
832abc76
LC
57(define %gcc-infrastructure
58 ;; Base URL for GCC's infrastructure.
966a543b 59 "mirror://gcc/infrastructure/")
832abc76 60
76e639a0 61(define (gcc-configure-flags-for-triplet target)
ca16cb96
LC
62 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
63
64The purpose of this procedure is to translate extended GNU triplets---e.g.,
65where the OS part is overloaded to denote a specific ABI---into GCC
66`configure' options. We take extended GNU triplets that glibc recognizes."
67 (cond ((string-match "^mips64el.*gnuabin?64$" target)
68 ;; Triplets recognized by glibc as denoting the N64 ABI; see
69 ;; ports/sysdeps/mips/preconfigure.
70 '("--with-abi=64"))
3f00ff8b
MW
71
72 ((string-match "^arm.*-gnueabihf$" target)
73 '("--with-arch=armv7-a"
74 "--with-float=hard"
75 "--with-mode=thumb"
aa725117 76 "--with-fpu=neon"))
3f00ff8b 77
ec6ba5c1
LC
78 ((and (string-suffix? "-gnu" target)
79 (not (string-contains target "-linux")))
80 ;; Cross-compilation of libcilkrts in GCC 5.5.0 to GNU/Hurd fails
81 ;; with:
82 ;; libcilkrts/runtime/os-unix.c:388:2: error: #error "Unknown architecture"
83 ;; Cilk has been removed from GCC 8 anyway.
84 '("--disable-libcilkrts"))
85
45dd2b45
CM
86 ;; glibc needs the 128-bit long double type on these architectures.
87 ((or (string-prefix? "powerpc64le-" target)
88 (string-prefix? "powerpc-" target))
89 '("--with-long-double-128"))
90
ca16cb96 91 (else
3f00ff8b 92 ;; TODO: Add `arm.*-gnueabi', etc.
ca16cb96
LC
93 '())))
94
e9c0b944 95(define-public gcc-4.7
9063ef0f 96 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
de1d41f9
LC
97 (maybe-target-tools
98 (lambda ()
99 ;; Return the `_FOR_TARGET' variables that are needed when
100 ;; cross-compiling GCC.
101 (let ((target (%current-target-system)))
102 (if target
103 (map (lambda (var tool)
104 (string-append (string-append var "_FOR_TARGET")
105 "=" target "-" tool))
066ccc2c
LC
106 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
107 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
de1d41f9 108 '()))))
7e3c9f74
LC
109 (libdir
110 (let ((base '(or (assoc-ref outputs "lib")
111 (assoc-ref outputs "out"))))
112 (lambda ()
113 ;; Return the directory that contains lib/libgcc_s.so et al.
114 (if (%current-target-system)
115 `(string-append ,base "/" ,(%current-target-system))
116 base))))
de1d41f9
LC
117 (configure-flags
118 (lambda ()
119 ;; This is terrible. Since we have two levels of quasiquotation,
120 ;; we have to do this convoluted thing just so we can insert the
121 ;; contents of (maybe-target-tools).
122 (list 'quasiquote
123 (append
124 '("--enable-plugin"
125 "--enable-languages=c,c++"
126 "--disable-multilib"
98bd851e 127 "--with-system-zlib"
de1d41f9 128
06213498
LC
129 ;; No pre-compiled libstdc++ headers, to save space.
130 "--disable-libstdcxx-pch"
131
de1d41f9
LC
132 "--with-local-prefix=/no-gcc-local-prefix"
133
84e6756c
LC
134 ;; With a separate "lib" output, the build system
135 ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force
136 ;; it. (Don't use a versioned sub-directory, that's
137 ;; unnecessary.)
138 ,(string-append "--with-gxx-include-dir="
139 (assoc-ref %outputs "out")
140 "/include/c++")
141
de1d41f9
LC
142 ,(let ((libc (assoc-ref %build-inputs "libc")))
143 (if libc
144 (string-append "--with-native-system-header-dir=" libc
145 "/include")
146 "--without-headers")))
147
76e639a0
MW
148 ;; Pass the right options for the target triplet.
149 (let ((triplet
150 (or (%current-target-system)
151 (nix-system->gnu-triplet (%current-system)))))
152 (gcc-configure-flags-for-triplet triplet))
ca16cb96 153
de1d41f9 154 (maybe-target-tools))))))
d78010b8
RW
155 (hidden-package
156 (package
157 (name "gcc")
158 (version "4.7.4")
159 (source (origin
160 (method url-fetch)
161 (uri (string-append "mirror://gnu/gcc/gcc-"
162 version "/gcc-" version ".tar.bz2"))
163 (sha256
164 (base32
165 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
166 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
167 "gcc-fix-texi2pod.patch"))))
168 (build-system gnu-build-system)
169
170 ;; Separate out the run-time support libraries because all the
171 ;; dynamic-linked objects depend on it.
172 (outputs '("out" ;commands, etc. (60+ MiB)
173 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
174 "debug")) ;debug symbols of run-time libraries
175
8394619b 176 (inputs (list gmp mpfr mpc libelf zlib))
d78010b8
RW
177
178 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
179 ;; Newer texinfos fail to build the manual, so we use an older one.
8394619b
LC
180 (native-inputs (list perl ;for manpages
181 texinfo-5))
d78010b8
RW
182
183 (arguments
184 `(#:out-of-source? #t
185 #:configure-flags ,(configure-flags)
186 #:make-flags
187 ;; None of the flags below are needed when doing a Canadian cross.
188 ;; TODO: Simplify this.
189 ,(if (%current-target-system)
190 (if stripped?
191 ''("CFLAGS=-g0 -O2")
192 ''())
193 `(let* ((libc (assoc-ref %build-inputs "libc"))
194 (libc-native (or (assoc-ref %build-inputs "libc-native")
195 libc)))
196 `(,@(if libc
197 (list (string-append "LDFLAGS_FOR_TARGET="
198 "-B" libc "/lib "
199 "-Wl,-dynamic-linker "
200 "-Wl," libc
201 ,(glibc-dynamic-linker)))
202 '())
203
204 ;; Native programs like 'genhooks' also need that right.
205 ,(string-append "LDFLAGS="
206 "-Wl,-rpath=" libc-native "/lib "
207 "-Wl,-dynamic-linker "
208 "-Wl," libc-native ,(glibc-dynamic-linker))
209 ,(string-append "BOOT_CFLAGS=-O2 "
210 ,(if stripped? "-g0" "-g")))))
211
212 #:tests? #f
213
214 #:phases
215 (modify-phases %standard-phases
216 (add-before 'configure 'pre-configure
217 (lambda* (#:key inputs outputs #:allow-other-keys)
218 (let ((libdir ,(libdir))
219 (libc (assoc-ref inputs "libc")))
220 (when libc
221 ;; The following is not performed for `--without-headers'
222 ;; cross-compiler builds.
223
224 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
225 ;; single line, to allow the next step to work properly.
226 (for-each
227 (lambda (x)
ba81ca6a
TGR
228 (substitute* (find-files "gcc/config"
229 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
d78010b8
RW
230 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
231 line)))
232 '(1 2 3))
233
234 ;; Fix the dynamic linker's file name.
235 (substitute* (find-files "gcc/config"
236 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
237 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
238 _ gnu-user suffix)
239 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
240 gnu-user suffix
241 (string-append libc ,(glibc-dynamic-linker)))))
242
243 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
244 ;; `crt{begin,end}.o', which come with GCC.
245 (substitute* (find-files "gcc/config"
246 "^gnu-user.*\\.h$")
247 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
248 ;; Help libgcc_s.so be found (see also below.) Always use
249 ;; '-lgcc_s' so that libgcc_s.so is always found by those
250 ;; programs that use 'pthread_cancel' (glibc dlopens
251 ;; libgcc_s.so when pthread_cancel support is needed, but
252 ;; having it in the application's RUNPATH isn't enough; see
253 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
254 ;;
255 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
256 ;; later phase of %gcc-static. If you change the string
257 ;; below, make sure to update the relevant code in
258 ;; %gcc-static package as needed.
259 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
81197492 260\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
d78010b8
RW
261 libc libc libdir suffix))
262 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
263 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
e9c0b944 264#define STANDARD_STARTFILE_PREFIX_2 \"\"
06213498 265~a"
d78010b8
RW
266 libc line)))
267
268 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
269 ;; GNU_USER_* defines. Do the above for this case.
270 (substitute*
271 "gcc/config/rs6000/sysv4.h"
272 (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
273 (format #f "#define LIB_LINUX_SPEC \
fc649d0a 274\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
d78010b8
RW
275 libc libc libdir suffix))
276 (("#define STARTFILE_LINUX_SPEC.*$" line)
277 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
fc649d0a
CSLL
278#define STANDARD_STARTFILE_PREFIX_2 \"\"
279~a"
d78010b8
RW
280 libc line))))
281
8f0cd657
EF
282 (when (file-exists? "gcc/config/rs6000")
283 ;; Force powerpc libdir to be /lib and not /lib64
284 (substitute* (find-files "gcc/config/rs6000")
285 (("/lib64") "/lib")))
cac88b28 286
d78010b8
RW
287 ;; Don't retain a dependency on the build-time sed.
288 (substitute* "fixincludes/fixincl.x"
289 (("static char const sed_cmd_z\\[\\] =.*;")
290 "static char const sed_cmd_z[] = \"sed\";"))
291
292 ;; Aarch64 support didn't land in GCC until the 4.8 series.
293 (when (file-exists? "gcc/config/aarch64")
294 ;; Force Aarch64 libdir to be /lib and not /lib64
295 (substitute* "gcc/config/aarch64/t-aarch64-linux"
296 (("lib64") "lib")))
297
32f52f82
EF
298 ;; TODO: Make this unconditional in core-updates.
299 ;; The STARTFILE_PREFIX_SPEC prevents gcc from finding the
300 ;; gcc:lib output, which causes ld to not find -lgcc_s.
301 ,@(if (target-riscv64?)
302 `((when (file-exists? "gcc/config/riscv")
303 (substitute* "gcc/config/riscv/linux.h"
304 (("define STARTFILE_PREFIX_SPEC")
305 "define __STARTFILE_PREFIX_SPEC"))))
306 '())
307
d78010b8
RW
308 (when (file-exists? "libbacktrace")
309 ;; GCC 4.8+ comes with libbacktrace. By default it builds
310 ;; with -Werror, which fails with a -Wcast-qual error in glibc
311 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
312 (substitute* "libbacktrace/configure"
313 (("WARN_FLAGS=(.*)-Werror" _ flags)
314 (string-append "WARN_FLAGS=" flags)))
315
316 (when (file-exists? "libsanitizer/libbacktrace")
317 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
318 (substitute* "libsanitizer/libbacktrace/Makefile.in"
319 (("-Werror")
320 ""))))
321
322 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
323 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
324 ;; and <http://bugs.gnu.org/20358>.
325 (substitute* "libstdc++-v3/src/Makefile.in"
326 (("^OPT_LDFLAGS = ")
327 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
328
329 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
330 ;; circularity between "out" and "lib". (Note:
331 ;; --with-python-dir is useless because it imposes $(prefix) as
332 ;; the parent directory.)
333 (substitute* "libstdc++-v3/python/Makefile.in"
334 (("pythondir = .*$")
335 (string-append "pythondir = " libdir "/share"
336 "/gcc-$(gcc_version)/python\n")))
337
338 ;; Avoid another circularity between the outputs: this #define
339 ;; ends up in auto-host.h in the "lib" output, referring to
340 ;; "out". (This variable is used to augment cpp's search path,
341 ;; but there's nothing useful to look for here.)
342 (substitute* "gcc/config.in"
343 (("PREFIX_INCLUDE_DIR")
16111ad1 344 "PREFIX_INCLUDE_DIR_isnt_necessary_here")))))
d78010b8
RW
345
346 (add-after 'configure 'post-configure
347 (lambda _
348 ;; Don't store configure flags, to avoid retaining references to
349 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
350 (substitute* "Makefile"
351 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
16111ad1 352 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))))))
d78010b8
RW
353
354 (native-search-paths
355 ;; Use the language-specific variables rather than 'CPATH' because they
356 ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
357 ;; The intent is to allow headers that are in the search path to be
358 ;; treated as "system headers" (headers exempt from warnings) just like
359 ;; the typical /usr/include headers on an FHS system.
360 (list (search-path-specification
361 (variable "C_INCLUDE_PATH")
362 (files '("include")))
363 (search-path-specification
364 (variable "CPLUS_INCLUDE_PATH")
2073b55e
LC
365 ;; Add 'include/c++' here so that <cstdlib>'s "#include_next
366 ;; <stdlib.h>" finds GCC's <stdlib.h>, not libc's.
367 (files '("include/c++" "include")))
d78010b8
RW
368 (search-path-specification
369 (variable "LIBRARY_PATH")
370 (files '("lib" "lib64")))))
371
372 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
373 (synopsis "GNU Compiler Collection")
374 (description
375 "GCC is the GNU Compiler Collection. It provides compiler front-ends
a22dc0c4 376for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
79c311b8 377Go. It also includes runtime support libraries for these languages.")
d78010b8
RW
378 (license gpl3+)
379 (supported-systems (delete "aarch64-linux" %supported-systems))
380 (home-page "https://gcc.gnu.org/")))))
832abc76 381
3b401612 382(define-public gcc-4.8
3b401612 383 (package (inherit gcc-4.7)
ab5f49cf 384 (version "4.8.5")
3b401612 385 (source (origin
7e35b9dd
LC
386 (method url-fetch)
387 (uri (string-append "mirror://gnu/gcc/gcc-"
388 version "/gcc-" version ".tar.bz2"))
389 (sha256
390 (base32
ab5f49cf 391 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
19d27131 392 (patches (search-patches "gcc-arm-link-spec-fix.patch"
0b93d04a 393 "gcc-4.8-libsanitizer-fix.patch"
8e7ec29d 394 "gcc-asan-missing-include.patch"
7bbc708a
EF
395 "gcc-fix-texi2pod.patch"))
396 (modules '((guix build utils)))
397 ;; This is required for building with glibc-2.26.
398 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
399 (snippet
3504e39a
LC
400 '(for-each
401 (lambda (dir)
402 (substitute* (string-append "libgcc/config/"
403 dir "/linux-unwind.h")
404 (("struct ucontext") "ucontext_t")))
405 '("aarch64" "alpha" "bfin" "i386" "m68k"
406 "pa" "sh" "tilepro" "xtensa")))))
2b8d4ce8
EF
407 (supported-systems %supported-systems)
408 (inputs
8394619b
LC
409 (modify-inputs (package-inputs gcc-4.7)
410 (prepend isl-0.11 cloog)))))
3b401612 411
571aa6cd 412(define-public gcc-4.9
dd4efefd 413 (package (inherit gcc-4.8)
b0847497 414 (version "4.9.4")
571aa6cd 415 (source (origin
7e35b9dd
LC
416 (method url-fetch)
417 (uri (string-append "mirror://gnu/gcc/gcc-"
418 version "/gcc-" version ".tar.bz2"))
419 (sha256
420 (base32
b0847497 421 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
d6593070 422 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
3469a5ea 423 "gcc-4.9-libsanitizer-ustat.patch"
a33eac03 424 "gcc-4.9-libsanitizer-mode-size.patch"
d6593070 425 "gcc-arm-bug-71399.patch"
e80514bc 426 "gcc-asan-missing-include.patch"
19d27131 427 "gcc-libvtv-runpath.patch"
809b0a90
EF
428 "gcc-fix-texi2pod.patch"))
429 (modules '((guix build utils)))
430 ;; This is required for building with glibc-2.26.
431 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
432 (snippet
3504e39a
LC
433 '(for-each
434 (lambda (dir)
435 (substitute* (string-append "libgcc/config/"
436 dir "/linux-unwind.h")
437 (("struct ucontext") "ucontext_t")))
438 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
439 "pa" "sh" "tilepro" "xtensa")))))
19d27131 440 ;; Override inherited texinfo-5 with latest version.
8394619b
LC
441 (native-inputs (list perl ;for manpages
442 texinfo))
56c833ea
MB
443 (arguments
444 (if (%current-target-system)
445 (package-arguments gcc-4.8)
446 ;; For native builds of GCC 4.9 and GCC 5, the C++ include path needs
447 ;; to be adjusted so it does not interfere with GCC's own build processes.
448 (substitute-keyword-arguments (package-arguments gcc-4.8)
449 ((#:modules modules %gnu-build-system-modules)
450 `((srfi srfi-1)
451 ,@modules))
452 ((#:phases phases)
453 `(modify-phases ,phases
454 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
455 (lambda* (#:key inputs #:allow-other-keys)
456 (let ((libc (assoc-ref inputs "libc"))
457 (gcc (assoc-ref inputs "gcc")))
458 (setenv "CPLUS_INCLUDE_PATH"
459 (string-join (fold delete
460 (string-split (getenv "CPLUS_INCLUDE_PATH")
461 #\:)
462 (list (string-append libc "/include")
463 (string-append gcc "/include/c++")))
464 ":"))
465 (format #t
466 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
16111ad1 467 (getenv "CPLUS_INCLUDE_PATH"))))))))))))
571aa6cd 468
eeedb328
LC
469(define gcc-canadian-cross-objdump-snippet
470 ;; Fix 'libcc1/configure' error when cross-compiling GCC. Without that,
471 ;; 'libcc1/configure' wrongfully determines that '-rdynamic' support is
472 ;; missing because $gcc_cv_objdump is empty:
473 ;;
474 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
475 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
476 #~(substitute* "libcc1/configure"
477 (("\\$gcc_cv_objdump -T")
478 "$OBJDUMP_FOR_TARGET -T")))
479
629f4d2e 480(define-public gcc-5
7912677c
LC
481 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
482 ;; them in a VPATH build.
7e35b9dd 483 (package (inherit gcc-4.9)
404e3d8b 484 (version "5.5.0")
60e2d5fe 485 (source (origin
7e35b9dd
LC
486 (method url-fetch)
487 (uri (string-append "mirror://gnu/gcc/gcc-"
404e3d8b 488 version "/gcc-" version ".tar.xz"))
7e35b9dd
LC
489 (sha256
490 (base32
404e3d8b 491 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
b810a850 492 (patches (search-patches "gcc-arm-bug-71399.patch"
1aef659e 493 "gcc-libsanitizer-ustat.patch"
b810a850 494 "gcc-strmov-store-file-names.patch"
d71d6fe8
MB
495 "gcc-5.0-libvtv-runpath.patch"
496 "gcc-5-source-date-epoch-1.patch"
19d27131 497 "gcc-5-source-date-epoch-2.patch"
a33eac03 498 "gcc-6-libsanitizer-mode-size.patch"
25bc0f34 499 "gcc-fix-texi2pod.patch"
b04a20f7
TJB
500 "gcc-5-hurd.patch"
501 ;; See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86162
502 "gcc-5-fix-powerpc64le-build.patch"))
066ccc2c 503 (modules '((guix build utils)))
eeedb328 504 (snippet gcc-canadian-cross-objdump-snippet)))
eb9696e7 505 (inputs
8394619b
LC
506 (modify-inputs (package-inputs gcc-4.7)
507 (prepend ;; GCC5 needs <isl/band.h> which is removed in later versions.
508 isl-0.18)))))
60e2d5fe 509
e760ec41
LC
510(define-public gcc-6
511 (package
512 (inherit gcc-5)
8d65ae44 513 (version "6.5.0")
e760ec41
LC
514 (source (origin
515 (method url-fetch)
516 (uri (string-append "mirror://gnu/gcc/gcc-"
0dd87919 517 version "/gcc-" version ".tar.xz"))
e760ec41
LC
518 (sha256
519 (base32
8d65ae44
MB
520 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
521 (patches (search-patches "gcc-strmov-store-file-names.patch"
a33eac03 522 "gcc-6-libsanitizer-mode-size.patch"
aace9be8
MB
523 "gcc-6-source-date-epoch-1.patch"
524 "gcc-6-source-date-epoch-2.patch"
8d65ae44 525 "gcc-5.0-libvtv-runpath.patch"))))
56c833ea
MB
526
527 ;; GCC 4.9 and 5 has a workaround that is not needed for GCC 6 and later.
528 (arguments (package-arguments gcc-4.8))
529
2b8d4ce8
EF
530 (inputs
531 `(("isl" ,isl)
12dc9f58
LC
532
533 ;; XXX: This gross hack allows us to have libstdc++'s <bits/c++config.h>
534 ;; in the search path, thereby avoiding misconfiguration of libstdc++:
535 ;; <https://bugs.gnu.org/42392>.
536 ("libstdc++" ,libstdc++-headers)
537
2073b55e 538 ,@(package-inputs gcc-4.7)))))
2b8d4ce8 539
c31eed71
EF
540(define %gcc-7.5-aarch64-micro-architectures
541 ;; Suitable '-march' values for GCC 7.5.
542 ;; TODO: Allow dynamically adding feature flags.
543 '("armv8-a" "armv8.1-a" "armv8.2-a" "armv8.3-a"))
544
1ddef634
EF
545(define %gcc-7.5-armhf-micro-architectures
546 ;; Suitable '-march' values for GCC 7.5.
547 ;; TODO: Allow dynamically adding feature flags.
548 '("armv7" "armv7-a" "armv7-m" "armv7-r" "armv7e-m" "armv7ve"
549 "armv8-a" "armv8-a+crc" "armv8.1-a" "armv8.1-a+crc"
550 "armv8-m.base" "armv8-m.main" "armv8-m.main+dsp"
551 "iwmmxt" "iwmmxt2"))
552
2576e201
LC
553(define %gcc-7.5-x86_64-micro-architectures
554 ;; Suitable '-march' values for GCC 7.5 (info "(gcc) x86 Options").
555 '("core2" "nehalem" "westmere" "sandybridge" "ivybridge"
556 "haswell" "broadwell" "skylake" "bonnell" "silvermont"
557 "knl" "skylake-avx512"
558
559 "k8" "k8-sse3" "barcelona"
560 "bdver1" "bdver2" "bdver3" "bdver4"
561 "znver1"
562 "btver1" "btver2" "geode"))
563
c31eed71
EF
564(define %gcc-10-aarch64-micro-architectures
565 ;; Suitable '-march' values for GCC 10.
566 ;; TODO: Allow dynamically adding feature flags.
567 (append %gcc-7.5-aarch64-micro-architectures
568 '("armv8.4-a" "armv8.5-a" "armv8.6-a")))
569
1ddef634
EF
570(define %gcc-10-armhf-micro-architectures
571 ;; Suitable '-march' values for GCC 10.
572 ;; TODO: Allow dynamically adding feature flags.
573 (append %gcc-7.5-armhf-micro-architectures
574 '("armv8.2-a" "armv8.3-a" "armv8.4-a" "armv8.5-a" "armv8.6-a"
575 "armv8-r" "armv8.1-m.main")))
576
2576e201
LC
577(define %gcc-10-x86_64-micro-architectures
578 ;; Suitable '-march' values for GCC 10.
579 (append %gcc-7.5-x86_64-micro-architectures
580 '("goldmont" "goldmont-plus" "tremont"
581 "knm" "cannonlake" "icelake-client" "icelake-server"
582 "cascadelake" "cooperlake" "tigerlake"
583
584 "znver2" "znver3")))
585
dc9503dd
LC
586(define %gcc-11-aarch64-micro-architectures
587 ;; Suitable '-march' values for GCC 11.
588 %gcc-10-aarch64-micro-architectures) ;unchanged
589
590(define %gcc-11-armhf-micro-architectures
591 %gcc-10-armhf-micro-architectures)
592
593(define %gcc-11-x86_64-micro-architectures
594 ;; Suitable '-march' values for GCC 11.
595 (append %gcc-10-x86_64-micro-architectures
596 '("sapphirerapids" "alterlake" "rocketlake" ;Intel
597
598 "btver1" "btver2"))) ;AMD
599
0c5658df
EF
600(define-public gcc-7
601 (package
602 (inherit gcc-6)
8456f9fc 603 (version "7.5.0")
0c5658df
EF
604 (source (origin
605 (method url-fetch)
606 (uri (string-append "mirror://gnu/gcc/gcc-"
2bccf1c0 607 version "/gcc-" version ".tar.xz"))
0c5658df
EF
608 (sha256
609 (base32
8456f9fc 610 "0qg6kqc5l72hpnj4vr6l0p69qav0rh4anlkk3y55540zy3klc6dq"))
0c5658df 611 (patches (search-patches "gcc-strmov-store-file-names.patch"
a33eac03 612 "gcc-7-libsanitizer-mode-size.patch"
35dadded
EF
613 "gcc-5.0-libvtv-runpath.patch"))))
614 (description
615 "GCC is the GNU Compiler Collection. It provides compiler front-ends
616for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
2576e201
LC
617It also includes runtime support libraries for these languages.")
618 (properties
619 `((compiler-cpu-architectures
c31eed71 620 ("aarch64" ,@%gcc-7.5-aarch64-micro-architectures)
1ddef634 621 ("armhf" ,@%gcc-7.5-armhf-micro-architectures)
2576e201 622 ("x86_64" ,@%gcc-7.5-x86_64-micro-architectures))))))
e760ec41 623
a1fa2691
MB
624(define-public gcc-8
625 (package
626 (inherit gcc-7)
f7e5ecf7 627 (version "8.5.0")
a1fa2691
MB
628 (source (origin
629 (method url-fetch)
630 (uri (string-append "mirror://gnu/gcc/gcc-"
631 version "/gcc-" version ".tar.xz"))
632 (sha256
633 (base32
f7e5ecf7 634 "0l7d4m9jx124xsk6xardchgy2k5j5l2b15q322k31f0va4d8826k"))
a1fa2691 635 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
83d9e2ee 636 "gcc-5.0-libvtv-runpath.patch"
eeedb328
LC
637 "gcc-8-sort-libtool-find-output.patch"))
638 (modules '((guix build utils)))
639 (snippet gcc-canadian-cross-objdump-snippet)))))
a1fa2691 640
bdfc3276
CD
641(define-public gcc-9
642 (package
643 (inherit gcc-8)
d2a91428 644 (version "9.5.0")
bdfc3276
CD
645 (source (origin
646 (method url-fetch)
647 (uri (string-append "mirror://gnu/gcc/gcc-"
648 version "/gcc-" version ".tar.xz"))
649 (sha256
650 (base32
d2a91428 651 "13ygjmd938m0wmy946pxdhz9i1wq7z4w10l6pvidak0xxxj9yxi7"))
bdfc3276 652 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
0e293f75 653 "gcc-9-asan-fix-limits-include.patch"
eeedb328
LC
654 "gcc-5.0-libvtv-runpath.patch"))
655 (modules '((guix build utils)))
656 (snippet gcc-canadian-cross-objdump-snippet)))))
bdfc3276 657
2bb5b1d4
LC
658(define-public gcc-10
659 (package
660 (inherit gcc-8)
a365777e 661 (version "10.3.0")
2bb5b1d4
LC
662 (source (origin
663 (method url-fetch)
664 (uri (string-append "mirror://gnu/gcc/gcc-"
665 version "/gcc-" version ".tar.xz"))
666 (sha256
667 (base32
a365777e 668 "0i6378ig6h397zkhd7m4ccwjx5alvzrf2hm27p1pzwjhlv0h9x34"))
2bb5b1d4 669 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
eeedb328
LC
670 "gcc-5.0-libvtv-runpath.patch"))
671 (modules '((guix build utils)))
2576e201
LC
672 (snippet gcc-canadian-cross-objdump-snippet)))
673 (properties
674 `((compiler-cpu-architectures
c31eed71 675 ("aarch64" ,@%gcc-10-aarch64-micro-architectures)
1ddef634 676 ("armhf" ,@%gcc-10-armhf-micro-architectures)
2576e201 677 ("x86_64" ,@%gcc-10-x86_64-micro-architectures))))))
2bb5b1d4 678
007ec662
EF
679(define-public gcc-11
680 (package
681 (inherit gcc-8)
9017c240 682 (version "11.3.0")
007ec662
EF
683 (source (origin
684 (method url-fetch)
685 (uri (string-append "mirror://gnu/gcc/gcc-"
686 version "/gcc-" version ".tar.xz"))
687 (sha256
688 (base32
9017c240 689 "0fdclcwf728wbq52vphfcjywzhpsjp3kifzj3pib3xcihs0z4z5l"))
007ec662 690 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
eeedb328
LC
691 "gcc-5.0-libvtv-runpath.patch"))
692 (modules '((guix build utils)))
15bb35d0
LC
693 (snippet gcc-canadian-cross-objdump-snippet)))
694
dc9503dd
LC
695 (properties
696 `((compiler-cpu-architectures
697 ("aarch64" ,@%gcc-11-aarch64-micro-architectures)
698 ("armhf" ,@%gcc-11-armhf-micro-architectures)
699 ("x86_64" ,@%gcc-11-x86_64-micro-architectures))))))
007ec662 700
37e29ccd
LC
701(define-public gcc-12
702 (package
703 (inherit gcc-11)
704 ;; Note: 'compiler-cpu-architectures' is unchanged compared to GCC 11.
9f7236e3 705 (version "12.2.0")
37e29ccd
LC
706 (source (origin
707 (method url-fetch)
708 (uri (string-append "mirror://gnu/gcc/gcc-"
709 version "/gcc-" version ".tar.xz"))
710 (sha256
711 (base32
9f7236e3 712 "1zrhca90c7hqnjz3jgr1vl675q3h5lrd92b5ggi00jjryffcyjg5"))
37e29ccd
LC
713 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
714 "gcc-5.0-libvtv-runpath.patch"))
715 (modules '((guix build utils)))
716 (snippet gcc-canadian-cross-objdump-snippet)))))
717
718
ce362de8 719;; Note: When changing the default gcc version, update
a172def5 720;; the gcc-toolchain-* definitions.
4796b5d6 721(define-public gcc gcc-10)
eed67cbb 722
66f12401
LC
723\f
724;;;
725;;; Historical version.
726;;;
727
728(define-public gcc-2.95
729 ;; Note: 'gcc-core-mesboot0' in commencement.scm provides 2.95 as well, but
730 ;; with additional tricks to support compilation with TinyCC and Mes-libc.
731 (package
732 (inherit gcc)
733 (version "2.95.3")
734 (source (origin
735 (method url-fetch)
736 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
737 version ".tar.gz"))
738 (sha256
739 (base32
740 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))
741 (modules '((guix build utils)))
742 (snippet
743 '(begin
744 ;; Do not build the bundled Texinfo.
745 (delete-file-recursively "texinfo")
746 (substitute* "configure"
747 (("host_tools=(.*)texinfo" _ before)
b41ff1a0
EF
748 (string-append "host_tools=" before)))
749 ;; Fix building on arm* with gcc-4+
750 (substitute* "gcc/config/arm/arm.c"
751 (("arm_prog_mode") "arm_prgmode"))))))
3f929203
EF
752 (supported-systems (fold delete %supported-systems
753 '("powerpc64le-linux" "riscv64-linux")))
66f12401
LC
754 (native-inputs (list texinfo dejagnu))
755 (inputs '())
756 (propagated-inputs '())
757 (outputs '("out"))
758 (arguments
3f929203
EF
759 (let ((matching-system
760 (match (%current-system)
761 ;; This package predates our 64-bit architectures.
762 ;; Force a 32-bit build targeting a similar architecture.
763 ("aarch64-linux"
764 "armhf-linux")
765 ("x86_64-linux"
766 "i686-linux")
767 (_
768 (%current-system)))))
769 (list #:system matching-system
770 #:configure-flags #~'("--disable-werror")
771
772 #:phases
773 #~(modify-phases %standard-phases
774 (add-before 'configure 'set-dynamic-linker-file-name
775 (lambda* (#:key inputs #:allow-other-keys)
776 ;; Tell GCC what the real loader file name is.
777 (substitute* '("gcc/config/alpha/linux-elf.h"
778 "gcc/config/m68k/linux.h"
779 "gcc/config/mips/linux.h"
780 "gcc/config/rs6000/linux.h")
781 (("/lib/ld\\.so\\.1")
782 (search-input-file
783 inputs #$(glibc-dynamic-linker matching-system))))
96f89454
EF
784 (substitute* "gcc/config/i386/gnu.h"
785 (("/lib/ld\\.so")
786 (search-input-file
787 inputs #$(glibc-dynamic-linker matching-system))))
3f929203
EF
788 (substitute* '("gcc/config/alpha/linux-elf.h"
789 "gcc/config/arm/linux-elf.h"
790 "gcc/config/i386/linux.h"
791 "gcc/config/m68k/linux.h"
792 "gcc/config/sparc/linux.h"
793 "gcc/config/sparc/linux64.h")
794 (("/lib(64)?/ld-linux\\.so\\.[12]")
795 (search-input-file
796 inputs #$(glibc-dynamic-linker matching-system))))))
797 (replace 'configure
798 (lambda* (#:key outputs build configure-flags
799 #:allow-other-keys)
800 ;; It's an old 'configure' script so it needs some help.
801 (setenv "CONFIG_SHELL" (which "sh"))
802 (apply invoke "./configure"
803 (string-append "--prefix=" #$output)
804 (string-append "--build=" build)
805 (string-append "--host=" build)
806 configure-flags)))
807 (add-before 'configure 'remove-bundled-texinfo
808 (lambda _
809 ;; Go ahead despite the many warnings.
810 (substitute* '("Makefile.in" "gcc/Makefile.in")
811 (("^MAKEINFOFLAGS =.*")
812 "MAKEINFOFLAGS = --force\n"))))))))
66f12401
LC
813 (native-search-paths
814 ;; This package supports nothing but the C language.
815 (list (search-path-specification
816 (variable "C_INCLUDE_PATH")
817 (files '("include")))
818 (search-path-specification
819 (variable "LIBRARY_PATH")
820 (files '("lib")))))))
821
822\f
d0abf829
LC
823(define-public (make-libstdc++ gcc)
824 "Return a libstdc++ package based on GCC. The primary use case is when
825using compilers other than GCC."
826 (package
827 (inherit gcc)
828 (name "libstdc++")
829 (arguments
830 `(#:out-of-source? #t
cac88b28 831 #:phases
6dd338ee
EF
832 (modify-phases %standard-phases
833 ;; Force rs6000 (i.e., powerpc) libdir to be /lib and not /lib64.
834 (add-before 'chdir 'fix-rs6000-libdir
835 (lambda _
836 (when (file-exists? "gcc/config/rs6000")
837 (substitute* (find-files "gcc/config/rs6000")
838 (("/lib64") "/lib")))))
839 (add-before 'configure 'chdir
840 (lambda _
841 (chdir "libstdc++-v3"))))
cac88b28 842
d0abf829
LC
843 #:configure-flags `("--disable-libstdcxx-pch"
844 ,(string-append "--with-gxx-include-dir="
845 (assoc-ref %outputs "out")
846 "/include"))))
847 (outputs '("out" "debug"))
848 (inputs '())
849 (native-inputs '())
850 (propagated-inputs '())
851 (synopsis "GNU C++ standard library")))
852
12dc9f58
LC
853(define libstdc++
854 ;; Libstdc++ matching the default GCC.
855 (make-libstdc++ gcc))
856
857(define libstdc++-headers
858 ;; XXX: This package is for internal use to work around
859 ;; <https://bugs.gnu.org/42392> (see above). The main difference compared
860 ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>
861 ;; is right under include/c++ and not under
862 ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).
863 (package
864 (inherit libstdc++)
865 (name "libstdc++-headers")
866 (outputs '("out"))
867 (build-system trivial-build-system)
868 (arguments
869 '(#:builder (let* ((out (assoc-ref %outputs "out"))
870 (libstdc++ (assoc-ref %build-inputs "libstdc++")))
871 (mkdir out)
872 (mkdir (string-append out "/include"))
873 (symlink (string-append libstdc++ "/include")
874 (string-append out "/include/c++")))))
875 (inputs `(("libstdc++" ,libstdc++)))
876 (synopsis "Headers of GNU libstdc++")))
877
d0abf829
LC
878(define-public libstdc++-4.9
879 (make-libstdc++ gcc-4.9))
880
2b6b6d13
RW
881(define (make-libiberty gcc)
882 "Return a libiberty package based on GCC."
883 (package
884 (inherit gcc)
885 (name "libiberty")
886 (arguments
887 `(#:out-of-source? #t
888 #:phases
889 (modify-phases %standard-phases
890 (add-before 'configure 'chdir
0f7e6964 891 (lambda _
16111ad1 892 (chdir "libiberty")))
0f7e6964 893 (replace 'install
894 (lambda* (#:key outputs #:allow-other-keys)
895 (let* ((out (assoc-ref outputs "out"))
896 (lib (string-append out "/lib/"))
897 (include (string-append out "/include/")))
898 (install-file "libiberty.a" lib)
16111ad1 899 (install-file "../include/libiberty.h" include)))))))
2b6b6d13
RW
900 (inputs '())
901 (outputs '("out"))
902 (native-inputs '())
903 (propagated-inputs '())
0f665134 904 (properties '())
2b6b6d13
RW
905 (synopsis "Collection of subroutines used by various GNU programs")))
906
907(define-public libiberty
908 (make-libiberty gcc))
909
009b53fd
LC
910(define* (custom-gcc gcc name languages
911 #:optional
912 (search-paths (package-native-search-paths gcc))
913 #:key (separate-lib-output? #t))
914 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
915as the 'native-search-paths' field."
fdd6c726
NK
916 (package (inherit gcc)
917 (name name)
c4df90a5
MW
918 (outputs (if separate-lib-output?
919 (package-outputs gcc)
920 (delete "lib" (package-outputs gcc))))
009b53fd 921 (native-search-paths search-paths)
fbeb92d7 922 (properties (alist-delete 'hidden? (package-properties gcc)))
fdd6c726 923 (arguments
587398d2
MB
924 (substitute-keyword-arguments (package-arguments gcc)
925 ((#:modules modules %gnu-build-system-modules)
926 `(,@modules
927 (srfi srfi-1)
928 (srfi srfi-26)
929 (ice-9 regex)))
fdd6c726
NK
930 ((#:configure-flags flags)
931 `(cons (string-append "--enable-languages="
932 ,(string-join languages ","))
933 (remove (cut string-match "--enable-languages.*" <>)
82f145ef
RW
934 ,flags)))
935 ((#:phases phases)
936 `(modify-phases ,phases
937 (add-after 'install 'remove-broken-or-conflicting-files
938 (lambda* (#:key outputs #:allow-other-keys)
5318bade
SM
939 (for-each
940 delete-file
941 (find-files (string-append (assoc-ref outputs "out") "/bin")
942 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|lto)(-.*)?$"))))))))))
fdd6c726 943
009b53fd
LC
944(define %generic-search-paths
945 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
946 ;; not considered "system headers", which means GCC can raise warnings for
947 ;; issues in those headers. 'CPATH' is the only one that works for
948 ;; front-ends not in the C family.
949 (list (search-path-specification
950 (variable "CPATH")
951 (files '("include")))
952 (search-path-specification
953 (variable "LIBRARY_PATH")
954 (files '("lib" "lib64")))))
955
0681f054 956(define-public gfortran
a7c75b8d 957 (hidden-package
11284cb3 958 (custom-gcc gcc
12dc9f58 959 "gfortran" '("fortran")
a7c75b8d 960 %generic-search-paths)))
f66be84d 961
b69156ef
RW
962(define-public gfortran-7
963 (hidden-package
964 (custom-gcc gcc-7
965 "gfortran" '("fortran")
966 %generic-search-paths)))
967
163686d8 968(define-public gdc-10
969 (hidden-package
970 (custom-gcc gcc-10 "gdc" '("d")
971 %generic-search-paths)))
972
1f5543e7
EF
973(define-public gdc-11
974 (hidden-package
975 (custom-gcc gcc-11 "gdc" '("d")
976 %generic-search-paths)))
977
bf33a77e 978(define-public (make-libgccjit gcc)
76d2b9a2 979 (package
bf33a77e 980 (inherit gcc)
76d2b9a2
JL
981 (name "libgccjit")
982 (outputs (delete "lib" (package-outputs gcc)))
983 (properties (alist-delete 'hidden? (package-properties gcc)))
984 (arguments
bf33a77e
LMP
985 (substitute-keyword-arguments (package-arguments gcc)
986 ((#:modules _ '())
987 '((guix build gnu-build-system)
988 (guix build utils)
989 (ice-9 regex)
990 (srfi srfi-1)
991 (srfi srfi-26)))
76d2b9a2 992 ((#:configure-flags flags)
6b635715
LMP
993 #~(cons* "--disable-bootstrap"
994 "--disable-libatomic"
995 "--disable-libgomp"
996 "--disable-libquadmath"
997 "--disable-libssp"
998 "--enable-host-shared"
999 "--enable-checking=release"
bf33a77e 1000 "--enable-languages=jit"
76d2b9a2 1001 (remove (cut string-match "--enable-languages.*" <>)
bf33a77e 1002 #$flags)))
76d2b9a2 1003 ((#:phases phases)
bf33a77e
LMP
1004 #~(modify-phases #$phases
1005 (add-after 'install 'remove-broken-or-conflicting-files
1006 (lambda* (#:key outputs #:allow-other-keys)
1007 (for-each delete-file
1008 (find-files
1009 (string-append (assoc-ref outputs "out") "/bin")
1010 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))))))))
6b635715
LMP
1011 (inputs (modify-inputs (package-inputs gcc)
1012 (delete "libstdc++")))
1013 (native-inputs (modify-inputs (package-native-inputs gcc)
1014 (prepend gcc)))
a4fe16ee 1015 (synopsis "GCC library generating machine code on-the-fly at runtime")
1016 (description
1017 "This package is part of the GNU Compiler Collection and provides an
1018embeddable library for generating machine code on-the-fly at runtime. This
1019shared library can then be dynamically-linked into bytecode interpreters and
1020other such programs that want to generate machine code on-the-fly at run-time.
1021It can also be used for ahead-of-time code generation for building standalone
1022compilers. The just-in-time (jit) part of the name is now something of a
1023misnomer.")))
76d2b9a2 1024
80a9b757
LMP
1025(define-public libgccjit-9 (make-libgccjit gcc-9))
1026(define-public libgccjit-10 (make-libgccjit gcc-10))
1027(define-public libgccjit-11 (make-libgccjit gcc-11))
1028(define-public libgccjit-12 (make-libgccjit gcc-12))
1029
1030(define-public libgccjit libgccjit-10)
bf33a77e 1031
ef590de6
SM
1032(define (make-gccgo gcc)
1033 "Return a gccgo package based on GCC."
e4779e06 1034 (let ((gccgo (custom-gcc gcc "gccgo" '("go") %generic-search-paths)))
ef590de6
SM
1035 (package
1036 (inherit gccgo)
1037 (synopsis "Go frontend to GCC")
1038 (description
1039 "This package is part of the GNU Compiler Collection and
1040provides the GNU compiler for the Go programming language.")
1041 (arguments
1042 (substitute-keyword-arguments (package-arguments gccgo)
1043 ((#:phases phases)
1044 `(modify-phases ,phases
1045 (add-after 'install 'wrap-go-with-tool-path
1046 (lambda* (#:key outputs #:allow-other-keys)
1047 (let* ((out (assoc-ref outputs "out"))
1048 (exedir (string-append out "/libexec/gcc"))
1049 (tooldir (dirname (car (find-files exedir "^cgo$")))))
1050 (wrap-program (string-append out "/bin/go")
1051 `("GCCGOTOOLDIR" =
68d15fcf 1052 (,(string-append "${GCCGOTOOLDIR:-" tooldir "}")))
ef590de6 1053 `("GOROOT" =
68d15fcf 1054 (,(string-append "${GOROOT:-" out "}")))))))
ef590de6
SM
1055 (add-before 'configure 'fix-gotools-runpath
1056 (lambda _
1057 (substitute* "gotools/Makefile.in"
1058 (("AM_LDFLAGS =" all)
1059 (string-append all " -Wl,-rpath=$(libdir) ")))))
1060 (add-before 'configure 'remove-tool-reference-from-libgo
1061 (lambda _
1062 (substitute* "libgo/Makefile.in"
1063 (("(GccgoToolDir = \\\")[^\\\"]+" _ start)
1064 (string-append start "/nonexistent"))
1065 (("(DefaultGoroot = \\\")[^\\\"]+" _ start)
1066 (string-append start "/nonexistent"))
1067 (("(defaultGOROOTValue.*?return `)[^`]+" _ start)
1068 (string-append start "/nonexistent"))))))))))))
76d2b9a2 1069
c8732e19 1070(define-public gccgo-4.9
542c4707 1071 (custom-gcc (package
1072 (inherit gcc-4.9)
1073 (synopsis "Go frontend to GCC")
1074 (description
1075 "This package is part of the GNU Compiler Collection and
1076provides the GNU compiler for the Go programming language."))
1077 "gccgo" '("go")
009b53fd 1078 %generic-search-paths
c4df90a5
MW
1079 ;; Suppress the separate "lib" output, because otherwise the
1080 ;; "lib" and "out" outputs would refer to each other, creating
1081 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
1082 #:separate-lib-output? #f))
fdd6c726 1083
ef590de6
SM
1084(define-public gccgo-10
1085 (make-gccgo gcc-10))
1086
5cc9d41d
EF
1087(define-public gccgo-11
1088 (make-gccgo gcc-11))
1089
14cce84c
JK
1090(define %objc-search-paths
1091 (list (search-path-specification
1092 (variable "OBJC_INCLUDE_PATH")
1093 (files '("include")))
1094 (search-path-specification
1095 (variable "LIBRARY_PATH")
1096 (files '("lib" "lib64")))))
1097
fdd6c726 1098(define-public gcc-objc-4.8
009b53fd 1099 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
14cce84c 1100 %objc-search-paths))
fdd6c726 1101
2d69c161
RW
1102(define-public gcc-objc-4.9
1103 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
14cce84c 1104 %objc-search-paths))
2d69c161 1105
f51d01e1
EF
1106(define-public gcc-objc-5
1107 (custom-gcc gcc-5 "gcc-objc" '("objc")
14cce84c 1108 %objc-search-paths))
f51d01e1 1109
4072c10b
EF
1110(define-public gcc-objc-6
1111 (custom-gcc gcc-6 "gcc-objc" '("objc")
14cce84c 1112 %objc-search-paths))
ce9afe2b
EF
1113
1114(define-public gcc-objc-7
1115 (custom-gcc gcc-7 "gcc-objc" '("objc")
14cce84c 1116 %objc-search-paths))
4072c10b 1117
f66be84d
EB
1118(define-public gcc-objc-8
1119 (custom-gcc gcc-8 "gcc-objc" '("objc")
14cce84c
JK
1120 %objc-search-paths))
1121
1122(define-public gcc-objc-9
1123 (custom-gcc gcc-9 "gcc-objc" '("objc")
1124 %objc-search-paths))
1125
1126(define-public gcc-objc-10
1127 (custom-gcc gcc-10 "gcc-objc" '("objc")
1128 %objc-search-paths))
f66be84d 1129
b36c41ee
MB
1130(define-public gcc-objc-11
1131 (custom-gcc gcc-11 "gcc-objc" '("objc")
1132 %objc-search-paths))
1133
1134(define-public gcc-objc-12
1135 (custom-gcc gcc-12 "gcc-objc" '("objc")
1136 %objc-search-paths))
1137
4796b5d6 1138(define-public gcc-objc gcc-objc-10)
8b196ad2 1139
14cce84c
JK
1140(define %objc++-search-paths
1141 (list (search-path-specification
1142 (variable "OBJCPLUS_INCLUDE_PATH")
1143 (files '("include")))
1144 (search-path-specification
1145 (variable "LIBRARY_PATH")
1146 (files '("lib" "lib64")))))
1147
fdd6c726 1148(define-public gcc-objc++-4.8
009b53fd 1149 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
14cce84c 1150 %objc++-search-paths))
fdd6c726 1151
a5948c0d
RW
1152(define-public gcc-objc++-4.9
1153 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
14cce84c 1154 %objc++-search-paths))
fdd6c726 1155
ed8cdab8
EF
1156(define-public gcc-objc++-5
1157 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
14cce84c 1158 %objc++-search-paths))
ed8cdab8 1159
7a7c6308
EF
1160(define-public gcc-objc++-6
1161 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
14cce84c 1162 %objc++-search-paths))
7a7c6308 1163
e05f8d2f
EF
1164(define-public gcc-objc++-7
1165 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
14cce84c 1166 %objc++-search-paths))
e05f8d2f 1167
f66be84d
EB
1168(define-public gcc-objc++-8
1169 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
14cce84c
JK
1170 %objc++-search-paths))
1171
1172(define-public gcc-objc++-9
1173 (custom-gcc gcc-9 "gcc-objc++" '("obj-c++")
1174 %objc++-search-paths))
1175
1176(define-public gcc-objc++-10
1177 (custom-gcc gcc-10 "gcc-objc++" '("obj-c++")
1178 %objc++-search-paths))
f66be84d 1179
b36c41ee
MB
1180(define-public gcc-objc++-11
1181 (custom-gcc gcc-11 "gcc-objc++" '("obj-c++")
1182 %objc++-search-paths))
1183
1184(define-public gcc-objc++-12
1185 (custom-gcc gcc-12 "gcc-objc++" '("obj-c++")
1186 %objc++-search-paths))
1187
4796b5d6 1188(define-public gcc-objc++ gcc-objc++-10)
987a1183 1189
98b385d1
LC
1190(define (make-libstdc++-doc gcc)
1191 "Return a package with the libstdc++ documentation for GCC."
1192 (package
1193 (inherit gcc)
1194 (name "libstdc++-doc")
1195 (version (package-version gcc))
1196 (synopsis "GNU libstdc++ documentation")
1197 (outputs '("out"))
8394619b
LC
1198 (native-inputs (list doxygen
1199 texinfo
1200 libxml2
1201 libxslt
1202 docbook-xml
1203 docbook-xsl
1204 graphviz)) ;for 'dot', invoked by 'doxygen'
98b385d1
LC
1205 (inputs '())
1206 (propagated-inputs '())
1207 (arguments
1208 '(#:out-of-source? #t
1209 #:tests? #f ;it's just documentation
1210 #:phases (modify-phases %standard-phases
1211 (add-before 'configure 'chdir
1212 (lambda _
16111ad1 1213 (chdir "libstdc++-v3")))
98b385d1
LC
1214 (add-before 'configure 'set-xsl-directory
1215 (lambda* (#:key inputs #:allow-other-keys)
1216 (let ((docbook (assoc-ref inputs "docbook-xsl")))
1217 (substitute* (find-files "doc"
1218 "^Makefile\\.in$")
1219 (("@XSL_STYLE_DIR@")
1220 (string-append
1221 docbook "/xml/xsl/"
16111ad1 1222 (strip-store-file-name docbook)))))))
98b385d1
LC
1223 (replace 'build
1224 (lambda _
1225 ;; XXX: There's also a 'doc-info' target, but it
1226 ;; relies on docbook2X, which itself relies on
1227 ;; DocBook 4.1.2, which is not really usable
1228 ;; (lacks a catalog.xml.)
61a815eb
MW
1229 (invoke "make"
1230 "doc-html"
1231 "doc-man")))
98b385d1
LC
1232 (replace 'install
1233 (lambda* (#:key outputs #:allow-other-keys)
1234 (let ((out (assoc-ref outputs "out")))
61a815eb
MW
1235 (invoke "make"
1236 "doc-install-html"
798591b6
LC
1237 "doc-install-man")))))))
1238 (properties (alist-delete 'hidden? (package-properties gcc)))))
98b385d1 1239
629f4d2e
MW
1240(define-public libstdc++-doc-5
1241 (make-libstdc++-doc gcc-5))
98b385d1 1242
e7313ae2
LC
1243(define-public libstdc++-doc-9
1244 (make-libstdc++-doc gcc-9))
1245
832abc76
LC
1246(define-public isl
1247 (package
1248 (name "isl")
f0c20da7 1249 (version "0.23")
832abc76
LC
1250 (source (origin
1251 (method url-fetch)
75431d50
LC
1252 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1253 version ".tar.bz2")
832abc76 1254 (string-append %gcc-infrastructure
75431d50 1255 "isl-" version ".tar.bz2")))
832abc76
LC
1256 (sha256
1257 (base32
f0c20da7 1258 "0k91zck10zxs9sk3yrbb92y1j3w981w3fbwkfwd7kl779b0j52f5"))))
832abc76 1259 (build-system gnu-build-system)
5d8a4354
MB
1260 (outputs '("out" "static"))
1261 (arguments
1262 '(#:phases (modify-phases %standard-phases
1263 (add-after 'install 'move-static-library
1264 (lambda* (#:key outputs #:allow-other-keys)
1265 (let* ((out (assoc-ref outputs "out"))
1266 (static (assoc-ref outputs "static"))
1267 (source (string-append out "/lib/libisl.a"))
1268 (target (string-append static "/lib/libisl.a")))
1269 (mkdir-p (dirname target))
1270 (link source target)
1271 (delete-file source)
1272
1273 ;; Remove reference to libisl.a from the .la file so
1274 ;; libtool looks for it in the usual locations.
1275 (substitute* (string-append out "/lib/libisl.la")
1276 (("^old_library=.*")
16111ad1 1277 "old_library=''\n"))))))))
8394619b 1278 (inputs (list gmp))
75431d50 1279 (home-page "https://libisl.sourceforge.io/") ;https://repo.or.cz/w/isl.git
d93706ad 1280 (properties `((release-monitoring-url . ,home-page)))
832abc76 1281 (synopsis
9e771e3b
LC
1282 "Manipulating sets and relations of integer points \
1283bounded by linear constraints")
832abc76
LC
1284 (description
1285 "isl is a library for manipulating sets and relations of integer points
35b9e423 1286bounded by linear constraints. Supported operations on sets include
832abc76
LC
1287intersection, union, set difference, emptiness check, convex hull, (integer)
1288affine hull, integer projection, computing the lexicographic minimum using
1289parametric integer programming, coalescing and parametric vertex
35b9e423 1290enumeration. It also includes an ILP solver based on generalized basis
832abc76
LC
1291reduction, transitive closures on maps (which may encode infinite graphs),
1292dependence analysis and bounds on piecewise step-polynomials.")
1293 (license lgpl2.1+)))
1294
25bd7267
MB
1295(define-public isl-0.18
1296 (package
1297 (inherit isl)
1298 (version "0.18")
1299 (source (origin
1300 (method url-fetch)
75431d50 1301 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
25bd7267
MB
1302 version ".tar.bz2")
1303 (string-append %gcc-infrastructure
9f1da6ce 1304 "isl-" version ".tar.bz2")))
25bd7267
MB
1305 (sha256
1306 (base32
1307 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
1308
ab53bdf0
EF
1309(define-public isl-0.11
1310 (package
1311 (inherit isl)
1312 (name "isl")
1313 (version "0.11.1")
1314 (source (origin
1315 (method url-fetch)
75431d50
LC
1316 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1317 version ".tar.bz2")
ab53bdf0 1318 (string-append %gcc-infrastructure
75431d50 1319 "isl-" version ".tar.bz2")))
ab53bdf0
EF
1320 (sha256
1321 (base32
1322 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
1323 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
1324
832abc76
LC
1325(define-public cloog
1326 (package
1327 (name "cloog")
1328 (version "0.18.0")
1329 (source
1330 (origin
1331 (method url-fetch)
1332 (uri (list (string-append
1333 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
1334 version
1335 ".tar.gz")
1336 (string-append %gcc-infrastructure
1337 name "-" version ".tar.gz")))
1338 (sha256
1339 (base32
1340 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
1341 (file-name (string-append name "-" version ".tar.gz"))))
1342 (build-system gnu-build-system)
8394619b 1343 (inputs (list gmp isl-0.11))
832abc76
LC
1344 (arguments '(#:configure-flags '("--with-isl=system")))
1345 (home-page "http://www.cloog.org/")
9e771e3b 1346 (synopsis "Library to generate code for scanning Z-polyhedra")
832abc76
LC
1347 (description
1348 "CLooG is a free software library to generate code for scanning
1349Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
1350reaches each integral point of one or more parameterized polyhedra.
1351CLooG has been originally written to solve the code generation problem
1352for optimizing compilers based on the polytope model. Nevertheless it
1353is used now in various area e.g., to build control automata for
1354high-level synthesis or to find the best polynomial approximation of a
1355function. CLooG may help in any situation where scanning polyhedra
1356matters. While the user has full control on generated code quality,
1357CLooG is designed to avoid control overhead and to produce a very
1358effective code.")
1359 (license gpl2+)))
5c126b64 1360
50c7a1e2
LC
1361(define-public gnu-c-manual
1362 (package
1363 (name "gnu-c-manual")
d35f8c7c 1364 (version "0.2.5")
50c7a1e2
LC
1365 (source (origin
1366 (method url-fetch)
1367 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1368 version ".tar.gz"))
1369 (sha256
1370 (base32
d35f8c7c 1371 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
50c7a1e2 1372 (build-system gnu-build-system)
8394619b 1373 (native-inputs (list texinfo))
50c7a1e2
LC
1374 (arguments
1375 '(#:phases (modify-phases %standard-phases
1376 (delete 'configure)
1377 (delete 'check)
1378 (replace 'build
1379 (lambda _
9feb4fd5
MW
1380 (invoke "make"
1381 "gnu-c-manual.info"
1382 "gnu-c-manual.html")))
50c7a1e2
LC
1383 (replace 'install
1384 (lambda* (#:key outputs #:allow-other-keys)
1385 (let* ((out (assoc-ref outputs "out"))
1386 (info (string-append out "/share/info"))
1387 (html (string-append
1388 out "/share/doc/gnu-c-manual")))
1389 (mkdir-p info)
1390 (mkdir-p html)
1391
1392 (for-each (lambda (file)
1393 (copy-file file
1394 (string-append info "/"
1395 file)))
1396 (find-files "." "\\.info(-[0-9])?$"))
1397 (for-each (lambda (file)
1398 (copy-file file
1399 (string-append html "/"
1400 file)))
16111ad1 1401 (find-files "." "\\.html$"))))))))
50c7a1e2
LC
1402 (synopsis "Reference manual for the C programming language")
1403 (description
1404 "This is a reference manual for the C programming language, as
1405implemented by the GNU C Compiler (gcc). As a reference, it is not intended
1406to be a tutorial of the language. Rather, it outlines all of the constructs
1407of the language. Library functions are not included.")
6fd52309 1408 (home-page "https://www.gnu.org/software/gnu-c-manual/")
50c7a1e2 1409 (license fdl1.3+)))