projects/guix·blob java-team · refs

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