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