projects/guix·blob ruby-team · refs

1958 lines · 86.4 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012-2025 Ludovic Courtès <[email protected]>
3;;; Copyright © 2014, 2015, 2018 Mark H Weaver <[email protected]>
4;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus <[email protected]>
5;;; Copyright © 2015, 2023 Andreas Enge <[email protected]>
6;;; Copyright © 2015-2018, 2020-2025 Efraim Flashner <[email protected]>
7;;; Copyright © 2016 Carlos Sánchez de La Lama <[email protected]>
8;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
9;;; Copyright © 2018, 2020, 2022 Marius Bakke <[email protected]>
10;;; Copyright © 2020 Joseph LaFreniere <[email protected]>
11;;; Copyright © 2020 Guy Fleury Iteriteka <[email protected]>
12;;; Copyright © 2020 Simon Tournier <[email protected]>
13;;; Copyright © 2021 Chris Marusich <[email protected]>
14;;; Copyright © 2021 Sarah Morgensen <[email protected]>
15;;; Copyright © 2022 Greg Hogan <[email protected]>
16;;; Copyright © 2024-2026 Zheng Junjie <[email protected]>
17;;; Copyright © 2023 Bruno Victal <[email protected]>
18;;; Copyright © 2023 Maxim Cournoyer <[email protected]>
19;;; Copyright © 2024 Nguyễn Gia Phong <[email protected]>
20;;; Copyright © 2025 Janneke Nieuwenhuizen <[email protected]>
21;;; Copyright © 2025 Leo Nikkilä <[email protected]>
22;;; Copyright © 2025-2026 Jonas Meeuws <[email protected]>
23;;;
24;;; This file is part of GNU Guix.
25;;;
26;;; GNU Guix is free software; you can redistribute it and/or modify it
27;;; under the terms of the GNU General Public License as published by
28;;; the Free Software Foundation; either version 3 of the License, or (at
29;;; your option) any later version.
30;;;
31;;; GNU Guix is distributed in the hope that it will be useful, but
32;;; WITHOUT ANY WARRANTY; without even the implied warranty of
33;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34;;; GNU General Public License for more details.
35;;;
36;;; You should have received a copy of the GNU General Public License
37;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
38
39(define-module (gnu packages gcc)
40 #:use-module ((guix licenses)
41 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
42 #:use-module (gnu packages)
43 #:use-module (gnu packages autotools)
44 #:use-module (gnu packages bootstrap)
45 #:use-module (gnu packages compression)
46 #:use-module (gnu packages multiprecision)
47 #:use-module (gnu packages texinfo)
48 #:use-module (gnu packages dejagnu)
49 #:use-module (gnu packages documentation)
50 #:use-module (gnu packages xml)
51 #:use-module (gnu packages docbook)
52 #:use-module (gnu packages graphviz)
53 #:use-module (gnu packages elf)
54 #:use-module (gnu packages compiler-tools)
55 #:use-module (gnu packages perl)
56 #:use-module (guix packages)
57 #:use-module (guix download)
58 #:use-module (guix memoization)
59 #:use-module (guix build-system copy)
60 #:use-module (guix build-system gnu)
61 #:use-module (guix build-system trivial)
62 #:use-module (guix git-download)
63 #:use-module (guix gexp)
64 #:use-module (guix search-paths)
65 #:use-module (guix utils)
66 #:use-module (srfi srfi-1)
67 #:use-module (ice-9 match)
68 #:use-module (ice-9 regex))
69
70(define %gcc-infrastructure
71 ;; Base URL for GCC's infrastructure.
72 "mirror://gcc/infrastructure/")
73
74(define (gcc-configure-flags-for-triplet target)
75 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
76
77The purpose of this procedure is to translate extended GNU triplets---e.g.,
78where the OS part is overloaded to denote a specific ABI---into GCC
79`configure' options. We take extended GNU triplets that glibc recognizes."
80 (cond ((string-match "^mips64el.*gnuabin?64$" target)
81 ;; Triplets recognized by glibc as denoting the N64 ABI; see
82 ;; ports/sysdeps/mips/preconfigure.
83 '("--with-abi=64"))
84
85 ((string-match "^arm.*-gnueabihf$" target)
86 '("--with-arch=armv7-a"
87 "--with-float=hard"
88 "--with-mode=thumb"
89 "--with-fpu=neon"))
90
91 ((string-match "x86_64-linux-gnux32" target)
92 '("--with-abi=mx32"))
93
94 ((and (string-suffix? "-gnu" target)
95 (not (string-contains target "-linux")))
96 ;; Cross-compilation of libcilkrts in GCC 5.5.0 to GNU/Hurd fails
97 ;; with:
98 ;; libcilkrts/runtime/os-unix.c:388:2: error: #error "Unknown architecture"
99 ;; Cilk has been removed from GCC 8 anyway.
100 '("--disable-libcilkrts"))
101
102 ;; glibc needs the 128-bit long double type on these architectures.
103 ((or (string-prefix? "powerpc64le-" target)
104 (string-prefix? "powerpc-" target))
105 '("--with-long-double-128"))
106
107 ;; GCC 11.3.0's <libgcov.h> includes <sys/mman.h>, which MinGW lacks:
108 ;; <https://bugs.gentoo.org/show_bug.cgi?id=843989>.
109 ((target-mingw? target)
110 '("--disable-gcov"))
111
112 (else
113 ;; TODO: Add `arm.*-gnueabi', etc.
114 '())))
115
116(define-public gcc-base
117 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
118 (maybe-target-tools
119 (lambda ()
120 ;; Return the `_FOR_TARGET' variables that are needed when
121 ;; cross-compiling GCC.
122 (let ((target (%current-target-system)))
123 (if target
124 (map (lambda (var tool)
125 (string-append (string-append var "_FOR_TARGET")
126 "=" target "-" tool))
127 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
128 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
129 '()))))
130 (libdir
131 (let ((base '(or (assoc-ref outputs "lib")
132 (assoc-ref outputs "out"))))
133 (lambda ()
134 ;; Return the directory that contains lib/libgcc_s.so et al.
135 (if (%current-target-system)
136 `(string-append ,base "/" ,(%current-target-system))
137 base))))
138 (configure-flags
139 (lambda ()
140 ;; This is terrible. Since we have two levels of quasiquotation,
141 ;; we have to do this convoluted thing just so we can insert the
142 ;; contents of (maybe-target-tools).
143 (list 'quasiquote
144 (append
145 '("--enable-plugin"
146 "--enable-languages=c,c++,objc,obj-c++"
147 "--disable-multilib"
148 "--with-system-zlib"
149
150 ;; No pre-compiled libstdc++ headers, to save space.
151 "--disable-libstdcxx-pch"
152
153 "--with-local-prefix=/no-gcc-local-prefix"
154
155 ;; With a separate "lib" output, the build system
156 ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force
157 ;; it. (Don't use a versioned sub-directory, that's
158 ;; unnecessary.)
159 ,(string-append "--with-gxx-include-dir="
160 (assoc-ref %outputs "out")
161 "/include/c++")
162
163 ,(let ((libc (assoc-ref %build-inputs "libc")))
164 (if libc
165 (string-append "--with-native-system-header-dir=" libc
166 "/include")
167 "--without-headers")))
168
169 ;; Pass the right options for the target triplet.
170 (let ((triplet
171 (or (%current-target-system)
172 (nix-system->gnu-triplet (%current-system)))))
173 (gcc-configure-flags-for-triplet triplet))
174
175 (maybe-target-tools))))))
176 (hidden-package
177 (package
178 (name "gcc")
179 (version "4.7.4")
180 (source (origin
181 (method url-fetch)
182 (uri (string-append "mirror://gnu/gcc/gcc-"
183 version "/gcc-" version ".tar.bz2"))
184 (sha256
185 (base32
186 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
187 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
188 "gcc-fix-texi2pod.patch"))))
189 (build-system gnu-build-system)
190
191 ;; Separate out the run-time support libraries because all the
192 ;; dynamic-linked objects depend on it.
193 (outputs '("out" ;commands, etc. (60+ MiB)
194 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
195 "debug")) ;debug symbols of run-time libraries
196
197 (inputs (list gmp mpfr mpc elfutils zlib))
198
199 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
200 ;; Newer texinfos fail to build the manual, so we use an older one.
201 (native-inputs (list perl ;for manpages
202 texinfo-5))
203
204 (arguments
205 `(#:out-of-source? #t
206 #:configure-flags ,(configure-flags)
207
208 #:make-flags
209 ;; None of the flags below are needed when doing a Canadian cross.
210 ;; TODO: Simplify this.
211 ,(if (%current-target-system)
212 (if stripped?
213 ''("CFLAGS=-g0 -O2")
214 ''())
215 `(let* ((libc (assoc-ref %build-inputs "libc"))
216 (libc-native (or (assoc-ref %build-inputs "libc-native")
217 libc)))
218 `(,@(if libc
219 (list (string-append "LDFLAGS_FOR_TARGET="
220 "-B" libc "/lib "
221 "-Wl,-dynamic-linker "
222 "-Wl," libc
223 ,(glibc-dynamic-linker)))
224 '())
225
226 ;; Native programs like 'genhooks' also need that right.
227 ,(string-append "LDFLAGS="
228 "-Wl,-rpath=" libc-native "/lib "
229 "-Wl,-dynamic-linker "
230 "-Wl," libc-native ,(glibc-dynamic-linker))
231 ,(string-append "BOOT_CFLAGS=-O2 "
232 ,(if stripped? "-g0" "-g")))))
233
234 #:tests? #f
235
236 #:phases
237 (modify-phases %standard-phases
238 (add-before 'configure 'relax-gcc-14s-strictness
239 (lambda* (#:key inputs #:allow-other-keys)
240 (let ((bash (assoc-ref inputs "bash"))
241 (wrapper (string-append (getcwd) "/gcc.sh"))
242 (stage-wrapper (string-append (getcwd) "/stage-gcc.sh")))
243 (with-output-to-file wrapper
244 (lambda _
245 (format #t "#! ~a/bin/bash
246exec gcc \"$@\" \
247 -Wno-error=implicit-function-declaration"
248 bash)))
249 (chmod wrapper #o555)
250 (with-output-to-file stage-wrapper
251 (lambda _
252 (format #t "#! ~a/bin/bash
253exec \"$@\" \
254 -Wno-error=implicit-function-declaration"
255 bash)))
256 (chmod stage-wrapper #o555)
257 ;; Rather than adding CC to #:configure-flags and
258 ;; STAGE_CC_WRAPPER to #:make-flags, we add them to the
259 ;; environment in this easily removable stage.
260 (cond (,(%current-target-system) ;cross-build?
261 (setenv "CC_FOR_BUILD" wrapper))
262 (else
263 (setenv "CC" wrapper)
264 (setenv "STAGE_CC_WRAPPER" stage-wrapper))))))
265 (add-before 'configure 'pre-configure
266 (lambda* (#:key inputs outputs #:allow-other-keys)
267 (let ((libdir ,(libdir))
268 (libc (assoc-ref inputs "libc")))
269 (when libc
270 ;; The following is not performed for `--without-headers'
271 ;; cross-compiler builds.
272
273 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
274 ;; single line, to allow the next step to work properly.
275 (for-each
276 (lambda (x)
277 (substitute* (find-files "gcc/config"
278 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
279 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
280 line)))
281 '(1 2 3))
282
283 ;; Fix the dynamic linker's file name.
284 (substitute* (find-files "gcc/config"
285 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
286 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
287 _ gnu-user suffix)
288 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
289 gnu-user suffix
290 (string-append libc ,(glibc-dynamic-linker)))))
291
292 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
293 ;; `crt{begin,end}.o', which come with GCC.
294 (substitute* (find-files "gcc/config"
295 "^gnu-user.*\\.h$")
296 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
297 ;; Help libgcc_s.so be found (see also below.) Always use
298 ;; '-lgcc_s' so that libgcc_s.so is always found by those
299 ;; programs that use 'pthread_cancel' (glibc dlopens
300 ;; libgcc_s.so when pthread_cancel support is needed, but
301 ;; having it in the application's RUNPATH isn't enough; see
302 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
303 ;;
304 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
305 ;; later phase of %gcc-static. If you change the string
306 ;; below, make sure to update the relevant code in
307 ;; %gcc-static package as needed.
308 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
309\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
310 libc libc libdir suffix))
311 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
312 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib/\"
313#define STANDARD_STARTFILE_PREFIX_2 \"\"
314~a"
315 libc line)))
316
317 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
318 ;; GNU_USER_* defines. Do the above for this case.
319 (substitute*
320 "gcc/config/rs6000/sysv4.h"
321 (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
322 (format #f "#define LIB_LINUX_SPEC \
323\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
324 libc libc libdir suffix))
325 (("#define STARTFILE_LINUX_SPEC.*$" line)
326 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib/\"
327#define STANDARD_STARTFILE_PREFIX_2 \"\"
328~a"
329 libc line))))
330
331 (when (file-exists? "gcc/config/rs6000")
332 ;; Force powerpc libdir to be /lib and not /lib64
333 (substitute* (find-files "gcc/config/rs6000")
334 (("/lib64") "/lib")))
335
336 ;; Don't retain a dependency on the build-time sed.
337 (substitute* "fixincludes/fixincl.x"
338 (("static char const sed_cmd_z\\[\\] =.*;")
339 "static char const sed_cmd_z[] = \"sed\";"))
340
341 ;; Aarch64 support didn't land in GCC until the 4.8 series.
342 (when (file-exists? "gcc/config/aarch64")
343 ;; Force Aarch64 libdir to be /lib and not /lib64
344 (substitute* "gcc/config/aarch64/t-aarch64-linux"
345 (("lib64") "lib")))
346
347 ;; The STARTFILE_PREFIX_SPEC prevents gcc from finding the
348 ;; gcc:lib output, which causes ld to not find -lgcc_s.
349 (when (file-exists? "gcc/config/riscv")
350 (substitute* '("gcc/config/riscv/linux.h"
351 "gcc/config/riscv/riscv.h") ; GCC < 10
352 (("define STARTFILE_PREFIX_SPEC")
353 "define __STARTFILE_PREFIX_SPEC")))
354
355 (when (file-exists? "libbacktrace")
356 ;; GCC 4.8+ comes with libbacktrace. By default it builds
357 ;; with -Werror, which fails with a -Wcast-qual error in glibc
358 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
359 (substitute* "libbacktrace/configure"
360 (("WARN_FLAGS=(.*)-Werror" _ flags)
361 (string-append "WARN_FLAGS=" flags)))
362
363 (when (file-exists? "libsanitizer/libbacktrace")
364 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
365 (substitute* "libsanitizer/libbacktrace/Makefile.in"
366 (("-Werror")
367 ""))))
368
369 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
370 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
371 ;; and <http://bugs.gnu.org/20358>.
372 (substitute* "libstdc++-v3/src/Makefile.in"
373 (("^OPT_LDFLAGS = ")
374 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
375
376 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
377 ;; circularity between "out" and "lib". (Note:
378 ;; --with-python-dir is useless because it imposes $(prefix) as
379 ;; the parent directory.)
380 (substitute* "libstdc++-v3/python/Makefile.in"
381 (("pythondir = .*$")
382 (string-append "pythondir = " libdir "/share"
383 "/gcc-$(gcc_version)/python\n")))
384
385 ;; Avoid another circularity between the outputs: this #define
386 ;; ends up in auto-host.h in the "lib" output, referring to
387 ;; "out". (This variable is used to augment cpp's search path,
388 ;; but there's nothing useful to look for here.)
389 (substitute* "gcc/config.in"
390 (("PREFIX_INCLUDE_DIR")
391 "PREFIX_INCLUDE_DIR_isnt_necessary_here")))))
392
393 (add-after 'configure 'post-configure
394 (lambda _
395 ;; Don't store configure flags, to avoid retaining references to
396 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
397 (substitute* "Makefile"
398 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
399 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))))))
400 (native-search-paths %gcc-search-paths)
401 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
402 (synopsis "GNU Compiler Collection")
403 (description
404 "GCC is the GNU Compiler Collection. It provides compiler front-ends
405for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
406Go. It also includes runtime support libraries for these languages.")
407 (license gpl3+)
408 (home-page "https://gcc.gnu.org/")))))
409
410(define-public gcc-4.7
411 (package (inherit gcc-base)
412 (version "4.7.4")
413 (source (origin
414 (method url-fetch)
415 (uri (string-append "mirror://gnu/gcc/gcc-"
416 version "/gcc-" version ".tar.bz2"))
417 (sha256
418 (base32
419 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
420 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
421 "gcc-fix-texi2pod.patch"))
422 (modules '((guix build utils)))
423 ;; This is required for building with glibc-2.26.
424 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
425 (snippet
426 '(for-each
427 (lambda (dir)
428 (substitute* (string-append "libgcc/config/"
429 dir "/linux-unwind.h")
430 (("struct ucontext") "ucontext_t")))
431 '("alpha" "bfin" "i386" "m68k"
432 "pa" "sh" "tilepro" "xtensa")))))
433 (arguments
434 (if (%current-target-system)
435 arguments
436 ;; For native builds of some GCC versions the C++ include path needs to
437 ;; be adjusted so it does not interfere with GCC's own build processes.
438 (substitute-keyword-arguments arguments
439 ((#:modules modules %default-gnu-modules)
440 `((srfi srfi-1)
441 ,@modules))
442 ((#:phases phases)
443 `(modify-phases ,phases
444 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
445 (lambda* (#:key inputs #:allow-other-keys)
446 (let ((libc (assoc-ref inputs "libc"))
447 (gcc (assoc-ref inputs "gcc")))
448 (setenv "CPLUS_INCLUDE_PATH"
449 (string-join (fold delete
450 (string-split (getenv "CPLUS_INCLUDE_PATH")
451 #\:)
452 (list (string-append libc "/include")
453 (string-append gcc "/include/c++")))
454 ":"))
455 (format #t
456 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
457 (getenv "CPLUS_INCLUDE_PATH"))))))))))
458 (supported-systems (fold delete %supported-systems
459 '("aarch64-linux" "riscv64-linux"
460 "powerpc64le-linux" "x86_64-gnu")))))
461
462(define-public gcc-4.8
463 (package (inherit gcc-base)
464 (version "4.8.5")
465 (source (origin
466 (method url-fetch)
467 (uri (string-append "mirror://gnu/gcc/gcc-"
468 version "/gcc-" version ".tar.bz2"))
469 (sha256
470 (base32
471 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
472 (patches (search-patches "gcc-arm-link-spec-fix.patch"
473 "gcc-4.8-libsanitizer-fix.patch"
474 "gcc-asan-missing-include.patch"
475 "gcc-fix-texi2pod.patch"))
476 (modules '((guix build utils)))
477 ;; This is required for building with glibc-2.26.
478 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
479 (snippet
480 '(for-each
481 (lambda (dir)
482 (substitute* (string-append "libgcc/config/"
483 dir "/linux-unwind.h")
484 (("struct ucontext") "ucontext_t")))
485 '("aarch64" "alpha" "bfin" "i386" "m68k"
486 "pa" "sh" "tilepro" "xtensa")))))
487 (arguments
488 (if (%current-target-system)
489 (substitute-keyword-arguments arguments
490 ((#:configure-flags flags '())
491 `(cons "CXX=g++ -std=c++03" ,flags)))
492 (substitute-keyword-arguments arguments
493 ((#:modules modules %default-gnu-modules)
494 `((srfi srfi-1)
495 ,@modules))
496 ((#:configure-flags flags '())
497 `(cons "CXX=g++ -std=c++03" ,flags))
498 ;; For native builds of some GCC versions the C++ include path needs to
499 ;; be adjusted so it does not interfere with GCC's own build processes.
500 ((#:phases phases)
501 `(modify-phases ,phases
502 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
503 (lambda* (#:key inputs #:allow-other-keys)
504 (let ((libc (assoc-ref inputs "libc"))
505 (gcc (assoc-ref inputs "gcc")))
506 (setenv "CPLUS_INCLUDE_PATH"
507 (string-join (fold delete
508 (string-split (getenv "CPLUS_INCLUDE_PATH")
509 #\:)
510 (list (string-append libc "/include")
511 (string-append gcc "/include/c++")))
512 ":"))
513 (format #t
514 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
515 (getenv "CPLUS_INCLUDE_PATH"))))))))))
516 (supported-systems (fold delete %supported-systems
517 '("riscv64-linux" "x86_64-gnu")))
518 (inputs
519 (modify-inputs inputs
520 (prepend isl-0.11 cloog)))))
521
522(define-public gcc-4.9
523 (package (inherit gcc-base)
524 (version "4.9.4")
525 (source (origin
526 (method url-fetch)
527 (uri (string-append "mirror://gnu/gcc/gcc-"
528 version "/gcc-" version ".tar.bz2"))
529 (sha256
530 (base32
531 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
532 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
533 "gcc-4.9-libsanitizer-ustat.patch"
534 "gcc-4.9-libsanitizer-mode-size.patch"
535 "gcc-arm-bug-71399.patch"
536 "gcc-asan-missing-include.patch"
537 "gcc-libvtv-runpath.patch"
538 "gcc-fix-texi2pod.patch"))
539 (modules '((guix build utils)))
540 ;; This is required for building with glibc-2.26.
541 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
542 (snippet
543 '(for-each
544 (lambda (dir)
545 (substitute* (string-append "libgcc/config/"
546 dir "/linux-unwind.h")
547 (("struct ucontext") "ucontext_t")))
548 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
549 "pa" "sh" "tilepro" "xtensa")))))
550 (arguments
551 (if (%current-target-system)
552 (substitute-keyword-arguments arguments
553 ((#:configure-flags flags '())
554 `(cons "CXX=g++ -std=c++11" ,flags)))
555 (substitute-keyword-arguments arguments
556 ((#:modules modules %default-gnu-modules)
557 `((srfi srfi-1)
558 ,@modules))
559 ((#:configure-flags flags '())
560 `(cons "CXX=g++ -std=c++11" ,flags))
561 ;; For native builds of some GCC versions the C++ include path needs to
562 ;; be adjusted so it does not interfere with GCC's own build processes.
563 ((#:phases phases)
564 `(modify-phases ,phases
565 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
566 (lambda* (#:key inputs #:allow-other-keys)
567 (let ((libc (assoc-ref inputs "libc"))
568 (gcc (assoc-ref inputs "gcc")))
569 (setenv "CPLUS_INCLUDE_PATH"
570 (string-join (fold delete
571 (string-split (getenv "CPLUS_INCLUDE_PATH")
572 #\:)
573 (list (string-append libc "/include")
574 (string-append gcc "/include/c++")))
575 ":"))
576 (format #t
577 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
578 (getenv "CPLUS_INCLUDE_PATH"))))))))))
579 ;; Override inherited texinfo-5 with latest version.
580 (native-inputs (list perl ;for manpages
581 texinfo))
582 (inputs
583 (modify-inputs inputs
584 (prepend isl-0.11 cloog)))
585 (supported-systems (fold delete %supported-systems
586 '("riscv64-linux" "x86_64-gnu")))))
587
588(define gcc-canadian-cross-objdump-snippet
589 ;; Fix 'libcc1/configure' error when cross-compiling GCC. Without that,
590 ;; 'libcc1/configure' wrongfully determines that '-rdynamic' support is
591 ;; missing because $gcc_cv_objdump is empty:
592 ;;
593 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
594 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
595 #~(substitute* "libcc1/configure"
596 (("\\$gcc_cv_objdump -T")
597 "$OBJDUMP_FOR_TARGET -T")))
598
599(define-public gcc-5
600 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
601 ;; them in a VPATH build.
602 (package (inherit gcc-base)
603 (version "5.5.0")
604 (source (origin
605 (method url-fetch)
606 (uri (string-append "mirror://gnu/gcc/gcc-"
607 version "/gcc-" version ".tar.xz"))
608 (sha256
609 (base32
610 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
611 (patches (search-patches "gcc-arm-bug-71399.patch"
612 "gcc-libsanitizer-ustat.patch"
613 "gcc-strmov-store-file-names.patch"
614 "gcc-5.0-libvtv-runpath.patch"
615 "gcc-5-source-date-epoch-1.patch"
616 "gcc-5-source-date-epoch-2.patch"
617 "gcc-5.5.0-libstdc++-xmlcatalog.patch"
618 "gcc-13.2.0-libstdc++-docbook-xsl-uri.patch"
619 "gcc-13.2.0-libstdc++-info-install-fix.patch"
620 "gcc-7-libsanitizer-fsconfig-command.patch"
621 "gcc-6-libsanitizer-mode-size.patch"
622 "gcc-fix-texi2pod.patch"
623 "gcc-5-hurd.patch"
624 ;; See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86162
625 "gcc-5-fix-powerpc64le-build.patch"))
626 (modules '((guix build utils)))
627 (snippet gcc-canadian-cross-objdump-snippet)))
628 (arguments
629 (substitute-keyword-arguments arguments
630 ((#:modules modules %default-gnu-modules)
631 `((srfi srfi-1)
632 ,@modules))
633 ((#:configure-flags flags '())
634 `(cons "CXX=g++ -std=c++11" ,flags))
635 ;; For native builds of some GCC versions the C++ include path needs to
636 ;; be adjusted so it does not interfere with GCC's own build processes.
637 ((#:phases phases)
638 (if (%current-target-system)
639 phases
640 `(modify-phases ,phases
641 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
642 (lambda* (#:key inputs #:allow-other-keys)
643 (let ((libc (assoc-ref inputs "libc"))
644 (gcc (assoc-ref inputs "gcc")))
645 (setenv "CPLUS_INCLUDE_PATH"
646 (string-join (fold delete
647 (string-split (getenv "CPLUS_INCLUDE_PATH")
648 #\:)
649 (list (string-append libc "/include")
650 (string-append gcc "/include/c++")))
651 ":"))
652 (format #t
653 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
654 (getenv "CPLUS_INCLUDE_PATH"))))))))))
655 (native-inputs (list perl ;for manpages
656 texinfo))
657 (inputs
658 (modify-inputs inputs
659 (prepend ;; GCC5 needs <isl/band.h> which is removed in later versions.
660 isl-0.18)))
661 (supported-systems (fold delete %supported-systems
662 '("riscv64-linux" "x86_64-gnu")))))
663
664(define-public gcc-6
665 (package
666 (inherit gcc-base)
667 (version "6.5.0")
668 (source (origin
669 (method url-fetch)
670 (uri (string-append "mirror://gnu/gcc/gcc-"
671 version "/gcc-" version ".tar.xz"))
672 (sha256
673 (base32
674 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
675 (patches (search-patches "gcc-strmov-store-file-names.patch"
676 "gcc-7-libsanitizer-fsconfig-command.patch"
677 "gcc-6-libsanitizer-mode-size.patch"
678 "gcc-6-source-date-epoch-1.patch"
679 "gcc-6-source-date-epoch-2.patch"
680 "gcc-5.0-libvtv-runpath.patch"))))
681
682 (native-inputs (list perl ;for manpages
683 texinfo))
684 (inputs
685 `(("isl" ,isl)
686
687 ;; XXX: This gross hack allows us to have libstdc++'s <bits/c++config.h>
688 ;; in the search path, thereby avoiding misconfiguration of libstdc++:
689 ;; <https://bugs.gnu.org/42392>.
690 ("libstdc++" ,(make-libstdc++-headers this-package))
691
692 ,@(package-inputs gcc-base)))))
693
694(define %gcc-7.5-aarch64-micro-architectures
695 ;; Suitable '-march' values for GCC 7.5 (info "(gcc) AArch64 Options").
696 ;; TODO: Allow dynamically adding feature flags.
697 '("armv8-a" "armv8.1-a" "armv8.2-a" "armv8.3-a"))
698
699(define %gcc-7.5-armhf-micro-architectures
700 ;; Suitable '-march' values for GCC 7.5 (info "(gcc) ARM Options").
701 ;; TODO: Allow dynamically adding feature flags.
702 '("armv7" "armv7-a" "armv7-m" "armv7-r" "armv7e-m" "armv7ve"
703 "armv8-a" "armv8-a+crc" "armv8.1-a" "armv8.1-a+crc"
704 "armv8-m.base" "armv8-m.main" "armv8-m.main+dsp"
705 "iwmmxt" "iwmmxt2" "armv8.2-a"))
706
707(define %gcc-7.5-x86_64-micro-architectures
708 ;; Suitable '-march' values for GCC 7.5 (info "(gcc) x86 Options").
709 '("core2" "nehalem" "westmere" "sandybridge" "ivybridge"
710 "haswell" "broadwell" "skylake" "bonnell" "silvermont"
711 "knl" "skylake-avx512"
712
713 "k8" "k8-sse3" "barcelona"
714 "bdver1" "bdver2" "bdver3" "bdver4"
715 "znver1"
716 "btver1" "btver2" "geode"))
717
718(define %gcc-10-aarch64-micro-architectures
719 ;; Suitable '-march' values for GCC 10.
720 ;; TODO: Allow dynamically adding feature flags.
721 (append %gcc-7.5-aarch64-micro-architectures
722 '("armv8.4-a" "armv8.5-a" "armv8.6-a")))
723
724(define %gcc-10-armhf-micro-architectures
725 ;; Suitable '-march' values for GCC 10.
726 ;; TODO: Allow dynamically adding feature flags.
727 (append %gcc-7.5-armhf-micro-architectures
728 '("armv8.3-a" "armv8.4-a" "armv8.5-a" "armv8.6-a"
729 "armv8-r" "armv8.1-m.main")))
730
731(define %gcc-10-ppc64le-micro-architectures
732 '("power8" "power9" "power10" "powerpc64le"))
733
734(define %gcc-10-x86_64-micro-architectures
735 ;; Suitable '-march' values for GCC 10.
736 (append %gcc-7.5-x86_64-micro-architectures
737 '("goldmont" "goldmont-plus" "tremont"
738 "knm" "cannonlake" "icelake-client" "icelake-server"
739 "cascadelake" "cooperlake" "tigerlake"
740
741 "znver2" "znver3")))
742
743(define %gcc-11-aarch64-micro-architectures
744 ;; Suitable '-march' values for GCC 11.
745 (append %gcc-10-aarch64-micro-architectures
746 '("armv8-r")))
747
748(define %gcc-11-armhf-micro-architectures
749 %gcc-10-armhf-micro-architectures)
750
751(define %gcc-11-x86_64-micro-architectures
752 ;; Suitable '-march' values for GCC 11.
753 (append %gcc-10-x86_64-micro-architectures
754 '("sapphirerapids" "alderlake" "rocketlake" ;Intel
755
756 "btver1" "btver2" ;AMD
757
758 ;; psABI micro-architecture levels
759 "x86-64" "x86-64-v2" "x86-64-v3" "x86-64-v4")))
760
761;; Suitable '-march' values for GCC 12.
762(define %gcc-12-aarch64-micro-architectures
763 (append %gcc-11-aarch64-micro-architectures
764 '("armv8.7-a" "armv8.8-a" "armv9-a")))
765
766(define %gcc-12-armhf-micro-architectures
767 (append %gcc-11-armhf-micro-architectures
768 '("armv9-a")))
769
770(define %gcc-12-x86_64-micro-architectures
771 (append %gcc-11-x86_64-micro-architectures
772 '("znver4"))) ;AMD
773
774;; Suitable '-march' values for GCC 13.
775(define %gcc-13-aarch64-micro-architectures
776 (append %gcc-12-aarch64-micro-architectures
777 '("armv9.1-a" "armv9.2-a" "armv9.3-a")))
778
779(define %gcc-13-armhf-micro-architectures
780 %gcc-12-armhf-micro-architectures)
781
782(define %gcc-13-x86_64-micro-architectures
783 (append %gcc-12-x86_64-micro-architectures
784 '("graniterapids" ;Intel
785 "lujiazui")))
786
787(define %gcc-14-aarch64-micro-architectures
788 (append %gcc-13-aarch64-micro-architectures
789 '("armv9.4-a")))
790
791(define %gcc-14-ppc64le-micro-architectures
792 (append %gcc-10-ppc64le-micro-architectures
793 '("power11")))
794
795(define %gcc-14-x86_64-micro-architectures
796 (append %gcc-13-x86_64-micro-architectures
797 '("znver5" ;AMD
798 "yongfeng")))
799
800(define %gcc-15-aarch64-micro-architectures
801 (append %gcc-14-aarch64-micro-architectures
802 '("armv9.5-a")))
803
804(define %gcc-15-x86_64-micro-architectures
805 (append
806 (fold delete %gcc-14-x86_64-micro-architectures
807 '("knm" "knl"))
808 '("diamondrapids" ;Intel
809 "shijidadao")))
810
811(define-public gcc-7
812 (package
813 (inherit gcc-base)
814 (version "7.5.0")
815 (source (origin
816 (method url-fetch)
817 (uri (string-append "mirror://gnu/gcc/gcc-"
818 version "/gcc-" version ".tar.xz"))
819 (sha256
820 (base32
821 "0qg6kqc5l72hpnj4vr6l0p69qav0rh4anlkk3y55540zy3klc6dq"))
822 (patches (search-patches "gcc-strmov-store-file-names.patch"
823 "gcc-7-libsanitizer-mode-size.patch"
824 "gcc-7-libsanitizer-fsconfig-command.patch"
825 "gcc-5.0-libvtv-runpath.patch"
826 "gcc-libstdc++-newer-gcc.patch"))))
827 (native-inputs (list perl ;for manpages
828 texinfo))
829 (inputs
830 `(("isl" ,isl)
831
832 ;; XXX: This gross hack allows us to have libstdc++'s <bits/c++config.h>
833 ;; in the search path, thereby avoiding misconfiguration of libstdc++:
834 ;; <https://bugs.gnu.org/42392>.
835 ("libstdc++" ,(make-libstdc++-headers this-package))
836
837 ,@(package-inputs gcc-base)))
838 (description
839 "GCC is the GNU Compiler Collection. It provides compiler front-ends
840for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
841It also includes runtime support libraries for these languages.")
842 (properties
843 `((compiler-cpu-architectures
844 ("aarch64" ,@%gcc-7.5-aarch64-micro-architectures)
845 ("armhf" ,@%gcc-7.5-armhf-micro-architectures)
846 ("i686" ,@%gcc-7.5-x86_64-micro-architectures)
847 ("x86_64" ,@%gcc-7.5-x86_64-micro-architectures))
848 ,@(package-properties gcc-6)))))
849
850(define-public gcc-8
851 (package
852 (inherit gcc-7)
853 (version "8.5.0")
854 (source (origin
855 (method url-fetch)
856 (uri (string-append "mirror://gnu/gcc/gcc-"
857 version "/gcc-" version ".tar.xz"))
858 (sha256
859 (base32
860 "0l7d4m9jx124xsk6xardchgy2k5j5l2b15q322k31f0va4d8826k"))
861 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
862 "gcc-7-libsanitizer-fsconfig-command.patch"
863 "gcc-5.0-libvtv-runpath.patch"
864 "gcc-8-sort-libtool-find-output.patch"
865 "gcc-libstdc++-newer-gcc.patch"))
866 (modules '((guix build utils)))
867 (snippet gcc-canadian-cross-objdump-snippet)))))
868
869(define-public gcc-9
870 (package
871 (inherit gcc-8)
872 (version "9.5.0")
873 (source (origin
874 (method url-fetch)
875 (uri (string-append "mirror://gnu/gcc/gcc-"
876 version "/gcc-" version ".tar.xz"))
877 (sha256
878 (base32
879 "13ygjmd938m0wmy946pxdhz9i1wq7z4w10l6pvidak0xxxj9yxi7"))
880 (patches (search-patches "gcc-7-libsanitizer-fsconfig-command.patch"
881 "gcc-13.2.0-libstdc++-docbook-xsl-uri.patch"
882 "gcc-13.2.0-libstdc++-info-install-fix.patch"
883 "gcc-9-strmov-store-file-names.patch"
884 "gcc-9-asan-fix-limits-include.patch"
885 "gcc-5.0-libvtv-runpath.patch"
886 "gcc-libstdc++-newer-gcc.patch"))
887 (modules '((guix build utils)))
888 (snippet gcc-canadian-cross-objdump-snippet)))))
889
890(define-public gcc-10
891 (package
892 (inherit gcc-8)
893 (version "10.5.0")
894 (source (origin
895 (method url-fetch)
896 (uri (string-append "mirror://gnu/gcc/gcc-"
897 version "/gcc-" version ".tar.xz"))
898 (sha256
899 (base32
900 "1h87lcfaga0ydsf4pkhwlnjr8mky5ix8npbv6iy3jvzlzm1ra415"))
901 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
902 "gcc-5.0-libvtv-runpath.patch"
903 "gcc-10-libsanitizer-no-crypt.patch"
904 "gcc-libstdc++-newer-gcc.patch"))
905 (modules '((guix build utils)))
906 (snippet gcc-canadian-cross-objdump-snippet)))
907 (properties
908 `((compiler-cpu-architectures
909 ("aarch64" ,@%gcc-10-aarch64-micro-architectures)
910 ("armhf" ,@%gcc-10-armhf-micro-architectures)
911 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
912 ("i686" ,@%gcc-10-x86_64-micro-architectures)
913 ("x86_64" ,@%gcc-10-x86_64-micro-architectures))
914 ,@(package-properties gcc-8)))))
915
916(define-public gcc-11
917 (package
918 (inherit gcc-8)
919 (version "11.5.0")
920 (source (origin
921 (method url-fetch)
922 (uri (string-append "mirror://gnu/gcc/gcc-"
923 version "/gcc-" version ".tar.xz"))
924 (sha256
925 (base32
926 "0y1l6q4iy94nr30r3189fbb82ljbdqkq87y0y23wyifmx9l1iqm6"))
927 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
928 "gcc-5.0-libvtv-runpath.patch"
929 "gcc-10-libsanitizer-no-crypt.patch"
930 "gcc-11-libstdc++-hurd-libpthread.patch"
931 "gcc-libstdc++-newer-gcc.patch"))
932 (modules '((guix build utils)))
933 (snippet gcc-canadian-cross-objdump-snippet)))
934 (properties
935 `((compiler-cpu-architectures
936 ("aarch64" ,@%gcc-11-aarch64-micro-architectures)
937 ("armhf" ,@%gcc-11-armhf-micro-architectures)
938 ("i686" ,@%gcc-11-x86_64-micro-architectures)
939 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
940 ("x86_64" ,@%gcc-11-x86_64-micro-architectures))
941 ,@(package-properties gcc-8)))))
942
943(define-public gcc-12
944 (package
945 (inherit gcc-11)
946 (version "12.5.0")
947 (source (origin
948 (method url-fetch)
949 (uri (string-append "mirror://gnu/gcc/gcc-"
950 version "/gcc-" version ".tar.xz"))
951 (sha256
952 (base32
953 "1cv282mipca0s9f64c3vza7a1hd4q54lvcdmqmk5wq841wykgkbi"))
954 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
955 "gcc-5.0-libvtv-runpath.patch"
956 "gcc-12-libsanitizer-no-crypt.patch"
957 "gcc-11-libstdc++-hurd-libpthread.patch"
958 "gcc-libstdc++-newer-gcc.patch"))
959 (modules '((guix build utils)))
960 (snippet gcc-canadian-cross-objdump-snippet)))
961 (properties
962 `((compiler-cpu-architectures
963 ("aarch64" ,@%gcc-12-aarch64-micro-architectures)
964 ("armhf" ,@%gcc-12-armhf-micro-architectures)
965 ("i686" ,@%gcc-12-x86_64-micro-architectures)
966 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
967 ("x86_64" ,@%gcc-12-x86_64-micro-architectures))
968 ,@(package-properties gcc-11)))))
969
970(define-public gcc-13
971 (package
972 (inherit gcc-11)
973 (version "13.3.0")
974 (source (origin
975 (method url-fetch)
976 (uri (string-append "mirror://gnu/gcc/gcc-"
977 version "/gcc-" version ".tar.xz"))
978 (sha256
979 (base32
980 "10y0l1hx1haz4cj4d4g9f2ci5h7z9555i52f90zs2hwm3iifji88"))
981 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
982 "gcc-5.0-libvtv-runpath.patch"
983 "gcc-13-libsanitizer-no-crypt.patch"
984 "gcc-libstdc++-newer-gcc.patch"))
985 (modules '((guix build utils)))
986 (snippet gcc-canadian-cross-objdump-snippet)))
987 (arguments
988 (substitute-keyword-arguments arguments
989 ((#:phases phases #~%standard-phases)
990 (if (target-hurd?)
991 #~(modify-phases #$phases
992 (delete 'patch-hurd-libpthread))
993 phases))))
994 (properties
995 `((compiler-cpu-architectures
996 ("aarch64" ,@%gcc-13-aarch64-micro-architectures)
997 ("armhf" ,@%gcc-13-armhf-micro-architectures)
998 ("i686" ,@%gcc-13-x86_64-micro-architectures)
999 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
1000 ("x86_64" ,@%gcc-13-x86_64-micro-architectures))
1001 ,@(package-properties gcc-11)))))
1002
1003(define-public gcc-14
1004 (package
1005 (inherit gcc-13)
1006 (version "14.3.0")
1007 (source (origin
1008 (method url-fetch)
1009 (uri (string-append "mirror://gnu/gcc/gcc-"
1010 version "/gcc-" version ".tar.xz"))
1011 (sha256
1012 (base32
1013 "0fna78ly417g69fdm4i5f3ms96g8xzzjza8gwp41lqr5fqlpgp70"))
1014 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
1015 "gcc-5.0-libvtv-runpath.patch"))
1016 (modules '((guix build utils)))
1017 (snippet gcc-canadian-cross-objdump-snippet)))
1018 (arguments (substitute-keyword-arguments arguments
1019 ((#:phases phases #~%standard-phases)
1020 #~(modify-phases #$phases
1021 (add-before 'configure 'pre-x86-configure
1022 (lambda _
1023 (substitute* '("gcc/config/i386/t-linux64"
1024 "gcc/config/i386/t-gnu64")
1025 (("\\.\\./lib64") "../lib"))))))))
1026 (properties
1027 `((compiler-cpu-architectures
1028 ("aarch64" ,@%gcc-14-aarch64-micro-architectures)
1029 ("armhf" ,@%gcc-13-armhf-micro-architectures)
1030 ("i686" ,@%gcc-14-x86_64-micro-architectures)
1031 ("powerpc64le" ,@%gcc-14-ppc64le-micro-architectures)
1032 ("x86_64" ,@%gcc-14-x86_64-micro-architectures))
1033 ,@(package-properties gcc-11)))))
1034
1035(define-public gcc-15
1036 (package
1037 (inherit gcc-14)
1038 (version "15.2.0")
1039 (source (origin
1040 (method url-fetch)
1041 (uri (string-append "mirror://gnu/gcc/gcc-"
1042 version "/gcc-" version ".tar.xz"))
1043 (sha256
1044 (base32
1045 "0knj4ph6y7r7yhnp1v4339af7mki5nkh7ni9b948433bhabdk3s3"))
1046 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
1047 "gcc-5.0-libvtv-runpath.patch"
1048 "gcc-hurd-split-stack.patch"))
1049 (modules '((guix build utils)))
1050 (snippet gcc-canadian-cross-objdump-snippet)))
1051 (arguments
1052 (substitute-keyword-arguments arguments
1053 ((#:phases phases #~%standard-phases)
1054 #~(modify-phases #$phases
1055 (add-after 'install 'adjust-modules-file
1056 ;; Avoid cycle dependencies
1057 (lambda* (#:key outputs #:allow-other-keys)
1058 (let ((lib (assoc-ref outputs "lib"))
1059 (out (assoc-ref outputs "out")))
1060 (when lib
1061 (let* ((target
1062 ;; Are we building a cross toolchain?
1063 #$(%current-target-system))
1064 (modfile
1065 (string-append
1066 lib
1067 (if target
1068 (string-append "/" target)
1069 "")
1070 "/lib/libstdc++.modules.json"))
1071 (origin (string-append out "/include/c++/bits"))
1072 (moddir (string-append lib "/include/c++/bits")))
1073 ;; no libstdc++.modules.json file in gcc-cross-sans-libc
1074 (when (file-exists? modfile)
1075 (for-each (lambda (file) (install-file file moddir))
1076 (find-files origin "\\.cc$"))
1077 (substitute* modfile
1078 ;; Relative file to out output
1079 (("\\.\\./\\.\\./.*/include")
1080 (string-append lib "/include")))))))))))))
1081 (properties
1082 `((compiler-cpu-architectures
1083 ("aarch64" ,@%gcc-15-aarch64-micro-architectures)
1084 ("armhf" ,@%gcc-13-armhf-micro-architectures)
1085 ("i686" ,@%gcc-15-x86_64-micro-architectures)
1086 ("powerpc64le" ,@%gcc-14-ppc64le-micro-architectures)
1087 ("x86_64" ,@%gcc-15-x86_64-micro-architectures))
1088 ,@(package-properties gcc-11)))))
1089
1090(define-public gcc-16
1091 (package
1092 (inherit gcc-15)
1093 (version "16.2.0")
1094 (source (origin
1095 (method url-fetch)
1096 (uri (string-append "mirror://gnu/gcc/gcc-"
1097 version "/gcc-" version ".tar.xz"))
1098 (sha256
1099 (base32
1100 "0gjw120wr4l1gvn2gz4x0x2w1zbzyc00da8sfdq34wvzb4lqwwz6"))
1101 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
1102 "gcc-5.0-libvtv-runpath.patch"))
1103 (modules '((guix build utils)))
1104 (snippet gcc-canadian-cross-objdump-snippet)))
1105 ;; XXX: The libstdc++-headers package needs to be removed in order
1106 ;; for gcc 16 to build successfully.
1107 (inputs (modify-inputs inputs
1108 (delete "libstdc++")))
1109 (properties
1110 `((compiler-cpu-architectures
1111 ("aarch64" ,@%gcc-15-aarch64-micro-architectures)
1112 ("armhf" ,@%gcc-13-armhf-micro-architectures)
1113 ("i686" ,@%gcc-15-x86_64-micro-architectures)
1114 ("powerpc64le" ,@%gcc-14-ppc64le-micro-architectures)
1115 ("x86_64" ,@%gcc-15-x86_64-micro-architectures))
1116 ,@(package-properties gcc-11)))))
1117
1118
1119;; Note: When changing the default gcc version, update
1120;; the gcc-toolchain-* definitions.
1121(define-public gcc gcc-14)
1122
1123
1124;;;
1125;;; Historical version.
1126;;;
1127
1128(define-public gcc-2.95
1129 ;; Note: 'gcc-core-mesboot0' in commencement.scm provides 2.95 as well, but
1130 ;; with additional tricks to support compilation with TinyCC and Mes-libc.
1131 (package
1132 (inherit gcc)
1133 (version "2.95.3")
1134 (source (origin
1135 (method url-fetch)
1136 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
1137 version ".tar.gz"))
1138 (sha256
1139 (base32
1140 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))
1141 (modules '((guix build utils)))
1142 (snippet
1143 '(begin
1144 ;; Do not build the bundled Texinfo.
1145 (delete-file-recursively "texinfo")
1146 (substitute* "configure"
1147 (("host_tools=(.*)texinfo" _ before)
1148 (string-append "host_tools=" before)))
1149 ;; Fix building on arm* with gcc-4+
1150 (substitute* "gcc/config/arm/arm.c"
1151 (("arm_prog_mode") "arm_prgmode"))))))
1152 (supported-systems (fold delete %supported-systems
1153 '("powerpc64le-linux" "riscv64-linux")))
1154 (native-inputs (list gcc-4.8 texinfo dejagnu))
1155 (inputs '())
1156 (propagated-inputs '())
1157 (outputs '("out"))
1158 (arguments
1159 (let ((matching-system
1160 (match (%current-system)
1161 ;; This package predates our 64-bit architectures.
1162 ;; Force a 32-bit build targeting a similar architecture.
1163 ("aarch64-linux"
1164 "armhf-linux")
1165 ("x86_64-linux"
1166 "i686-linux")
1167 (_
1168 (%current-system)))))
1169 (list #:system matching-system
1170 #:configure-flags #~'("--disable-werror")
1171
1172 #:phases
1173 #~(modify-phases %standard-phases
1174 (add-before 'configure 'set-dynamic-linker-file-name
1175 (lambda* (#:key inputs #:allow-other-keys)
1176 ;; Tell GCC what the real loader file name is.
1177 (substitute* '("gcc/config/alpha/linux-elf.h"
1178 "gcc/config/m68k/linux.h"
1179 "gcc/config/mips/linux.h"
1180 "gcc/config/rs6000/linux.h")
1181 (("/lib/ld\\.so\\.1")
1182 (search-input-file
1183 inputs #$(glibc-dynamic-linker matching-system))))
1184 (substitute* "gcc/config/i386/gnu.h"
1185 (("/lib/ld\\.so")
1186 (search-input-file
1187 inputs #$(glibc-dynamic-linker matching-system))))
1188 (substitute* '("gcc/config/alpha/linux-elf.h"
1189 "gcc/config/arm/linux-elf.h"
1190 "gcc/config/i386/linux.h"
1191 "gcc/config/m68k/linux.h"
1192 "gcc/config/sparc/linux.h"
1193 "gcc/config/sparc/linux64.h")
1194 (("/lib(64)?/ld-linux\\.so\\.[12]")
1195 (search-input-file
1196 inputs #$(glibc-dynamic-linker matching-system))))))
1197 (replace 'configure
1198 (lambda* (#:key outputs build configure-flags
1199 #:allow-other-keys)
1200 ;; It's an old 'configure' script so it needs some help.
1201 (setenv "CONFIG_SHELL" (which "sh"))
1202 (apply invoke "./configure"
1203 (string-append "--prefix=" #$output)
1204 (string-append "--build=" build)
1205 (string-append "--host=" build)
1206 configure-flags)))
1207 (add-before 'configure 'remove-bundled-texinfo
1208 (lambda _
1209 ;; Go ahead despite the many warnings.
1210 (substitute* '("Makefile.in" "gcc/Makefile.in")
1211 (("^MAKEINFOFLAGS =.*")
1212 "MAKEINFOFLAGS = --force\n"))))))))
1213 (native-search-paths
1214 ;; This package supports nothing but the C language.
1215 (list $C_INCLUDE_PATH
1216 $LIBRARY_PATH))))
1217
1218
1219(define-public (make-libstdc++ gcc)
1220 "Return a libstdc++ package based on GCC. The primary use case is when
1221using compilers other than GCC."
1222 (package
1223 (inherit gcc)
1224 (name "libstdc++")
1225 (arguments
1226 (list
1227 #:out-of-source? #t
1228 #:modules `((srfi srfi-1)
1229 (srfi srfi-26)
1230 ,@%default-gnu-modules)
1231 #:phases
1232 #~(modify-phases %standard-phases
1233 #$@(if (version>=? (package-version gcc) "11")
1234 #~((add-after 'unpack 'hide-gcc-headers
1235 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1236 (let ((gcc (assoc-ref (or native-inputs inputs)
1237 #$(if (%current-target-system)
1238 "cross-gcc"
1239 "gcc"))))
1240 ;; Fix a regression in GCC 11 where the GCC headers
1241 ;; shadows glibc headers when building libstdc++. An
1242 ;; upstream fix was added in GCC 11.3.0, but it only
1243 ;; hides system include directories, not those on
1244 ;; CPLUS_INCLUDE_PATH. See discussion at
1245 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100017>
1246 ;; and the similar adjustment in GCC-FINAL.
1247 (substitute* "libstdc++-v3/src/c++17/Makefile.in"
1248 (("AM_CXXFLAGS = ")
1249 (string-append #$(if (%current-target-system)
1250 "CROSS_CPLUS_INCLUDE_PATH = "
1251 "CPLUS_INCLUDE_PATH = ")
1252 (string-join
1253 (remove (cut string-prefix? gcc <>)
1254 (string-split
1255 (getenv
1256 #$(if (%current-target-system)
1257 "CROSS_CPLUS_INCLUDE_PATH"
1258 "CPLUS_INCLUDE_PATH"))
1259 #\:))
1260 ":")
1261 "\nAM_CXXFLAGS = ")))))))
1262 '())
1263 #$@(let ((version (package-version gcc)))
1264 (if (and (target-ppc64le?)
1265 (version>=? version "11")
1266 (not (version>=? version "12")))
1267 ;; TODO: Drop the 'else' branch below on next rebuild
1268 ;; cycle.
1269 (if (%current-target-system)
1270 #~((add-after 'unpack 'patch-powerpc ;correct
1271 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1272 (invoke "patch" "--force" "-p1" "-i"
1273 (assoc-ref (or native-inputs inputs)
1274 "powerpc64le-patch")))))
1275 #~((add-after 'unpack 'patch-powerpc ;wrong
1276 (lambda* (#:key inputs #:allow-other-keys)
1277 (invoke "patch" "--force" "-p1" "-i"
1278 (assoc-ref inputs "powerpc64le-patch"))))))
1279 '()))
1280 ;; Force rs6000 (i.e., powerpc) libdir to be /lib and not /lib64.
1281 (add-after 'unpack 'fix-rs6000-libdir
1282 (lambda _
1283 (when (file-exists? "gcc/config/rs6000")
1284 (substitute* (find-files "gcc/config/rs6000")
1285 (("/lib64") "/lib")))))
1286 (add-before 'configure 'chdir
1287 (lambda _
1288 (chdir "libstdc++-v3")))
1289
1290 #$@(if (version>=? (package-version gcc) "13")
1291 #~((add-after 'unpack 'patch-tzdb.cc
1292 (lambda _
1293 (substitute* "libstdc++-v3/src/c++20/tzdb.cc"
1294 (("#if ! defined _GLIBCXX_ZONEINFO_DIR")
1295 "#if 1 // ! defined _GLIBCXX_ZONEINFO_DIR")))))
1296 '()))
1297
1298 #:configure-flags '`("--disable-libstdcxx-pch"
1299 ,(string-append "--with-gxx-include-dir="
1300 (assoc-ref %outputs "out")
1301 "/include"))))
1302 (outputs '("out" "debug"))
1303 (inputs '())
1304 (native-inputs
1305 `(,@(if (and (target-ppc64le?)
1306 (let ((version (package-version gcc)))
1307 (and
1308 (version>=? version "11")
1309 (not (version>=? version "12")))))
1310 `(("powerpc64le-patch" ,(search-patch "gcc-11-libstdc++-powerpc.patch")))
1311 '())))
1312 (propagated-inputs '())
1313 (synopsis "GNU C++ standard library")))
1314
1315(define make-libstdc++-headers
1316 (mlambdaq (gcc) ;memoize to play well with the object cache
1317 ;; XXX: This package is for internal use to work around
1318 ;; <https://bugs.gnu.org/42392> (see above). The main difference compared
1319 ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>
1320 ;; is right under include/c++ and not under
1321 ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).
1322 (let ((libstdc++ (make-libstdc++ gcc)))
1323 (package
1324 (inherit libstdc++)
1325 (name "libstdc++-headers")
1326 (outputs '("out"))
1327 (build-system trivial-build-system)
1328 (arguments
1329 '(#:builder (let* ((out (assoc-ref %outputs "out"))
1330 (libstdc++ (assoc-ref %build-inputs "libstdc++")))
1331 (mkdir out)
1332 (mkdir (string-append out "/include"))
1333 (symlink (string-append libstdc++ "/include")
1334 (string-append out "/include/c++")))))
1335 (inputs `(("libstdc++" ,libstdc++)))
1336 (synopsis "Headers of GNU libstdc++")))))
1337
1338(define (make-libiberty gcc)
1339 "Return a libiberty package based on GCC."
1340 (package
1341 (inherit gcc)
1342 (name "libiberty")
1343 (arguments
1344 `(#:out-of-source? #t
1345 #:make-flags '("CFLAGS=-O2 -g -fPIC")
1346 #:phases
1347 (modify-phases %standard-phases
1348 (add-before 'configure 'chdir
1349 (lambda _
1350 (chdir "libiberty")))
1351 (replace 'install
1352 (lambda* (#:key outputs #:allow-other-keys)
1353 (let* ((out (assoc-ref outputs "out"))
1354 (lib (string-append out "/lib/"))
1355 (include (string-append out "/include/")))
1356 (install-file "libiberty.a" lib)
1357 (install-file "../include/demangle.h" include)
1358 (install-file "../include/libiberty.h" include)))))))
1359 (inputs '())
1360 (outputs '("out"))
1361 (native-inputs '())
1362 (propagated-inputs '())
1363 (properties '())
1364 (synopsis "Collection of subroutines used by various GNU programs")))
1365
1366(define-public libiberty
1367 (make-libiberty gcc))
1368
1369(define* (custom-gcc gcc name languages
1370 #:optional
1371 (search-paths (package-native-search-paths gcc))
1372 #:key (separate-lib-output? #t))
1373 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
1374as the 'native-search-paths' field."
1375 (package (inherit gcc)
1376 (name name)
1377 (outputs (if separate-lib-output?
1378 (package-outputs gcc)
1379 (delete "lib" (package-outputs gcc))))
1380 (native-search-paths search-paths)
1381 (arguments
1382 (substitute-keyword-arguments arguments
1383 ((#:modules modules %default-gnu-modules)
1384 `(,@modules
1385 (srfi srfi-1)
1386 (srfi srfi-26)
1387 (ice-9 regex)))
1388 ((#:configure-flags flags)
1389 #~(cons (string-append "--enable-languages="
1390 #$(string-join languages ","))
1391 (remove (cut string-match "--enable-languages.*" <>)
1392 #$flags)))
1393 ((#:phases phases)
1394 #~(modify-phases #$phases
1395 (add-after 'install 'remove-broken-or-conflicting-files
1396 (lambda* (#:key outputs #:allow-other-keys)
1397 (for-each
1398 delete-file
1399 (find-files (string-append (assoc-ref outputs "out") "/bin")
1400 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|lto)(-.*)?$"))))))))
1401 (properties `((upstream-name . "gcc")
1402 ,@(alist-delete 'hidden? (package-properties gcc))))))
1403
1404(define %generic-search-paths
1405 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
1406 ;; not considered "system headers", which means GCC can raise warnings for
1407 ;; issues in those headers. 'CPATH' is the only one that works for
1408 ;; front-ends not in the C family.
1409 (list (search-path-specification
1410 (variable "CPATH")
1411 (files '("include")))
1412 (search-path-specification
1413 (variable "LIBRARY_PATH")
1414 (files '("lib" "lib64")))))
1415
1416(define-public gfortran-13
1417 (hidden-package
1418 (custom-gcc gcc-13
1419 "gfortran" '("fortran")
1420 %generic-search-paths)))
1421
1422(define-public gfortran
1423 (hidden-package
1424 (custom-gcc gcc
1425 "gfortran" '("fortran")
1426 %generic-search-paths)))
1427
1428(define-public gfortran-9
1429 (hidden-package
1430 (custom-gcc gcc-9
1431 "gfortran" '("fortran")
1432 %generic-search-paths)))
1433
1434(define-public gfortran-7
1435 (hidden-package
1436 (custom-gcc gcc-7
1437 "gfortran" '("fortran")
1438 %generic-search-paths)))
1439
1440(define* (make-gdc gcc #:optional bootstrap-gdc #:key frontend-version)
1441 (define gdc (custom-gcc gcc "gdc" '("d") (list $LIBRARY_PATH)))
1442 (define version (package-version gdc))
1443 (define (since-version? since) (version>=? version since))
1444 (define (until-version? until) (version>? until version))
1445 (package
1446 (inherit gdc)
1447 (arguments
1448 (substitute-keyword-arguments arguments
1449 ((#:modules modules)
1450 `(,@modules
1451 (ice-9 ftw)))
1452 ((#:configure-flags flags)
1453 #~(append
1454 #$flags
1455 (list "--disable-c++tools"
1456 #$@(if (since-version? "11") #~("--disable-libatomic") #~())
1457 "--disable-libcc1"
1458 "--disable-libgomp"
1459 "--disable-libitm"
1460 "--disable-libquadmath"
1461 "--disable-libsanitizer"
1462 "--disable-libssp"
1463 #$@(if (until-version? "15") #~("--disable-libstdcxx") #~())
1464 "--disable-plugin")))
1465 ((#:phases phases)
1466 #~(modify-phases #$phases
1467 (add-after 'strip 'gdc-cleanup-install
1468 (lambda* (#:key outputs #:allow-other-keys)
1469 (define (delete-except-matches prefix patterns)
1470 ;; Remove all files except for those matching any of the
1471 ;; patterns.
1472 (define (should-delete? path statbuf)
1473 (define suffix (substring path (string-length prefix)))
1474 (not (or (zero? (string-length suffix))
1475 (any (cut string-match <> suffix)
1476 patterns))))
1477 (for-each (lambda (path)
1478 (format #t "Deleting ~a\n" path)
1479 (delete-file path))
1480 (find-files prefix should-delete?))
1481 ;; Clean up empty directories.
1482 (define (dir-empty? path statbuf)
1483 (and (eq? (stat:type statbuf) 'directory)
1484 (zero? (length (filter
1485 (lambda (name)
1486 (not (or (string=? name ".")
1487 (string=? name ".."))))
1488 (scandir path))))))
1489 (while #t
1490 (let* ((empty-dirs (find-files prefix dir-empty?
1491 #:stat lstat
1492 #:directories? #t)))
1493 (if (zero? (length empty-dirs))
1494 (break)
1495 (for-each rmdir empty-dirs)))))
1496 ;; Leave out non-GDC binaries, man pages, locale files, and
1497 ;; c++ headers.
1498 (delete-except-matches
1499 (assoc-ref outputs "out")
1500 (list "^/bin/.*gdc$"
1501 "^/libexec/"
1502 "^/share/info/gdc"
1503 "^/share/man/man1/gdc"
1504 "^/share/man/man7/"))
1505 ;; Leave out C/C++ libraries, headers and empty directories.
1506 (delete-except-matches
1507 (assoc-ref outputs "lib")
1508 (list "^/lib/gcc/.*/include/d/"
1509 "^/lib/gcc/.*/.*\\.[ao]$"
1510 "^/lib/libgcc_s.*"
1511 "^/lib/libgdruntime.*"
1512 "^/lib/libgphobos.*"))
1513 ;; Repeat for the debug files.
1514 (delete-except-matches
1515 (assoc-ref outputs "debug")
1516 (list "^/lib/debug/.*/bin/.*gdc\\.debug$"
1517 "^/lib/debug/.*/lib/libgcc_s"
1518 "^/lib/debug/.*/lib/libgdruntime"
1519 "^/lib/debug/.*/lib/libgphobos"))))))))
1520 (inputs
1521 (modify-inputs inputs
1522 ;; This makes flags like -static-libstdc++ work. Required for using this
1523 ;; compiler as a bootstrap compiler for GDC 12+.
1524 ;; Additionally, this allows us to support linking with GCC libraries,
1525 ;; without building or storing them ourselves.
1526 (append (list gcc "lib"))))
1527 (native-inputs
1528 (let ((orig native-inputs))
1529 (if bootstrap-gdc
1530 (modify-inputs orig
1531 ;; Since GCC 12, GDC is self-hosted, requiring a version of itself
1532 ;; to build.
1533 (append bootstrap-gdc))
1534 orig)))
1535 (synopsis "GNU D Compiler")
1536 (description
1537 (string-append
1538 "GDC is the D frontend for the @acronym{GNU Compiler Collection,GCC}. It
1539also includes the druntime and phobos libraries."
1540 (if frontend-version
1541 (format #f "~%~%This compiler is based on the DMD frontend version ~a."
1542 frontend-version)
1543 "")))
1544 (home-page "https://www.gdcproject.org/")))
1545
1546(define-public gdc-9
1547 (make-gdc gcc-9 #:frontend-version "2.076.2"))
1548
1549(define-public gdc-10
1550 (make-gdc gcc-10 #:frontend-version "2.076.2"))
1551
1552(define-public gdc-11
1553 (make-gdc gcc-11 #:frontend-version "2.076.2"))
1554
1555(define-public gdc-12
1556 (make-gdc gcc-12 gdc-11 #:frontend-version "2.100.2"))
1557
1558(define-public gdc-13
1559 (make-gdc gcc-13 gdc-11 #:frontend-version "2.103.1"))
1560
1561(define-public gdc-14
1562 (make-gdc gcc-14 gdc-11 #:frontend-version "2.108.1"))
1563
1564(define-public gdc-15
1565 (make-gdc gcc-15 gdc-11 #:frontend-version "2.111.0"))
1566
1567(define-public gdc gdc-14)
1568
1569(define* (make-gdmd gdc)
1570 (let ((gdc-version (package-version gdc))
1571 (gdmd-version "0.26.0"))
1572 (package
1573 (name "gdmd")
1574 (version (string-append gdc-version "-" gdmd-version))
1575 (source (origin
1576 (method git-fetch)
1577 (uri (git-reference
1578 (url "https://github.com/D-Programming-GDC/gdmd")
1579 (commit (string-append "script-" gdmd-version))))
1580 (file-name (git-file-name name gdmd-version))
1581 (sha256
1582 (base32
1583 "0i9warhlwyspjs3rpvs2989820909lgzjnsflpd9mp2flq7isjh0"))))
1584 (build-system copy-build-system)
1585 (arguments
1586 (list
1587 #:install-plan
1588 #~'(("dmd-script" "bin/gdmd")
1589 ("dmd-script.1" "share/man/man1/gdmd.1"))
1590 #:phases
1591 #~(modify-phases %standard-phases
1592 (add-after 'unpack 'adjust-gdc-location
1593 (lambda* (#:key inputs #:allow-other-keys)
1594 (substitute* "dmd-script"
1595 (("my \\$gdc_dir.*")
1596 (string-append "my $gdc_dir = \""
1597 (dirname
1598 (search-input-file inputs "/bin/gdc"))
1599 "\";\n"))))))))
1600 (inputs (list gdc perl))
1601 (synopsis "DMD-like wrapper for GDC")
1602 (description "This package provides a DMD-like wrapper for the
1603@acronym{GNU D Compiler,GDC}.")
1604 (license gpl3+)
1605 (home-page "https://github.com/D-Programming-GDC/gdmd"))))
1606
1607(define-public gdmd-9
1608 (make-gdmd gdc-9))
1609
1610(define-public gdmd-10
1611 (make-gdmd gdc-10))
1612
1613(define-public gdmd-11
1614 (make-gdmd gdc-11))
1615
1616(define-public gdmd-12
1617 (make-gdmd gdc-12))
1618
1619(define-public gdmd-13
1620 (make-gdmd gdc-13))
1621
1622(define-public gdmd-14
1623 (make-gdmd gdc-14))
1624
1625(define-public gdmd-15
1626 (make-gdmd gdc-15))
1627
1628(define-public gdmd gdmd-14)
1629
1630(define-public gm2
1631 (hidden-package
1632 (let ((base (custom-gcc gcc-14
1633 "gm2" '("m2")
1634 %generic-search-paths)))
1635 (package
1636 (inherit base)
1637 (native-inputs
1638 (modify-inputs native-inputs
1639 (prepend flex)))))))
1640
1641(define-public (make-libgccjit gcc)
1642 (package
1643 (inherit gcc)
1644 (name "libgccjit")
1645 (outputs (delete "lib" (package-outputs gcc)))
1646 (properties (alist-delete 'hidden? (package-properties gcc)))
1647 (arguments
1648 (substitute-keyword-arguments arguments
1649 ((#:modules _ '())
1650 '((guix build gnu-build-system)
1651 (guix build utils)
1652 (ice-9 regex)
1653 (srfi srfi-1)
1654 (srfi srfi-26)))
1655 ((#:configure-flags flags)
1656 #~(cons* "--disable-bootstrap"
1657 "--disable-libatomic"
1658 "--disable-libgomp"
1659 "--disable-libquadmath"
1660 "--disable-libssp"
1661 "--enable-host-shared"
1662 "--enable-checking=release"
1663 "--enable-languages=jit"
1664 (remove (cut string-match "--enable-languages.*" <>)
1665 #$flags)))
1666 ((#:phases phases)
1667 #~(modify-phases #$phases
1668 (add-after 'install 'remove-broken-or-conflicting-files
1669 (lambda* (#:key outputs #:allow-other-keys)
1670 (for-each delete-file
1671 (find-files
1672 (string-append (assoc-ref outputs "out") "/bin")
1673 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))))))))
1674 (inputs (modify-inputs inputs
1675 (delete "libstdc++")))
1676 (native-inputs (modify-inputs native-inputs
1677 (prepend gcc)))
1678 (synopsis "GCC library generating machine code on-the-fly at runtime")
1679 (description
1680 "This package is part of the GNU Compiler Collection and provides an
1681embeddable library for generating machine code on-the-fly at runtime. This
1682shared library can then be dynamically-linked into bytecode interpreters and
1683other such programs that want to generate machine code on-the-fly at run-time.
1684It can also be used for ahead-of-time code generation for building standalone
1685compilers. The just-in-time (jit) part of the name is now something of a
1686misnomer.")))
1687
1688(define-public libgccjit-9 (make-libgccjit gcc-9))
1689(define-public libgccjit-10 (make-libgccjit gcc-10))
1690(define-public libgccjit-11 (make-libgccjit gcc-11))
1691(define-public libgccjit-12 (make-libgccjit gcc-12))
1692(define-public libgccjit-14 (make-libgccjit gcc-14))
1693(define-public libgccjit-15 (make-libgccjit gcc-15))
1694(define-public libgccjit-16 (make-libgccjit gcc-16))
1695
1696;; This must match the 'gcc' variable, but it must also be 'eq?' to one of the
1697;; libgccjit-* packages above.
1698(define-public libgccjit libgccjit-14)
1699
1700(define (make-gccgo gcc)
1701 "Return a gccgo package based on GCC."
1702 (let ((gccgo (custom-gcc gcc "gccgo" '("go") %generic-search-paths)))
1703 (package
1704 (inherit gccgo)
1705 (synopsis "Go frontend to GCC")
1706 (description
1707 "This package is part of the GNU Compiler Collection and
1708provides the GNU compiler for the Go programming language.")
1709 (arguments
1710 (substitute-keyword-arguments arguments
1711 ((#:phases phases)
1712 #~(modify-phases #$phases
1713 #$@(if (and (version>=? (package-version gccgo) "12.0")
1714 ;; This somehow breaks gccgo@12 on riscv64-linux.
1715 (not (and (target-riscv64?)
1716 (string=? (version-prefix
1717 (package-version gccgo) 1)
1718 "12"))))
1719 #~((add-after 'unpack 'adjust-libgo-dependencies
1720 (lambda _
1721 (substitute* "Makefile.in"
1722 ;; libgo.la depends on libbacktrace.la but the
1723 ;; current dependency rules don't have libbacktrace
1724 ;; building early enough for libgo. When built
1725 ;; with more than 1 core this issue doesn't appear.
1726 ;; see commit 5fee5ec362f7a243f459e6378fd49dfc89dc9fb5.
1727 (("all-target-libgo: maybe-all-target-libffi")
1728 (string-append
1729 "all-target-libgo: maybe-all-target-libbacktrace\n"
1730 "all-target-libgo: maybe-all-target-libffi\n"
1731 "all-target-libgo: maybe-all-target-libatomic"))))))
1732 #~())
1733 (add-after 'install 'wrap-go-with-tool-path
1734 (lambda* (#:key outputs #:allow-other-keys)
1735 (let* ((out (assoc-ref outputs "out"))
1736 (exedir (string-append out "/libexec/gcc"))
1737 (tooldir (dirname (car (find-files exedir "^cgo$")))))
1738 (wrap-program (string-append out "/bin/go")
1739 `("GCCGOTOOLDIR" =
1740 (,(string-append "${GCCGOTOOLDIR:-" tooldir "}")))
1741 `("GOROOT" =
1742 (,(string-append "${GOROOT:-" out "}")))))))
1743 (add-before 'configure 'fix-gotools-runpath
1744 (lambda _
1745 (substitute* "gotools/Makefile.in"
1746 (("AM_LDFLAGS =" all)
1747 (string-append all " -Wl,-rpath=$(libdir) ")))))
1748 (add-before 'configure 'remove-tool-reference-from-libgo
1749 (lambda _
1750 (substitute* "libgo/Makefile.in"
1751 (("(GccgoToolDir = \\\")[^\\\"]+" _ start)
1752 (string-append start "/nonexistent"))
1753 #$@(if (version>=? (package-version gccgo) "12.0")
1754 '((("(defaultGOROOT = `)[^`]+" _ start)
1755 (string-append start "/nonexistent")))
1756 '((("(DefaultGoroot = \\\")[^\\\"]+" _ start)
1757 (string-append start "/nonexistent"))))
1758 (("(defaultGOROOTValue.*?return `)[^`]+" _ start)
1759 (string-append start "/nonexistent"))))))))))))
1760
1761;; Provides go-1.18
1762(define-public gccgo-12
1763 (make-gccgo gcc-12))
1764
1765;; Provides go-1.18
1766(define-public gccgo-13
1767 (make-gccgo gcc-13))
1768
1769;; Provides go-1.18
1770(define-public gccgo-14
1771 (make-gccgo gcc-14))
1772
1773;; Provides go-1.18
1774(define-public gccgo-15
1775 (make-gccgo gcc-15))
1776
1777;; Provides go-1.18
1778(define-public gccgo-16
1779 (make-gccgo gcc-16))
1780
1781(define-public isl
1782 (package
1783 (name "isl")
1784 (version "0.24")
1785 (source (origin
1786 (method url-fetch)
1787 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1788 version ".tar.xz")
1789 (string-append %gcc-infrastructure
1790 "isl-" version ".tar.xz")))
1791 (sha256
1792 (base32
1793 "1bgbk6n93qqn7w8v21kxf4x6dc3z0ypqrzvgfd46nhagak60ac84"))))
1794 (build-system gnu-build-system)
1795 (outputs '("out" "static"))
1796 (arguments
1797 `(#:phases (modify-phases %standard-phases
1798 (add-after 'install 'move-static-library
1799 (lambda* (#:key outputs #:allow-other-keys)
1800 (let* ((out (assoc-ref outputs "out"))
1801 (static (assoc-ref outputs "static"))
1802 (source (string-append out "/lib/libisl.a"))
1803 (target (string-append static "/lib/libisl.a")))
1804 (mkdir-p (dirname target))
1805 (link source target)
1806 (delete-file source)
1807
1808 ;; Remove reference to libisl.a from the .la file so
1809 ;; libtool looks for it in the usual locations.
1810 (substitute* (string-append out "/lib/libisl.la")
1811 (("^old_library=.*")
1812 "old_library=''\n")))))
1813 ,@(if (target-loongarch64?)
1814 `((add-after 'unpack 'update-config-scripts
1815 (lambda* (#:key inputs native-inputs #:allow-other-keys)
1816 ;; Replace outdated config.guess and config.sub.
1817 (for-each (lambda (file)
1818 (install-file
1819 (search-input-file
1820 (or native-inputs inputs)
1821 (string-append "/bin/" file)) "."))
1822 '("config.guess" "config.sub")))))
1823 '()))))
1824 (native-inputs (if (target-loongarch64?)
1825 (list config)
1826 '()))
1827 (inputs (list gmp))
1828 (home-page "https://libisl.sourceforge.io/") ;https://repo.or.cz/w/isl.git
1829 (properties `((release-monitoring-url . ,home-page)))
1830 (synopsis
1831 "Manipulating sets and relations of integer points \
1832bounded by linear constraints")
1833 (description
1834 "isl is a library for manipulating sets and relations of integer points
1835bounded by linear constraints. Supported operations on sets include
1836intersection, union, set difference, emptiness check, convex hull, (integer)
1837affine hull, integer projection, computing the lexicographic minimum using
1838parametric integer programming, coalescing and parametric vertex
1839enumeration. It also includes an ILP solver based on generalized basis
1840reduction, transitive closures on maps (which may encode infinite graphs),
1841dependence analysis and bounds on piecewise step-polynomials.")
1842 (license lgpl2.1+)))
1843
1844(define-public isl-0.18
1845 (package
1846 (inherit isl)
1847 (version "0.18")
1848 (source (origin
1849 (method url-fetch)
1850 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1851 version ".tar.bz2")
1852 (string-append %gcc-infrastructure
1853 "isl-" version ".tar.bz2")))
1854 (sha256
1855 (base32
1856 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
1857
1858(define-public isl-0.11
1859 (package
1860 (inherit isl)
1861 (name "isl")
1862 (version "0.11.1")
1863 (source (origin
1864 (method url-fetch)
1865 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1866 version ".tar.bz2")
1867 (string-append %gcc-infrastructure
1868 "isl-" version ".tar.bz2")))
1869 (sha256
1870 (base32
1871 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
1872 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
1873
1874(define-public cloog
1875 (package
1876 (name "cloog")
1877 (version "0.18.0")
1878 (source
1879 (origin
1880 (method url-fetch)
1881 (uri (list (string-append
1882 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
1883 version
1884 ".tar.gz")
1885 (string-append %gcc-infrastructure
1886 name "-" version ".tar.gz")))
1887 (sha256
1888 (base32
1889 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
1890 (file-name (string-append name "-" version ".tar.gz"))))
1891 (build-system gnu-build-system)
1892 (inputs (list gmp isl-0.11))
1893 (arguments '(#:configure-flags '("--with-isl=system")))
1894 (home-page "http://www.cloog.org/")
1895 (synopsis "Library to generate code for scanning Z-polyhedra")
1896 (description
1897 "CLooG is a free software library to generate code for scanning
1898Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
1899reaches each integral point of one or more parameterized polyhedra.
1900CLooG has been originally written to solve the code generation problem
1901for optimizing compilers based on the polytope model. Nevertheless it
1902is used now in various area e.g., to build control automata for
1903high-level synthesis or to find the best polynomial approximation of a
1904function. CLooG may help in any situation where scanning polyhedra
1905matters. While the user has full control on generated code quality,
1906CLooG is designed to avoid control overhead and to produce a very
1907effective code.")
1908 (license gpl2+)))
1909
1910(define-public gnu-c-manual
1911 (package
1912 (name "gnu-c-manual")
1913 (version "0.2.5")
1914 (source (origin
1915 (method url-fetch)
1916 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1917 version ".tar.gz"))
1918 (sha256
1919 (base32
1920 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
1921 (build-system gnu-build-system)
1922 (native-inputs (list texinfo))
1923 (arguments
1924 '(#:phases (modify-phases %standard-phases
1925 (delete 'configure)
1926 (delete 'check)
1927 (replace 'build
1928 (lambda _
1929 (invoke "make"
1930 "gnu-c-manual.info"
1931 "gnu-c-manual.html")))
1932 (replace 'install
1933 (lambda* (#:key outputs #:allow-other-keys)
1934 (let* ((out (assoc-ref outputs "out"))
1935 (info (string-append out "/share/info"))
1936 (html (string-append
1937 out "/share/doc/gnu-c-manual")))
1938 (mkdir-p info)
1939 (mkdir-p html)
1940
1941 (for-each (lambda (file)
1942 (copy-file file
1943 (string-append info "/"
1944 file)))
1945 (find-files "." "\\.info(-[0-9])?$"))
1946 (for-each (lambda (file)
1947 (copy-file file
1948 (string-append html "/"
1949 file)))
1950 (find-files "." "\\.html$"))))))))
1951 (synopsis "Reference manual for the C programming language")
1952 (description
1953 "This is a reference manual for the C programming language, as
1954implemented by the GNU C Compiler (gcc). As a reference, it is not intended
1955to be a tutorial of the language. Rather, it outlines all of the constructs
1956of the language. Library functions are not included.")
1957 (home-page "https://www.gnu.org/software/gnu-c-manual/")
1958 (license fdl1.3+)))