projects/guix·blob python-team · refs

2006 lines · 88.3 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 '("sierraforest" "graniterapids" "grandridge" ;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 '("arrowlake-s"
798 "znver5" ;AMD
799 "yongfeng")))
800
801(define %gcc-15-aarch64-micro-architectures
802 (append %gcc-14-aarch64-micro-architectures
803 '("armv9.5-a")))
804
805(define %gcc-15-x86_64-micro-architectures
806 (append
807 (fold delete %gcc-14-x86_64-micro-architectures
808 '("knm" "knl"))
809 '("diamondrapids" ;Intel
810 "shijidadao")))
811
812(define %gcc-16-aarch64-micro-architectures
813 (append %gcc-15-aarch64-micro-architectures
814 '("armv9.6-a")))
815
816(define %gcc-16-riscv64-micro-architectures
817 '("rv64gc" "rva20u64" "rva22u64" "rva23u64" "rva23s64" "rvb23u64"
818 "rvb23s64"))
819
820(define %gcc-16-x86_64-micro-architectures
821 (append %gcc-15-x86_64-micro-architectures
822 '("arrowlake" "novalake"
823 "znver6"
824 "c86-4g-m4" "c86-4g-m6" "c86-4g-m7" "c86-4g-m8")))
825
826(define-public gcc-7
827 (package
828 (inherit gcc-base)
829 (version "7.5.0")
830 (source (origin
831 (method url-fetch)
832 (uri (string-append "mirror://gnu/gcc/gcc-"
833 version "/gcc-" version ".tar.xz"))
834 (sha256
835 (base32
836 "0qg6kqc5l72hpnj4vr6l0p69qav0rh4anlkk3y55540zy3klc6dq"))
837 (patches (search-patches "gcc-strmov-store-file-names.patch"
838 "gcc-7-libsanitizer-mode-size.patch"
839 "gcc-7-libsanitizer-fsconfig-command.patch"
840 "gcc-5.0-libvtv-runpath.patch"
841 "gcc-libstdc++-newer-gcc.patch"))))
842 (native-inputs (list perl ;for manpages
843 texinfo))
844 (inputs
845 `(("isl" ,isl)
846
847 ;; XXX: This gross hack allows us to have libstdc++'s <bits/c++config.h>
848 ;; in the search path, thereby avoiding misconfiguration of libstdc++:
849 ;; <https://bugs.gnu.org/42392>.
850 ("libstdc++" ,(make-libstdc++-headers this-package))
851
852 ,@(package-inputs gcc-base)))
853 (description
854 "GCC is the GNU Compiler Collection. It provides compiler front-ends
855for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
856It also includes runtime support libraries for these languages.")
857 (properties
858 `((compiler-cpu-architectures
859 ("aarch64" ,@%gcc-7.5-aarch64-micro-architectures)
860 ("armhf" ,@%gcc-7.5-armhf-micro-architectures)
861 ("i686" ,@%gcc-7.5-x86_64-micro-architectures)
862 ("x86_64" ,@%gcc-7.5-x86_64-micro-architectures))
863 ,@(package-properties gcc-6)))))
864
865(define-public gcc-8
866 (package
867 (inherit gcc-7)
868 (version "8.5.0")
869 (source (origin
870 (method url-fetch)
871 (uri (string-append "mirror://gnu/gcc/gcc-"
872 version "/gcc-" version ".tar.xz"))
873 (sha256
874 (base32
875 "0l7d4m9jx124xsk6xardchgy2k5j5l2b15q322k31f0va4d8826k"))
876 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
877 "gcc-7-libsanitizer-fsconfig-command.patch"
878 "gcc-5.0-libvtv-runpath.patch"
879 "gcc-8-sort-libtool-find-output.patch"
880 "gcc-libstdc++-newer-gcc.patch"))
881 (modules '((guix build utils)))
882 (snippet gcc-canadian-cross-objdump-snippet)))))
883
884(define-public gcc-9
885 (package
886 (inherit gcc-8)
887 (version "9.5.0")
888 (source (origin
889 (method url-fetch)
890 (uri (string-append "mirror://gnu/gcc/gcc-"
891 version "/gcc-" version ".tar.xz"))
892 (sha256
893 (base32
894 "13ygjmd938m0wmy946pxdhz9i1wq7z4w10l6pvidak0xxxj9yxi7"))
895 (patches (search-patches "gcc-7-libsanitizer-fsconfig-command.patch"
896 "gcc-13.2.0-libstdc++-docbook-xsl-uri.patch"
897 "gcc-13.2.0-libstdc++-info-install-fix.patch"
898 "gcc-9-strmov-store-file-names.patch"
899 "gcc-9-asan-fix-limits-include.patch"
900 "gcc-5.0-libvtv-runpath.patch"
901 "gcc-libstdc++-newer-gcc.patch"))
902 (modules '((guix build utils)))
903 (snippet gcc-canadian-cross-objdump-snippet)))))
904
905(define-public gcc-10
906 (package
907 (inherit gcc-8)
908 (version "10.5.0")
909 (source (origin
910 (method url-fetch)
911 (uri (string-append "mirror://gnu/gcc/gcc-"
912 version "/gcc-" version ".tar.xz"))
913 (sha256
914 (base32
915 "1h87lcfaga0ydsf4pkhwlnjr8mky5ix8npbv6iy3jvzlzm1ra415"))
916 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
917 "gcc-5.0-libvtv-runpath.patch"
918 "gcc-10-libsanitizer-no-crypt.patch"
919 "gcc-libstdc++-newer-gcc.patch"))
920 (modules '((guix build utils)))
921 (snippet gcc-canadian-cross-objdump-snippet)))
922 (properties
923 `((compiler-cpu-architectures
924 ("aarch64" ,@%gcc-10-aarch64-micro-architectures)
925 ("armhf" ,@%gcc-10-armhf-micro-architectures)
926 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
927 ("i686" ,@%gcc-10-x86_64-micro-architectures)
928 ("x86_64" ,@%gcc-10-x86_64-micro-architectures))
929 ,@(package-properties gcc-8)))))
930
931(define-public gcc-11
932 (package
933 (inherit gcc-8)
934 (version "11.5.0")
935 (source (origin
936 (method url-fetch)
937 (uri (string-append "mirror://gnu/gcc/gcc-"
938 version "/gcc-" version ".tar.xz"))
939 (sha256
940 (base32
941 "0y1l6q4iy94nr30r3189fbb82ljbdqkq87y0y23wyifmx9l1iqm6"))
942 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
943 "gcc-5.0-libvtv-runpath.patch"
944 "gcc-10-libsanitizer-no-crypt.patch"
945 "gcc-11-libstdc++-hurd-libpthread.patch"
946 "gcc-libstdc++-newer-gcc.patch"))
947 (modules '((guix build utils)))
948 (snippet gcc-canadian-cross-objdump-snippet)))
949 (arguments
950 (substitute-keyword-arguments arguments
951 ((#:phases phases #~%standard-phases)
952 (if (and (target-hurd64?) (version-prefix? "11" (package-version this-package)))
953 #~(modify-phases #$phases
954 (add-after 'unpack 'apply-x86_64-hurd-patch
955 (lambda _
956 (lambda* (#:key native-inputs inputs #:allow-other-keys)
957 (invoke "patch" "--force" "-p1" "-i"
958 #$(search-patch "gcc-11-x86_64-gnu.patch"))))))
959 phases))))
960 (properties
961 `((compiler-cpu-architectures
962 ("aarch64" ,@%gcc-11-aarch64-micro-architectures)
963 ("armhf" ,@%gcc-11-armhf-micro-architectures)
964 ("i686" ,@%gcc-11-x86_64-micro-architectures)
965 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
966 ("x86_64" ,@%gcc-11-x86_64-micro-architectures))
967 ,@(package-properties gcc-8)))))
968
969(define-public gcc-12
970 (package
971 (inherit gcc-11)
972 (version "12.5.0")
973 (source (origin
974 (method url-fetch)
975 (uri (string-append "mirror://gnu/gcc/gcc-"
976 version "/gcc-" version ".tar.xz"))
977 (sha256
978 (base32
979 "1cv282mipca0s9f64c3vza7a1hd4q54lvcdmqmk5wq841wykgkbi"))
980 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
981 "gcc-5.0-libvtv-runpath.patch"
982 "gcc-12-libsanitizer-no-crypt.patch"
983 "gcc-11-libstdc++-hurd-libpthread.patch"
984 "gcc-libstdc++-newer-gcc.patch"))
985 (modules '((guix build utils)))
986 (snippet gcc-canadian-cross-objdump-snippet)))
987 (properties
988 `((compiler-cpu-architectures
989 ("aarch64" ,@%gcc-12-aarch64-micro-architectures)
990 ("armhf" ,@%gcc-12-armhf-micro-architectures)
991 ("i686" ,@%gcc-12-x86_64-micro-architectures)
992 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
993 ("x86_64" ,@%gcc-12-x86_64-micro-architectures))
994 ,@(package-properties gcc-11)))))
995
996(define-public gcc-13
997 (package
998 (inherit gcc-11)
999 (version "13.3.0")
1000 (source (origin
1001 (method url-fetch)
1002 (uri (string-append "mirror://gnu/gcc/gcc-"
1003 version "/gcc-" version ".tar.xz"))
1004 (sha256
1005 (base32
1006 "10y0l1hx1haz4cj4d4g9f2ci5h7z9555i52f90zs2hwm3iifji88"))
1007 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
1008 "gcc-5.0-libvtv-runpath.patch"
1009 "gcc-13-libsanitizer-no-crypt.patch"
1010 "gcc-libstdc++-newer-gcc.patch"))
1011 (modules '((guix build utils)))
1012 (snippet gcc-canadian-cross-objdump-snippet)))
1013 (arguments
1014 (substitute-keyword-arguments arguments
1015 ((#:phases phases #~%standard-phases)
1016 (if (target-hurd?)
1017 #~(modify-phases #$phases
1018 (delete 'patch-hurd-libpthread))
1019 phases))))
1020 (properties
1021 `((compiler-cpu-architectures
1022 ("aarch64" ,@%gcc-13-aarch64-micro-architectures)
1023 ("armhf" ,@%gcc-13-armhf-micro-architectures)
1024 ("i686" ,@%gcc-13-x86_64-micro-architectures)
1025 ("powerpc64le" ,@%gcc-10-ppc64le-micro-architectures)
1026 ("x86_64" ,@%gcc-13-x86_64-micro-architectures))
1027 ,@(package-properties gcc-11)))))
1028
1029(define-public gcc-14
1030 (package
1031 (inherit gcc-13)
1032 (version "14.3.0")
1033 (source (origin
1034 (method url-fetch)
1035 (uri (string-append "mirror://gnu/gcc/gcc-"
1036 version "/gcc-" version ".tar.xz"))
1037 (sha256
1038 (base32
1039 "0fna78ly417g69fdm4i5f3ms96g8xzzjza8gwp41lqr5fqlpgp70"))
1040 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
1041 "gcc-5.0-libvtv-runpath.patch"))
1042 (modules '((guix build utils)))
1043 (snippet gcc-canadian-cross-objdump-snippet)))
1044 (arguments (substitute-keyword-arguments arguments
1045 ((#:phases phases #~%standard-phases)
1046 #~(modify-phases #$phases
1047 (add-before 'configure 'pre-x86-configure
1048 (lambda _
1049 (substitute* '("gcc/config/i386/t-linux64"
1050 "gcc/config/i386/t-gnu64")
1051 (("\\.\\./lib64") "../lib"))))))))
1052 (properties
1053 `((compiler-cpu-architectures
1054 ("aarch64" ,@%gcc-14-aarch64-micro-architectures)
1055 ("armhf" ,@%gcc-13-armhf-micro-architectures)
1056 ("i686" ,@%gcc-14-x86_64-micro-architectures)
1057 ("powerpc64le" ,@%gcc-14-ppc64le-micro-architectures)
1058 ("x86_64" ,@%gcc-14-x86_64-micro-architectures))
1059 ,@(package-properties gcc-11)))))
1060
1061(define-public gcc-15
1062 (package
1063 (inherit gcc-14)
1064 (version "15.2.0")
1065 (source (origin
1066 (method url-fetch)
1067 (uri (string-append "mirror://gnu/gcc/gcc-"
1068 version "/gcc-" version ".tar.xz"))
1069 (sha256
1070 (base32
1071 "0knj4ph6y7r7yhnp1v4339af7mki5nkh7ni9b948433bhabdk3s3"))
1072 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
1073 "gcc-5.0-libvtv-runpath.patch"
1074 "gcc-hurd-split-stack.patch"))
1075 (modules '((guix build utils)))
1076 (snippet gcc-canadian-cross-objdump-snippet)))
1077 (arguments
1078 (substitute-keyword-arguments arguments
1079 ((#:phases phases #~%standard-phases)
1080 #~(modify-phases #$phases
1081 (add-after 'install 'adjust-modules-file
1082 ;; Avoid cycle dependencies
1083 (lambda* (#:key outputs #:allow-other-keys)
1084 (let ((lib (assoc-ref outputs "lib"))
1085 (out (assoc-ref outputs "out")))
1086 (when lib
1087 (let* ((target
1088 ;; Are we building a cross toolchain?
1089 #$(%current-target-system))
1090 (modfile
1091 (string-append
1092 lib
1093 (if target
1094 (string-append "/" target)
1095 "")
1096 "/lib/libstdc++.modules.json"))
1097 (origin (string-append out "/include/c++/bits"))
1098 (moddir (string-append lib "/include/c++/bits")))
1099 ;; no libstdc++.modules.json file in gcc-cross-sans-libc
1100 (when (file-exists? modfile)
1101 (for-each (lambda (file) (install-file file moddir))
1102 (find-files origin "\\.cc$"))
1103 (substitute* modfile
1104 ;; Relative file to out output
1105 (("\\.\\./\\.\\./.*/include")
1106 (string-append lib "/include")))))))))))))
1107 (properties
1108 `((compiler-cpu-architectures
1109 ("aarch64" ,@%gcc-15-aarch64-micro-architectures)
1110 ("armhf" ,@%gcc-13-armhf-micro-architectures)
1111 ("i686" ,@%gcc-15-x86_64-micro-architectures)
1112 ("powerpc64le" ,@%gcc-14-ppc64le-micro-architectures)
1113 ("x86_64" ,@%gcc-15-x86_64-micro-architectures))
1114 ,@(package-properties gcc-11)))))
1115
1116(define-public gcc-16
1117 (package
1118 (inherit gcc-15)
1119 (version "16.2.0")
1120 (source (origin
1121 (method url-fetch)
1122 (uri (string-append "mirror://gnu/gcc/gcc-"
1123 version "/gcc-" version ".tar.xz"))
1124 (sha256
1125 (base32
1126 "0gjw120wr4l1gvn2gz4x0x2w1zbzyc00da8sfdq34wvzb4lqwwz6"))
1127 (patches (search-patches "gcc-12-strmov-store-file-names.patch"
1128 "gcc-5.0-libvtv-runpath.patch"))
1129 (modules '((guix build utils)))
1130 (snippet gcc-canadian-cross-objdump-snippet)))
1131 ;; XXX: The libstdc++-headers package needs to be removed in order
1132 ;; for gcc 16 to build successfully.
1133 (inputs (modify-inputs inputs
1134 (delete "libstdc++")))
1135 (properties
1136 `((compiler-cpu-architectures
1137 ("aarch64" ,@%gcc-16-aarch64-micro-architectures)
1138 ("armhf" ,@%gcc-13-armhf-micro-architectures)
1139 ("i686" ,@%gcc-16-x86_64-micro-architectures)
1140 ("powerpc64le" ,@%gcc-14-ppc64le-micro-architectures)
1141 ("riscv64" ,@%gcc-16-riscv64-micro-architectures)
1142 ("x86_64" ,@%gcc-16-x86_64-micro-architectures))
1143 ,@(package-properties gcc-11)))))
1144
1145
1146;; Note: When changing the default gcc version, update
1147;; the gcc-toolchain-* definitions.
1148(define-public gcc gcc-14)
1149
1150
1151;;;
1152;;; Historical version.
1153;;;
1154
1155(define-public gcc-2.95
1156 ;; Note: 'gcc-core-mesboot0' in commencement.scm provides 2.95 as well, but
1157 ;; with additional tricks to support compilation with TinyCC and Mes-libc.
1158 (package
1159 (inherit gcc)
1160 (version "2.95.3")
1161 (source (origin
1162 (method url-fetch)
1163 (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
1164 version ".tar.gz"))
1165 (sha256
1166 (base32
1167 "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))
1168 (modules '((guix build utils)))
1169 (snippet
1170 '(begin
1171 ;; Do not build the bundled Texinfo.
1172 (delete-file-recursively "texinfo")
1173 (substitute* "configure"
1174 (("host_tools=(.*)texinfo" _ before)
1175 (string-append "host_tools=" before)))
1176 ;; Fix building on arm* with gcc-4+
1177 (substitute* "gcc/config/arm/arm.c"
1178 (("arm_prog_mode") "arm_prgmode"))))))
1179 (supported-systems (fold delete %supported-systems
1180 '("powerpc64le-linux" "riscv64-linux")))
1181 (native-inputs (list gcc-4.8 texinfo dejagnu))
1182 (inputs '())
1183 (propagated-inputs '())
1184 (outputs '("out"))
1185 (arguments
1186 (let ((matching-system
1187 (match (%current-system)
1188 ;; This package predates our 64-bit architectures.
1189 ;; Force a 32-bit build targeting a similar architecture.
1190 ("aarch64-linux"
1191 "armhf-linux")
1192 ("x86_64-linux"
1193 "i686-linux")
1194 (_
1195 (%current-system)))))
1196 (list #:system matching-system
1197 #:configure-flags #~'("--disable-werror")
1198
1199 #:phases
1200 #~(modify-phases %standard-phases
1201 (add-before 'configure 'set-dynamic-linker-file-name
1202 (lambda* (#:key inputs #:allow-other-keys)
1203 ;; Tell GCC what the real loader file name is.
1204 (substitute* '("gcc/config/alpha/linux-elf.h"
1205 "gcc/config/m68k/linux.h"
1206 "gcc/config/mips/linux.h"
1207 "gcc/config/rs6000/linux.h")
1208 (("/lib/ld\\.so\\.1")
1209 (search-input-file
1210 inputs #$(glibc-dynamic-linker matching-system))))
1211 (substitute* "gcc/config/i386/gnu.h"
1212 (("/lib/ld\\.so")
1213 (search-input-file
1214 inputs #$(glibc-dynamic-linker matching-system))))
1215 (substitute* '("gcc/config/alpha/linux-elf.h"
1216 "gcc/config/arm/linux-elf.h"
1217 "gcc/config/i386/linux.h"
1218 "gcc/config/m68k/linux.h"
1219 "gcc/config/sparc/linux.h"
1220 "gcc/config/sparc/linux64.h")
1221 (("/lib(64)?/ld-linux\\.so\\.[12]")
1222 (search-input-file
1223 inputs #$(glibc-dynamic-linker matching-system))))))
1224 (replace 'configure
1225 (lambda* (#:key outputs build configure-flags
1226 #:allow-other-keys)
1227 ;; It's an old 'configure' script so it needs some help.
1228 (setenv "CONFIG_SHELL" (which "sh"))
1229 (apply invoke "./configure"
1230 (string-append "--prefix=" #$output)
1231 (string-append "--build=" build)
1232 (string-append "--host=" build)
1233 configure-flags)))
1234 (add-before 'configure 'remove-bundled-texinfo
1235 (lambda _
1236 ;; Go ahead despite the many warnings.
1237 (substitute* '("Makefile.in" "gcc/Makefile.in")
1238 (("^MAKEINFOFLAGS =.*")
1239 "MAKEINFOFLAGS = --force\n"))))))))
1240 (native-search-paths
1241 ;; This package supports nothing but the C language.
1242 (list $C_INCLUDE_PATH
1243 $LIBRARY_PATH))))
1244
1245
1246(define-public (make-libstdc++ gcc)
1247 "Return a libstdc++ package based on GCC. The primary use case is when
1248using compilers other than GCC."
1249 (package
1250 (inherit gcc)
1251 (name "libstdc++")
1252 (arguments
1253 (list
1254 #:out-of-source? #t
1255 #:modules `((srfi srfi-1)
1256 (srfi srfi-26)
1257 ,@%default-gnu-modules)
1258 #:phases
1259 #~(modify-phases %standard-phases
1260 #$@(if (version>=? (package-version gcc) "11")
1261 #~((add-after 'unpack 'hide-gcc-headers
1262 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1263 (let ((gcc (assoc-ref (or native-inputs inputs)
1264 #$(if (%current-target-system)
1265 "cross-gcc"
1266 "gcc"))))
1267 ;; Fix a regression in GCC 11 where the GCC headers
1268 ;; shadows glibc headers when building libstdc++. An
1269 ;; upstream fix was added in GCC 11.3.0, but it only
1270 ;; hides system include directories, not those on
1271 ;; CPLUS_INCLUDE_PATH. See discussion at
1272 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100017>
1273 ;; and the similar adjustment in GCC-FINAL.
1274 (substitute* "libstdc++-v3/src/c++17/Makefile.in"
1275 (("AM_CXXFLAGS = ")
1276 (string-append #$(if (%current-target-system)
1277 "CROSS_CPLUS_INCLUDE_PATH = "
1278 "CPLUS_INCLUDE_PATH = ")
1279 (string-join
1280 (remove (cut string-prefix? gcc <>)
1281 (string-split
1282 (getenv
1283 #$(if (%current-target-system)
1284 "CROSS_CPLUS_INCLUDE_PATH"
1285 "CPLUS_INCLUDE_PATH"))
1286 #\:))
1287 ":")
1288 "\nAM_CXXFLAGS = ")))))))
1289 '())
1290 #$@(let ((version (package-version gcc)))
1291 (if (and (target-ppc64le?)
1292 (version>=? version "11")
1293 (not (version>=? version "12")))
1294 ;; TODO: Drop the 'else' branch below on next rebuild
1295 ;; cycle.
1296 (if (%current-target-system)
1297 #~((add-after 'unpack 'patch-powerpc ;correct
1298 (lambda* (#:key native-inputs inputs #:allow-other-keys)
1299 (invoke "patch" "--force" "-p1" "-i"
1300 (assoc-ref (or native-inputs inputs)
1301 "powerpc64le-patch")))))
1302 #~((add-after 'unpack 'patch-powerpc ;wrong
1303 (lambda* (#:key inputs #:allow-other-keys)
1304 (invoke "patch" "--force" "-p1" "-i"
1305 (assoc-ref inputs "powerpc64le-patch"))))))
1306 '()))
1307 ;; Force rs6000 (i.e., powerpc) libdir to be /lib and not /lib64.
1308 (add-after 'unpack 'fix-rs6000-libdir
1309 (lambda _
1310 (when (file-exists? "gcc/config/rs6000")
1311 (substitute* (find-files "gcc/config/rs6000")
1312 (("/lib64") "/lib")))))
1313 (add-before 'configure 'chdir
1314 (lambda _
1315 (chdir "libstdc++-v3")))
1316
1317 #$@(if (version>=? (package-version gcc) "13")
1318 #~((add-after 'unpack 'patch-tzdb.cc
1319 (lambda _
1320 (substitute* "libstdc++-v3/src/c++20/tzdb.cc"
1321 (("#if ! defined _GLIBCXX_ZONEINFO_DIR")
1322 "#if 1 // ! defined _GLIBCXX_ZONEINFO_DIR")))))
1323 '()))
1324
1325 #:configure-flags '`("--disable-libstdcxx-pch"
1326 ,(string-append "--with-gxx-include-dir="
1327 (assoc-ref %outputs "out")
1328 "/include"))))
1329 (outputs '("out" "debug"))
1330 (inputs '())
1331 (native-inputs
1332 `(,@(if (and (target-ppc64le?)
1333 (let ((version (package-version gcc)))
1334 (and
1335 (version>=? version "11")
1336 (not (version>=? version "12")))))
1337 `(("powerpc64le-patch" ,(search-patch "gcc-11-libstdc++-powerpc.patch")))
1338 '())))
1339 (propagated-inputs '())
1340 (synopsis "GNU C++ standard library")))
1341
1342(define make-libstdc++-headers
1343 (mlambdaq (gcc) ;memoize to play well with the object cache
1344 ;; XXX: This package is for internal use to work around
1345 ;; <https://bugs.gnu.org/42392> (see above). The main difference compared
1346 ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>
1347 ;; is right under include/c++ and not under
1348 ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).
1349 (let ((libstdc++ (make-libstdc++ gcc)))
1350 (package
1351 (inherit libstdc++)
1352 (name "libstdc++-headers")
1353 (outputs '("out"))
1354 (build-system trivial-build-system)
1355 (arguments
1356 '(#:builder (let* ((out (assoc-ref %outputs "out"))
1357 (libstdc++ (assoc-ref %build-inputs "libstdc++")))
1358 (mkdir out)
1359 (mkdir (string-append out "/include"))
1360 (symlink (string-append libstdc++ "/include")
1361 (string-append out "/include/c++")))))
1362 (inputs `(("libstdc++" ,libstdc++)))
1363 (synopsis "Headers of GNU libstdc++")))))
1364
1365(define (make-libiberty gcc)
1366 "Return a libiberty package based on GCC."
1367 (package
1368 (inherit gcc)
1369 (name "libiberty")
1370 (arguments
1371 `(#:out-of-source? #t
1372 #:make-flags '("CFLAGS=-O2 -g -fPIC")
1373 #:phases
1374 (modify-phases %standard-phases
1375 (add-before 'configure 'chdir
1376 (lambda _
1377 (chdir "libiberty")))
1378 (replace 'install
1379 (lambda* (#:key outputs #:allow-other-keys)
1380 (let* ((out (assoc-ref outputs "out"))
1381 (lib (string-append out "/lib/"))
1382 (include (string-append out "/include/")))
1383 (install-file "libiberty.a" lib)
1384 (install-file "../include/demangle.h" include)
1385 (install-file "../include/libiberty.h" include)))))))
1386 (inputs '())
1387 (outputs '("out"))
1388 (native-inputs '())
1389 (propagated-inputs '())
1390 (properties '())
1391 (synopsis "Collection of subroutines used by various GNU programs")))
1392
1393(define-public libiberty
1394 (make-libiberty gcc))
1395
1396(define* (custom-gcc gcc name languages
1397 #:optional
1398 (search-paths (package-native-search-paths gcc))
1399 #:key (separate-lib-output? #t))
1400 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
1401as the 'native-search-paths' field."
1402 (package (inherit gcc)
1403 (name name)
1404 (outputs (if separate-lib-output?
1405 (package-outputs gcc)
1406 (delete "lib" (package-outputs gcc))))
1407 (native-search-paths search-paths)
1408 (arguments
1409 (substitute-keyword-arguments arguments
1410 ((#:modules modules %default-gnu-modules)
1411 `(,@modules
1412 (srfi srfi-1)
1413 (srfi srfi-26)
1414 (ice-9 regex)))
1415 ((#:configure-flags flags)
1416 #~(cons (string-append "--enable-languages="
1417 #$(string-join languages ","))
1418 (remove (cut string-match "--enable-languages.*" <>)
1419 #$flags)))
1420 ((#:phases phases)
1421 #~(modify-phases #$phases
1422 (add-after 'install 'remove-broken-or-conflicting-files
1423 (lambda* (#:key outputs #:allow-other-keys)
1424 (for-each
1425 delete-file
1426 (find-files (string-append (assoc-ref outputs "out") "/bin")
1427 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|lto)(-.*)?$"))))))))
1428 (properties `((upstream-name . "gcc")
1429 ,@(alist-delete 'hidden? (package-properties gcc))))))
1430
1431(define %generic-search-paths
1432 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
1433 ;; not considered "system headers", which means GCC can raise warnings for
1434 ;; issues in those headers. 'CPATH' is the only one that works for
1435 ;; front-ends not in the C family.
1436 (list (search-path-specification
1437 (variable "CPATH")
1438 (files '("include")))
1439 (search-path-specification
1440 (variable "LIBRARY_PATH")
1441 (files '("lib" "lib64")))))
1442
1443(define-public gfortran-13
1444 (hidden-package
1445 (custom-gcc gcc-13
1446 "gfortran" '("fortran")
1447 %generic-search-paths)))
1448
1449(define-public gfortran
1450 (hidden-package
1451 (custom-gcc gcc
1452 "gfortran" '("fortran")
1453 %generic-search-paths)))
1454
1455(define-public gfortran-9
1456 (hidden-package
1457 (custom-gcc gcc-9
1458 "gfortran" '("fortran")
1459 %generic-search-paths)))
1460
1461(define-public gfortran-7
1462 (hidden-package
1463 (custom-gcc gcc-7
1464 "gfortran" '("fortran")
1465 %generic-search-paths)))
1466
1467(define* (make-gdc gcc #:optional bootstrap-gdc #:key frontend-version)
1468 (define gdc (custom-gcc gcc "gdc" '("d") (list $LIBRARY_PATH)))
1469 (define version (package-version gdc))
1470 (define (since-version? since) (version>=? version since))
1471 (define (until-version? until) (version>? until version))
1472 (define patches (cond ((and (since-version? "11")
1473 (until-version? "12"))
1474 (search-patches "gdc-11-druntime-hurd.patch"))
1475 ((and (since-version? "14")
1476 (until-version? "15"))
1477 (search-patches "gdc-14-druntime-hurd.patch"))
1478 (else '())))
1479 (package
1480 (inherit gdc)
1481 (source
1482 (origin
1483 (inherit (package-source gdc))
1484 (patches
1485 (append (origin-patches (package-source gdc))
1486 patches))))
1487 (arguments
1488 (substitute-keyword-arguments arguments
1489 ((#:modules modules)
1490 `(,@modules
1491 (ice-9 ftw)))
1492 ((#:configure-flags flags)
1493 #~(append
1494 #$flags
1495 (list "--disable-c++tools"
1496 #$@(if (since-version? "11") #~("--disable-libatomic") #~())
1497 "--disable-libcc1"
1498 "--disable-libgomp"
1499 "--disable-libitm"
1500 "--disable-libquadmath"
1501 "--disable-libsanitizer"
1502 "--disable-libssp"
1503 #$@(if (until-version? "15") #~("--disable-libstdcxx") #~())
1504 "--disable-plugin")))
1505 ((#:phases phases)
1506 #~(modify-phases #$phases
1507 (add-after 'strip 'gdc-cleanup-install
1508 (lambda* (#:key outputs #:allow-other-keys)
1509 (define (delete-except-matches prefix patterns)
1510 ;; Remove all files except for those matching any of the
1511 ;; patterns.
1512 (define (should-delete? path statbuf)
1513 (define suffix (substring path (string-length prefix)))
1514 (not (or (zero? (string-length suffix))
1515 (any (cut string-match <> suffix)
1516 patterns))))
1517 (for-each (lambda (path)
1518 (format #t "Deleting ~a\n" path)
1519 (delete-file path))
1520 (find-files prefix should-delete?))
1521 ;; Clean up empty directories.
1522 (define (dir-empty? path statbuf)
1523 (and (eq? (stat:type statbuf) 'directory)
1524 (zero? (length (filter
1525 (lambda (name)
1526 (not (or (string=? name ".")
1527 (string=? name ".."))))
1528 (scandir path))))))
1529 (while #t
1530 (let* ((empty-dirs (find-files prefix dir-empty?
1531 #:stat lstat
1532 #:directories? #t)))
1533 (if (zero? (length empty-dirs))
1534 (break)
1535 (for-each rmdir empty-dirs)))))
1536 ;; Leave out non-GDC binaries, man pages, locale files, and
1537 ;; c++ headers.
1538 (delete-except-matches
1539 (assoc-ref outputs "out")
1540 (list "^/bin/.*gdc$"
1541 "^/libexec/"
1542 "^/share/info/gdc"
1543 "^/share/man/man1/gdc"
1544 "^/share/man/man7/"))
1545 ;; Leave out C/C++ libraries, headers and empty directories.
1546 (delete-except-matches
1547 (assoc-ref outputs "lib")
1548 (list "^/lib/gcc/.*/include/d/"
1549 "^/lib/gcc/.*/.*\\.[ao]$"
1550 "^/lib/libgcc_s.*"
1551 "^/lib/libgdruntime.*"
1552 "^/lib/libgphobos.*"))
1553 ;; Repeat for the debug files.
1554 (delete-except-matches
1555 (assoc-ref outputs "debug")
1556 (list "^/lib/debug/.*/bin/.*gdc\\.debug$"
1557 "^/lib/debug/.*/lib/libgcc_s"
1558 "^/lib/debug/.*/lib/libgdruntime"
1559 "^/lib/debug/.*/lib/libgphobos"))))))))
1560 (inputs
1561 (modify-inputs inputs
1562 ;; This makes flags like -static-libstdc++ work. Required for using this
1563 ;; compiler as a bootstrap compiler for GDC 12+.
1564 ;; Additionally, this allows us to support linking with GCC libraries,
1565 ;; without building or storing them ourselves.
1566 (append (list gcc "lib"))))
1567 (native-inputs
1568 (let ((orig native-inputs))
1569 (if bootstrap-gdc
1570 (modify-inputs orig
1571 ;; Since GCC 12, GDC is self-hosted, requiring a version of itself
1572 ;; to build.
1573 (append bootstrap-gdc))
1574 orig)))
1575 (synopsis "GNU D Compiler")
1576 (description
1577 (string-append
1578 "GDC is the D frontend for the @acronym{GNU Compiler Collection,GCC}. It
1579also includes the druntime and phobos libraries."
1580 (if frontend-version
1581 (format #f "~%~%This compiler is based on the DMD frontend version ~a."
1582 frontend-version)
1583 "")))
1584 (home-page "https://www.gdcproject.org/")))
1585
1586(define-public gdc-9
1587 (make-gdc gcc-9 #:frontend-version "2.076.2"))
1588
1589(define-public gdc-10
1590 (make-gdc gcc-10 #:frontend-version "2.076.2"))
1591
1592(define-public gdc-11
1593 (make-gdc gcc-11 #:frontend-version "2.076.2"))
1594
1595(define-public gdc-12
1596 (make-gdc gcc-12 gdc-11 #:frontend-version "2.100.2"))
1597
1598(define-public gdc-13
1599 (make-gdc gcc-13 gdc-11 #:frontend-version "2.103.1"))
1600
1601(define-public gdc-14
1602 (make-gdc gcc-14 gdc-11 #:frontend-version "2.108.1"))
1603
1604(define-public gdc-15
1605 (make-gdc gcc-15 gdc-11 #:frontend-version "2.111.0"))
1606
1607(define-public gdc-16
1608 (make-gdc gcc-16 gdc-11 #:frontend-version "2.113.0-beta.1"))
1609
1610(define-public gdc gdc-14)
1611
1612(define* (make-gdmd gdc)
1613 (let ((gdc-version (package-version gdc))
1614 (gdmd-version "0.26.0"))
1615 (package
1616 (name "gdmd")
1617 (version (string-append gdc-version "-" gdmd-version))
1618 (source (origin
1619 (method git-fetch)
1620 (uri (git-reference
1621 (url "https://github.com/D-Programming-GDC/gdmd")
1622 (commit (string-append "script-" gdmd-version))))
1623 (file-name (git-file-name name gdmd-version))
1624 (sha256
1625 (base32
1626 "0i9warhlwyspjs3rpvs2989820909lgzjnsflpd9mp2flq7isjh0"))))
1627 (build-system copy-build-system)
1628 (arguments
1629 (list
1630 #:install-plan
1631 #~'(("dmd-script" "bin/gdmd")
1632 ("dmd-script.1" "share/man/man1/gdmd.1"))
1633 #:phases
1634 #~(modify-phases %standard-phases
1635 (add-after 'unpack 'adjust-gdc-location
1636 (lambda* (#:key inputs #:allow-other-keys)
1637 (substitute* "dmd-script"
1638 (("my \\$gdc_dir.*")
1639 (string-append "my $gdc_dir = \""
1640 (dirname
1641 (search-input-file inputs "/bin/gdc"))
1642 "\";\n"))))))))
1643 (inputs (list gdc perl))
1644 (synopsis "DMD-like wrapper for GDC")
1645 (description "This package provides a DMD-like wrapper for the
1646@acronym{GNU D Compiler,GDC}.")
1647 (license gpl3+)
1648 (home-page "https://github.com/D-Programming-GDC/gdmd")
1649 (properties '(;; Some older tags don't follow this format.
1650 (release-tag-prefix . "^script-"))))))
1651
1652(define-public gdmd-9
1653 (make-gdmd gdc-9))
1654
1655(define-public gdmd-10
1656 (make-gdmd gdc-10))
1657
1658(define-public gdmd-11
1659 (make-gdmd gdc-11))
1660
1661(define-public gdmd-12
1662 (make-gdmd gdc-12))
1663
1664(define-public gdmd-13
1665 (make-gdmd gdc-13))
1666
1667(define-public gdmd-14
1668 (make-gdmd gdc-14))
1669
1670(define-public gdmd-15
1671 (make-gdmd gdc-15))
1672
1673(define-public gdmd-16
1674 (make-gdmd gdc-16))
1675
1676(define-public gdmd gdmd-14)
1677
1678(define-public gm2
1679 (hidden-package
1680 (let ((base (custom-gcc gcc-14
1681 "gm2" '("m2")
1682 %generic-search-paths)))
1683 (package
1684 (inherit base)
1685 (native-inputs
1686 (modify-inputs native-inputs
1687 (prepend flex)))))))
1688
1689(define-public (make-libgccjit gcc)
1690 (package
1691 (inherit gcc)
1692 (name "libgccjit")
1693 (outputs (delete "lib" (package-outputs gcc)))
1694 (properties (alist-delete 'hidden? (package-properties gcc)))
1695 (arguments
1696 (substitute-keyword-arguments arguments
1697 ((#:modules _ '())
1698 '((guix build gnu-build-system)
1699 (guix build utils)
1700 (ice-9 regex)
1701 (srfi srfi-1)
1702 (srfi srfi-26)))
1703 ((#:configure-flags flags)
1704 #~(cons* "--disable-bootstrap"
1705 "--disable-libatomic"
1706 "--disable-libgomp"
1707 "--disable-libquadmath"
1708 "--disable-libssp"
1709 "--enable-host-shared"
1710 "--enable-checking=release"
1711 "--enable-languages=jit"
1712 (remove (cut string-match "--enable-languages.*" <>)
1713 #$flags)))
1714 ((#:phases phases)
1715 #~(modify-phases #$phases
1716 (add-after 'install 'remove-broken-or-conflicting-files
1717 (lambda* (#:key outputs #:allow-other-keys)
1718 (for-each delete-file
1719 (find-files
1720 (string-append (assoc-ref outputs "out") "/bin")
1721 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))))))))
1722 (inputs (modify-inputs inputs
1723 (delete "libstdc++")))
1724 (native-inputs (modify-inputs native-inputs
1725 (prepend gcc)))
1726 (synopsis "GCC library generating machine code on-the-fly at runtime")
1727 (description
1728 "This package is part of the GNU Compiler Collection and provides an
1729embeddable library for generating machine code on-the-fly at runtime. This
1730shared library can then be dynamically-linked into bytecode interpreters and
1731other such programs that want to generate machine code on-the-fly at run-time.
1732It can also be used for ahead-of-time code generation for building standalone
1733compilers. The just-in-time (jit) part of the name is now something of a
1734misnomer.")))
1735
1736(define-public libgccjit-9 (make-libgccjit gcc-9))
1737(define-public libgccjit-10 (make-libgccjit gcc-10))
1738(define-public libgccjit-11 (make-libgccjit gcc-11))
1739(define-public libgccjit-12 (make-libgccjit gcc-12))
1740(define-public libgccjit-14 (make-libgccjit gcc-14))
1741(define-public libgccjit-15 (make-libgccjit gcc-15))
1742(define-public libgccjit-16 (make-libgccjit gcc-16))
1743
1744;; This must match the 'gcc' variable, but it must also be 'eq?' to one of the
1745;; libgccjit-* packages above.
1746(define-public libgccjit libgccjit-14)
1747
1748(define (make-gccgo gcc)
1749 "Return a gccgo package based on GCC."
1750 (let ((gccgo (custom-gcc gcc "gccgo" '("go") %generic-search-paths)))
1751 (package
1752 (inherit gccgo)
1753 (synopsis "Go frontend to GCC")
1754 (description
1755 "This package is part of the GNU Compiler Collection and
1756provides the GNU compiler for the Go programming language.")
1757 (arguments
1758 (substitute-keyword-arguments arguments
1759 ((#:phases phases)
1760 #~(modify-phases #$phases
1761 #$@(if (and (version>=? (package-version gccgo) "12.0")
1762 ;; This somehow breaks gccgo@12 on riscv64-linux.
1763 (not (and (target-riscv64?)
1764 (string=? (version-prefix
1765 (package-version gccgo) 1)
1766 "12"))))
1767 #~((add-after 'unpack 'adjust-libgo-dependencies
1768 (lambda _
1769 (substitute* "Makefile.in"
1770 ;; libgo.la depends on libbacktrace.la but the
1771 ;; current dependency rules don't have libbacktrace
1772 ;; building early enough for libgo. When built
1773 ;; with more than 1 core this issue doesn't appear.
1774 ;; see commit 5fee5ec362f7a243f459e6378fd49dfc89dc9fb5.
1775 (("all-target-libgo: maybe-all-target-libffi")
1776 (string-append
1777 "all-target-libgo: maybe-all-target-libbacktrace\n"
1778 "all-target-libgo: maybe-all-target-libffi\n"
1779 "all-target-libgo: maybe-all-target-libatomic"))))))
1780 #~())
1781 (add-after 'install 'wrap-go-with-tool-path
1782 (lambda* (#:key outputs #:allow-other-keys)
1783 (let* ((out (assoc-ref outputs "out"))
1784 (exedir (string-append out "/libexec/gcc"))
1785 (tooldir (dirname (car (find-files exedir "^cgo$")))))
1786 (wrap-program (string-append out "/bin/go")
1787 `("GCCGOTOOLDIR" =
1788 (,(string-append "${GCCGOTOOLDIR:-" tooldir "}")))
1789 `("GOROOT" =
1790 (,(string-append "${GOROOT:-" out "}")))))))
1791 (add-before 'configure 'fix-gotools-runpath
1792 (lambda _
1793 (substitute* "gotools/Makefile.in"
1794 (("AM_LDFLAGS =" all)
1795 (string-append all " -Wl,-rpath=$(libdir) ")))))
1796 (add-before 'configure 'remove-tool-reference-from-libgo
1797 (lambda _
1798 (substitute* "libgo/Makefile.in"
1799 (("(GccgoToolDir = \\\")[^\\\"]+" _ start)
1800 (string-append start "/nonexistent"))
1801 #$@(if (version>=? (package-version gccgo) "12.0")
1802 '((("(defaultGOROOT = `)[^`]+" _ start)
1803 (string-append start "/nonexistent")))
1804 '((("(DefaultGoroot = \\\")[^\\\"]+" _ start)
1805 (string-append start "/nonexistent"))))
1806 (("(defaultGOROOTValue.*?return `)[^`]+" _ start)
1807 (string-append start "/nonexistent"))))))))))))
1808
1809;; Provides go-1.18
1810(define-public gccgo-12
1811 (make-gccgo gcc-12))
1812
1813;; Provides go-1.18
1814(define-public gccgo-13
1815 (make-gccgo gcc-13))
1816
1817;; Provides go-1.18
1818(define-public gccgo-14
1819 (make-gccgo gcc-14))
1820
1821;; Provides go-1.18
1822(define-public gccgo-15
1823 (make-gccgo gcc-15))
1824
1825;; Provides go-1.18
1826(define-public gccgo-16
1827 (make-gccgo gcc-16))
1828
1829(define-public isl
1830 (package
1831 (name "isl")
1832 (version "0.24")
1833 (source (origin
1834 (method url-fetch)
1835 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1836 version ".tar.xz")
1837 (string-append %gcc-infrastructure
1838 "isl-" version ".tar.xz")))
1839 (sha256
1840 (base32
1841 "1bgbk6n93qqn7w8v21kxf4x6dc3z0ypqrzvgfd46nhagak60ac84"))))
1842 (build-system gnu-build-system)
1843 (outputs '("out" "static"))
1844 (arguments
1845 `(#:phases (modify-phases %standard-phases
1846 (add-after 'install 'move-static-library
1847 (lambda* (#:key outputs #:allow-other-keys)
1848 (let* ((out (assoc-ref outputs "out"))
1849 (static (assoc-ref outputs "static"))
1850 (source (string-append out "/lib/libisl.a"))
1851 (target (string-append static "/lib/libisl.a")))
1852 (mkdir-p (dirname target))
1853 (link source target)
1854 (delete-file source)
1855
1856 ;; Remove reference to libisl.a from the .la file so
1857 ;; libtool looks for it in the usual locations.
1858 (substitute* (string-append out "/lib/libisl.la")
1859 (("^old_library=.*")
1860 "old_library=''\n")))))
1861 ,@(if (target-loongarch64?)
1862 `((add-after 'unpack 'update-config-scripts
1863 (lambda* (#:key inputs native-inputs #:allow-other-keys)
1864 ;; Replace outdated config.guess and config.sub.
1865 (for-each (lambda (file)
1866 (install-file
1867 (search-input-file
1868 (or native-inputs inputs)
1869 (string-append "/bin/" file)) "."))
1870 '("config.guess" "config.sub")))))
1871 '()))))
1872 (native-inputs (if (target-loongarch64?)
1873 (list config)
1874 '()))
1875 (inputs (list gmp))
1876 (home-page "https://libisl.sourceforge.io/") ;https://repo.or.cz/w/isl.git
1877 (properties `((release-monitoring-url . ,home-page)))
1878 (synopsis
1879 "Manipulating sets and relations of integer points \
1880bounded by linear constraints")
1881 (description
1882 "isl is a library for manipulating sets and relations of integer points
1883bounded by linear constraints. Supported operations on sets include
1884intersection, union, set difference, emptiness check, convex hull, (integer)
1885affine hull, integer projection, computing the lexicographic minimum using
1886parametric integer programming, coalescing and parametric vertex
1887enumeration. It also includes an ILP solver based on generalized basis
1888reduction, transitive closures on maps (which may encode infinite graphs),
1889dependence analysis and bounds on piecewise step-polynomials.")
1890 (license lgpl2.1+)))
1891
1892(define-public isl-0.18
1893 (package
1894 (inherit isl)
1895 (version "0.18")
1896 (source (origin
1897 (method url-fetch)
1898 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1899 version ".tar.bz2")
1900 (string-append %gcc-infrastructure
1901 "isl-" version ".tar.bz2")))
1902 (sha256
1903 (base32
1904 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
1905
1906(define-public isl-0.11
1907 (package
1908 (inherit isl)
1909 (name "isl")
1910 (version "0.11.1")
1911 (source (origin
1912 (method url-fetch)
1913 (uri (list (string-append "mirror://sourceforge/libisl/isl-"
1914 version ".tar.bz2")
1915 (string-append %gcc-infrastructure
1916 "isl-" version ".tar.bz2")))
1917 (sha256
1918 (base32
1919 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
1920 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
1921
1922(define-public cloog
1923 (package
1924 (name "cloog")
1925 (version "0.18.0")
1926 (source
1927 (origin
1928 (method url-fetch)
1929 (uri (list (string-append
1930 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
1931 version
1932 ".tar.gz")
1933 (string-append %gcc-infrastructure
1934 name "-" version ".tar.gz")))
1935 (sha256
1936 (base32
1937 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
1938 (file-name (string-append name "-" version ".tar.gz"))))
1939 (build-system gnu-build-system)
1940 (inputs (list gmp isl-0.11))
1941 (arguments '(#:configure-flags '("--with-isl=system")))
1942 (home-page "http://www.cloog.org/")
1943 (synopsis "Library to generate code for scanning Z-polyhedra")
1944 (description
1945 "CLooG is a free software library to generate code for scanning
1946Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
1947reaches each integral point of one or more parameterized polyhedra.
1948CLooG has been originally written to solve the code generation problem
1949for optimizing compilers based on the polytope model. Nevertheless it
1950is used now in various area e.g., to build control automata for
1951high-level synthesis or to find the best polynomial approximation of a
1952function. CLooG may help in any situation where scanning polyhedra
1953matters. While the user has full control on generated code quality,
1954CLooG is designed to avoid control overhead and to produce a very
1955effective code.")
1956 (license gpl2+)))
1957
1958(define-public gnu-c-manual
1959 (package
1960 (name "gnu-c-manual")
1961 (version "0.2.5")
1962 (source (origin
1963 (method url-fetch)
1964 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1965 version ".tar.gz"))
1966 (sha256
1967 (base32
1968 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
1969 (build-system gnu-build-system)
1970 (native-inputs (list texinfo))
1971 (arguments
1972 '(#:phases (modify-phases %standard-phases
1973 (delete 'configure)
1974 (delete 'check)
1975 (replace 'build
1976 (lambda _
1977 (invoke "make"
1978 "gnu-c-manual.info"
1979 "gnu-c-manual.html")))
1980 (replace 'install
1981 (lambda* (#:key outputs #:allow-other-keys)
1982 (let* ((out (assoc-ref outputs "out"))
1983 (info (string-append out "/share/info"))
1984 (html (string-append
1985 out "/share/doc/gnu-c-manual")))
1986 (mkdir-p info)
1987 (mkdir-p html)
1988
1989 (for-each (lambda (file)
1990 (copy-file file
1991 (string-append info "/"
1992 file)))
1993 (find-files "." "\\.info(-[0-9])?$"))
1994 (for-each (lambda (file)
1995 (copy-file file
1996 (string-append html "/"
1997 file)))
1998 (find-files "." "\\.html$"))))))))
1999 (synopsis "Reference manual for the C programming language")
2000 (description
2001 "This is a reference manual for the C programming language, as
2002implemented by the GNU C Compiler (gcc). As a reference, it is not intended
2003to be a tutorial of the language. Rather, it outlines all of the constructs
2004of the language. Library functions are not included.")
2005 (home-page "https://www.gnu.org/software/gnu-c-manual/")
2006 (license fdl1.3+)))