gnu: Add blktrace.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
CommitLineData
e9c0b944 1;;; GNU Guix --- Functional package management for GNU
798591b6 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
f888d5bb 3;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
fbeb92d7 4;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
ed2b1c4f 5;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
60ce496a 6;;; Copyright © 2015, 2016, 2017, 2018, 2020 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>
a1fa2691 9;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
76d2b9a2 10;;; Copyright © 2020 Joseph LaFreniere <joseph@lafreniere.xyz>
e9c0b944
LC
11;;;
12;;; This file is part of GNU Guix.
13;;;
14;;; GNU Guix is free software; you can redistribute it and/or modify it
15;;; under the terms of the GNU General Public License as published by
16;;; the Free Software Foundation; either version 3 of the License, or (at
17;;; your option) any later version.
18;;;
19;;; GNU Guix is distributed in the hope that it will be useful, but
20;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;;; GNU General Public License for more details.
23;;;
24;;; You should have received a copy of the GNU General Public License
25;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27(define-module (gnu packages gcc)
c6d7e299 28 #:use-module ((guix licenses)
50c7a1e2 29 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
e9c0b944
LC
30 #:use-module (gnu packages)
31 #:use-module (gnu packages bootstrap)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages multiprecision)
c8ebc821 34 #:use-module (gnu packages texinfo)
c364a287 35 #:use-module (gnu packages dejagnu)
99828fa7 36 #:use-module (gnu packages documentation)
98b385d1
LC
37 #:use-module (gnu packages xml)
38 #:use-module (gnu packages docbook)
39 #:use-module (gnu packages graphviz)
3e778ad3 40 #:use-module (gnu packages elf)
38cf2ba0 41 #:use-module (gnu packages perl)
e9c0b944
LC
42 #:use-module (guix packages)
43 #:use-module (guix download)
ca16cb96 44 #:use-module (guix build-system gnu)
74574fd1 45 #:use-module (guix build-system trivial)
fdd6c726 46 #:use-module (guix utils)
e052c7e1 47 #:use-module (srfi srfi-1)
ca16cb96 48 #:use-module (ice-9 regex))
e9c0b944 49
832abc76
LC
50(define %gcc-infrastructure
51 ;; Base URL for GCC's infrastructure.
966a543b 52 "mirror://gcc/infrastructure/")
832abc76 53
76e639a0 54(define (gcc-configure-flags-for-triplet target)
ca16cb96
LC
55 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
56
57The purpose of this procedure is to translate extended GNU triplets---e.g.,
58where the OS part is overloaded to denote a specific ABI---into GCC
59`configure' options. We take extended GNU triplets that glibc recognizes."
60 (cond ((string-match "^mips64el.*gnuabin?64$" target)
61 ;; Triplets recognized by glibc as denoting the N64 ABI; see
62 ;; ports/sysdeps/mips/preconfigure.
63 '("--with-abi=64"))
3f00ff8b
MW
64
65 ((string-match "^arm.*-gnueabihf$" target)
66 '("--with-arch=armv7-a"
67 "--with-float=hard"
68 "--with-mode=thumb"
aa725117 69 "--with-fpu=neon"))
3f00ff8b 70
ec6ba5c1
LC
71 ((and (string-suffix? "-gnu" target)
72 (not (string-contains target "-linux")))
73 ;; Cross-compilation of libcilkrts in GCC 5.5.0 to GNU/Hurd fails
74 ;; with:
75 ;; libcilkrts/runtime/os-unix.c:388:2: error: #error "Unknown architecture"
76 ;; Cilk has been removed from GCC 8 anyway.
77 '("--disable-libcilkrts"))
78
ca16cb96 79 (else
3f00ff8b 80 ;; TODO: Add `arm.*-gnueabi', etc.
ca16cb96
LC
81 '())))
82
e9c0b944 83(define-public gcc-4.7
9063ef0f 84 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
de1d41f9
LC
85 (maybe-target-tools
86 (lambda ()
87 ;; Return the `_FOR_TARGET' variables that are needed when
88 ;; cross-compiling GCC.
89 (let ((target (%current-target-system)))
90 (if target
91 (map (lambda (var tool)
92 (string-append (string-append var "_FOR_TARGET")
93 "=" target "-" tool))
066ccc2c
LC
94 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
95 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
de1d41f9 96 '()))))
7e3c9f74
LC
97 (libdir
98 (let ((base '(or (assoc-ref outputs "lib")
99 (assoc-ref outputs "out"))))
100 (lambda ()
101 ;; Return the directory that contains lib/libgcc_s.so et al.
102 (if (%current-target-system)
103 `(string-append ,base "/" ,(%current-target-system))
104 base))))
de1d41f9
LC
105 (configure-flags
106 (lambda ()
107 ;; This is terrible. Since we have two levels of quasiquotation,
108 ;; we have to do this convoluted thing just so we can insert the
109 ;; contents of (maybe-target-tools).
110 (list 'quasiquote
111 (append
112 '("--enable-plugin"
113 "--enable-languages=c,c++"
114 "--disable-multilib"
98bd851e 115 "--with-system-zlib"
de1d41f9 116
06213498
LC
117 ;; No pre-compiled libstdc++ headers, to save space.
118 "--disable-libstdcxx-pch"
119
de1d41f9
LC
120 "--with-local-prefix=/no-gcc-local-prefix"
121
84e6756c
LC
122 ;; With a separate "lib" output, the build system
123 ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force
124 ;; it. (Don't use a versioned sub-directory, that's
125 ;; unnecessary.)
126 ,(string-append "--with-gxx-include-dir="
127 (assoc-ref %outputs "out")
128 "/include/c++")
129
de1d41f9
LC
130 ,(let ((libc (assoc-ref %build-inputs "libc")))
131 (if libc
132 (string-append "--with-native-system-header-dir=" libc
133 "/include")
134 "--without-headers")))
135
76e639a0
MW
136 ;; Pass the right options for the target triplet.
137 (let ((triplet
138 (or (%current-target-system)
139 (nix-system->gnu-triplet (%current-system)))))
140 (gcc-configure-flags-for-triplet triplet))
ca16cb96 141
de1d41f9 142 (maybe-target-tools))))))
d78010b8
RW
143 (hidden-package
144 (package
145 (name "gcc")
146 (version "4.7.4")
147 (source (origin
148 (method url-fetch)
149 (uri (string-append "mirror://gnu/gcc/gcc-"
150 version "/gcc-" version ".tar.bz2"))
151 (sha256
152 (base32
153 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
154 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
155 "gcc-fix-texi2pod.patch"))))
156 (build-system gnu-build-system)
157
158 ;; Separate out the run-time support libraries because all the
159 ;; dynamic-linked objects depend on it.
160 (outputs '("out" ;commands, etc. (60+ MiB)
161 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
162 "debug")) ;debug symbols of run-time libraries
163
164 (inputs `(("gmp" ,gmp)
165 ("mpfr" ,mpfr)
166 ("mpc" ,mpc)
167 ("libelf" ,libelf)
168 ("zlib" ,zlib)))
169
170 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
171 ;; Newer texinfos fail to build the manual, so we use an older one.
172 (native-inputs `(("perl" ,perl) ;for manpages
173 ("texinfo" ,texinfo-5)))
174
175 (arguments
176 `(#:out-of-source? #t
177 #:configure-flags ,(configure-flags)
178 #:make-flags
179 ;; None of the flags below are needed when doing a Canadian cross.
180 ;; TODO: Simplify this.
181 ,(if (%current-target-system)
182 (if stripped?
183 ''("CFLAGS=-g0 -O2")
184 ''())
185 `(let* ((libc (assoc-ref %build-inputs "libc"))
186 (libc-native (or (assoc-ref %build-inputs "libc-native")
187 libc)))
188 `(,@(if libc
189 (list (string-append "LDFLAGS_FOR_TARGET="
190 "-B" libc "/lib "
191 "-Wl,-dynamic-linker "
192 "-Wl," libc
193 ,(glibc-dynamic-linker)))
194 '())
195
196 ;; Native programs like 'genhooks' also need that right.
197 ,(string-append "LDFLAGS="
198 "-Wl,-rpath=" libc-native "/lib "
199 "-Wl,-dynamic-linker "
200 "-Wl," libc-native ,(glibc-dynamic-linker))
201 ,(string-append "BOOT_CFLAGS=-O2 "
202 ,(if stripped? "-g0" "-g")))))
203
204 #:tests? #f
205
206 #:phases
207 (modify-phases %standard-phases
208 (add-before 'configure 'pre-configure
209 (lambda* (#:key inputs outputs #:allow-other-keys)
210 (let ((libdir ,(libdir))
211 (libc (assoc-ref inputs "libc")))
212 (when libc
213 ;; The following is not performed for `--without-headers'
214 ;; cross-compiler builds.
215
216 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
217 ;; single line, to allow the next step to work properly.
218 (for-each
219 (lambda (x)
ba81ca6a
TGR
220 (substitute* (find-files "gcc/config"
221 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
d78010b8
RW
222 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
223 line)))
224 '(1 2 3))
225
226 ;; Fix the dynamic linker's file name.
227 (substitute* (find-files "gcc/config"
228 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
229 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
230 _ gnu-user suffix)
231 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
232 gnu-user suffix
233 (string-append libc ,(glibc-dynamic-linker)))))
234
235 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
236 ;; `crt{begin,end}.o', which come with GCC.
237 (substitute* (find-files "gcc/config"
238 "^gnu-user.*\\.h$")
239 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
240 ;; Help libgcc_s.so be found (see also below.) Always use
241 ;; '-lgcc_s' so that libgcc_s.so is always found by those
242 ;; programs that use 'pthread_cancel' (glibc dlopens
243 ;; libgcc_s.so when pthread_cancel support is needed, but
244 ;; having it in the application's RUNPATH isn't enough; see
245 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
246 ;;
247 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
248 ;; later phase of %gcc-static. If you change the string
249 ;; below, make sure to update the relevant code in
250 ;; %gcc-static package as needed.
251 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
81197492 252\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
d78010b8
RW
253 libc libc libdir suffix))
254 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
255 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
e9c0b944 256#define STANDARD_STARTFILE_PREFIX_2 \"\"
06213498 257~a"
d78010b8
RW
258 libc line)))
259
260 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
261 ;; GNU_USER_* defines. Do the above for this case.
262 (substitute*
263 "gcc/config/rs6000/sysv4.h"
264 (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
265 (format #f "#define LIB_LINUX_SPEC \
fc649d0a 266\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
d78010b8
RW
267 libc libc libdir suffix))
268 (("#define STARTFILE_LINUX_SPEC.*$" line)
269 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
fc649d0a
CSLL
270#define STANDARD_STARTFILE_PREFIX_2 \"\"
271~a"
d78010b8
RW
272 libc line))))
273
274 ;; Don't retain a dependency on the build-time sed.
275 (substitute* "fixincludes/fixincl.x"
276 (("static char const sed_cmd_z\\[\\] =.*;")
277 "static char const sed_cmd_z[] = \"sed\";"))
278
279 ;; Aarch64 support didn't land in GCC until the 4.8 series.
280 (when (file-exists? "gcc/config/aarch64")
281 ;; Force Aarch64 libdir to be /lib and not /lib64
282 (substitute* "gcc/config/aarch64/t-aarch64-linux"
283 (("lib64") "lib")))
284
285 (when (file-exists? "libbacktrace")
286 ;; GCC 4.8+ comes with libbacktrace. By default it builds
287 ;; with -Werror, which fails with a -Wcast-qual error in glibc
288 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
289 (substitute* "libbacktrace/configure"
290 (("WARN_FLAGS=(.*)-Werror" _ flags)
291 (string-append "WARN_FLAGS=" flags)))
292
293 (when (file-exists? "libsanitizer/libbacktrace")
294 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
295 (substitute* "libsanitizer/libbacktrace/Makefile.in"
296 (("-Werror")
297 ""))))
298
299 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
300 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
301 ;; and <http://bugs.gnu.org/20358>.
302 (substitute* "libstdc++-v3/src/Makefile.in"
303 (("^OPT_LDFLAGS = ")
304 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
305
306 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
307 ;; circularity between "out" and "lib". (Note:
308 ;; --with-python-dir is useless because it imposes $(prefix) as
309 ;; the parent directory.)
310 (substitute* "libstdc++-v3/python/Makefile.in"
311 (("pythondir = .*$")
312 (string-append "pythondir = " libdir "/share"
313 "/gcc-$(gcc_version)/python\n")))
314
315 ;; Avoid another circularity between the outputs: this #define
316 ;; ends up in auto-host.h in the "lib" output, referring to
317 ;; "out". (This variable is used to augment cpp's search path,
318 ;; but there's nothing useful to look for here.)
319 (substitute* "gcc/config.in"
320 (("PREFIX_INCLUDE_DIR")
321 "PREFIX_INCLUDE_DIR_isnt_necessary_here"))
322 #t)))
323
324 (add-after 'configure 'post-configure
325 (lambda _
326 ;; Don't store configure flags, to avoid retaining references to
327 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
328 (substitute* "Makefile"
329 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
330 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))
331 #t)))))
332
333 (native-search-paths
334 ;; Use the language-specific variables rather than 'CPATH' because they
335 ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
336 ;; The intent is to allow headers that are in the search path to be
337 ;; treated as "system headers" (headers exempt from warnings) just like
338 ;; the typical /usr/include headers on an FHS system.
339 (list (search-path-specification
340 (variable "C_INCLUDE_PATH")
341 (files '("include")))
342 (search-path-specification
343 (variable "CPLUS_INCLUDE_PATH")
344 (files '("include")))
345 (search-path-specification
346 (variable "LIBRARY_PATH")
347 (files '("lib" "lib64")))))
348
349 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
350 (synopsis "GNU Compiler Collection")
351 (description
352 "GCC is the GNU Compiler Collection. It provides compiler front-ends
a22dc0c4 353for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
79c311b8 354Go. It also includes runtime support libraries for these languages.")
d78010b8
RW
355 (license gpl3+)
356 (supported-systems (delete "aarch64-linux" %supported-systems))
357 (home-page "https://gcc.gnu.org/")))))
832abc76 358
3b401612 359(define-public gcc-4.8
3b401612 360 (package (inherit gcc-4.7)
ab5f49cf 361 (version "4.8.5")
3b401612 362 (source (origin
7e35b9dd
LC
363 (method url-fetch)
364 (uri (string-append "mirror://gnu/gcc/gcc-"
365 version "/gcc-" version ".tar.bz2"))
366 (sha256
367 (base32
ab5f49cf 368 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
19d27131 369 (patches (search-patches "gcc-arm-link-spec-fix.patch"
0b93d04a 370 "gcc-4.8-libsanitizer-fix.patch"
8e7ec29d 371 "gcc-asan-missing-include.patch"
7bbc708a
EF
372 "gcc-fix-texi2pod.patch"))
373 (modules '((guix build utils)))
374 ;; This is required for building with glibc-2.26.
375 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
376 (snippet
6cbee49d
MW
377 '(begin
378 (for-each
379 (lambda (dir)
380 (substitute* (string-append "libgcc/config/"
381 dir "/linux-unwind.h")
382 (("struct ucontext") "ucontext_t")))
383 '("aarch64" "alpha" "bfin" "i386" "m68k"
384 "pa" "sh" "tilepro" "xtensa"))
385 #t))))
2b8d4ce8
EF
386 (supported-systems %supported-systems)
387 (inputs
ab53bdf0 388 `(("isl" ,isl-0.11)
2b8d4ce8
EF
389 ("cloog" ,cloog)
390 ,@(package-inputs gcc-4.7)))))
3b401612 391
571aa6cd 392(define-public gcc-4.9
dd4efefd 393 (package (inherit gcc-4.8)
b0847497 394 (version "4.9.4")
571aa6cd 395 (source (origin
7e35b9dd
LC
396 (method url-fetch)
397 (uri (string-append "mirror://gnu/gcc/gcc-"
398 version "/gcc-" version ".tar.bz2"))
399 (sha256
400 (base32
b0847497 401 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
d6593070 402 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
3469a5ea 403 "gcc-4.9-libsanitizer-ustat.patch"
d6593070 404 "gcc-arm-bug-71399.patch"
e80514bc 405 "gcc-asan-missing-include.patch"
19d27131 406 "gcc-libvtv-runpath.patch"
809b0a90
EF
407 "gcc-fix-texi2pod.patch"))
408 (modules '((guix build utils)))
409 ;; This is required for building with glibc-2.26.
410 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
411 (snippet
6cbee49d
MW
412 '(begin
413 (for-each
414 (lambda (dir)
415 (substitute* (string-append "libgcc/config/"
416 dir "/linux-unwind.h")
417 (("struct ucontext") "ucontext_t")))
418 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
419 "pa" "sh" "tilepro" "xtensa"))
420 #t))))
19d27131
MC
421 ;; Override inherited texinfo-5 with latest version.
422 (native-inputs `(("perl" ,perl) ;for manpages
423 ("texinfo" ,texinfo)))))
571aa6cd 424
629f4d2e 425(define-public gcc-5
7912677c
LC
426 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
427 ;; them in a VPATH build.
7e35b9dd 428 (package (inherit gcc-4.9)
404e3d8b 429 (version "5.5.0")
60e2d5fe 430 (source (origin
7e35b9dd
LC
431 (method url-fetch)
432 (uri (string-append "mirror://gnu/gcc/gcc-"
404e3d8b 433 version "/gcc-" version ".tar.xz"))
7e35b9dd
LC
434 (sha256
435 (base32
404e3d8b 436 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
b810a850 437 (patches (search-patches "gcc-arm-bug-71399.patch"
1aef659e 438 "gcc-libsanitizer-ustat.patch"
b810a850 439 "gcc-strmov-store-file-names.patch"
d71d6fe8
MB
440 "gcc-5.0-libvtv-runpath.patch"
441 "gcc-5-source-date-epoch-1.patch"
19d27131 442 "gcc-5-source-date-epoch-2.patch"
066ccc2c
LC
443 "gcc-fix-texi2pod.patch"))
444 (modules '((guix build utils)))
445 (snippet
446 ;; Fix 'libcc1/configure' error when cross-compiling GCC.
447 ;; Without that, 'libcc1/configure' wrongfully determines that
448 ;; '-rdynamic' support is missing because $gcc_cv_objdump is
449 ;; empty:
450 ;;
451 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
452 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
6cbee49d
MW
453 '(begin
454 (substitute* "libcc1/configure"
455 (("\\$gcc_cv_objdump -T")
456 "$OBJDUMP_FOR_TARGET -T"))
457 #t))))
eb9696e7 458 (inputs
25bd7267
MB
459 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
460 ("isl" ,isl-0.18)
eb9696e7 461 ,@(package-inputs gcc-4.7)))))
60e2d5fe 462
e760ec41
LC
463(define-public gcc-6
464 (package
465 (inherit gcc-5)
8d65ae44 466 (version "6.5.0")
e760ec41
LC
467 (source (origin
468 (method url-fetch)
469 (uri (string-append "mirror://gnu/gcc/gcc-"
0dd87919 470 version "/gcc-" version ".tar.xz"))
e760ec41
LC
471 (sha256
472 (base32
8d65ae44
MB
473 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
474 (patches (search-patches "gcc-strmov-store-file-names.patch"
aace9be8
MB
475 "gcc-6-source-date-epoch-1.patch"
476 "gcc-6-source-date-epoch-2.patch"
8d65ae44 477 "gcc-5.0-libvtv-runpath.patch"))))
2b8d4ce8
EF
478 (inputs
479 `(("isl" ,isl)
91a56b4a
LC
480 ,@(package-inputs gcc-4.7)))
481
482 (native-search-paths
483 ;; We have to use 'CPATH' for GCC > 5, not 'C_INCLUDE_PATH' & co., due to
484 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129>.
485 (list (search-path-specification
486 (variable "CPATH")
487 (files '("include")))
488 (search-path-specification
489 (variable "LIBRARY_PATH")
490 (files '("lib" "lib64")))))))
2b8d4ce8 491
0c5658df
EF
492(define-public gcc-7
493 (package
494 (inherit gcc-6)
7570ec5a 495 (version "7.4.0")
0c5658df
EF
496 (source (origin
497 (method url-fetch)
498 (uri (string-append "mirror://gnu/gcc/gcc-"
2bccf1c0 499 version "/gcc-" version ".tar.xz"))
0c5658df
EF
500 (sha256
501 (base32
7570ec5a 502 "0lgy170b0pp60j9cczqkmaqyjjb584vfamj4c30swd7k0j6y5pgd"))
0c5658df 503 (patches (search-patches "gcc-strmov-store-file-names.patch"
35dadded
EF
504 "gcc-5.0-libvtv-runpath.patch"))))
505 (description
506 "GCC is the GNU Compiler Collection. It provides compiler front-ends
507for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
508It also includes runtime support libraries for these languages.")))
e760ec41 509
a1fa2691
MB
510(define-public gcc-8
511 (package
512 (inherit gcc-7)
60ce496a 513 (version "8.4.0")
a1fa2691
MB
514 (source (origin
515 (method url-fetch)
516 (uri (string-append "mirror://gnu/gcc/gcc-"
517 version "/gcc-" version ".tar.xz"))
518 (sha256
519 (base32
60ce496a 520 "1m1d3gfix56w4aq8myazzfffkl8bqcrx4jhhapnjf7qfs596w2p3"))
a1fa2691
MB
521 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
522 "gcc-5.0-libvtv-runpath.patch"))))))
523
bdfc3276
CD
524(define-public gcc-9
525 (package
526 (inherit gcc-8)
3dade1d5 527 (version "9.3.0")
bdfc3276
CD
528 (source (origin
529 (method url-fetch)
530 (uri (string-append "mirror://gnu/gcc/gcc-"
531 version "/gcc-" version ".tar.xz"))
532 (sha256
533 (base32
3dade1d5 534 "1la2yy27ziasyf0jvzk58y1i5b5bq2h176qil550bxhifs39gqbi"))
bdfc3276 535 (patches (search-patches "gcc-9-strmov-store-file-names.patch"
0e293f75 536 "gcc-9-asan-fix-limits-include.patch"
bdfc3276
CD
537 "gcc-5.0-libvtv-runpath.patch"))))))
538
ce362de8 539;; Note: When changing the default gcc version, update
cb4805e3
RW
540;; the gcc-toolchain-* definitions and the gfortran definition
541;; accordingly.
01e8263f 542(define-public gcc gcc-7)
eed67cbb 543
d0abf829
LC
544(define-public (make-libstdc++ gcc)
545 "Return a libstdc++ package based on GCC. The primary use case is when
546using compilers other than GCC."
547 (package
548 (inherit gcc)
549 (name "libstdc++")
550 (arguments
551 `(#:out-of-source? #t
552 #:phases (alist-cons-before
553 'configure 'chdir
554 (lambda _
eb8ea381
MW
555 (chdir "libstdc++-v3")
556 #t)
d0abf829
LC
557 %standard-phases)
558 #:configure-flags `("--disable-libstdcxx-pch"
559 ,(string-append "--with-gxx-include-dir="
560 (assoc-ref %outputs "out")
561 "/include"))))
562 (outputs '("out" "debug"))
563 (inputs '())
564 (native-inputs '())
565 (propagated-inputs '())
566 (synopsis "GNU C++ standard library")))
567
568(define-public libstdc++-4.9
569 (make-libstdc++ gcc-4.9))
570
2b6b6d13
RW
571(define (make-libiberty gcc)
572 "Return a libiberty package based on GCC."
573 (package
574 (inherit gcc)
575 (name "libiberty")
576 (arguments
577 `(#:out-of-source? #t
578 #:phases
579 (modify-phases %standard-phases
580 (add-before 'configure 'chdir
581 (lambda _
582 (chdir "libiberty")
583 #t))
584 (replace
585 'install
586 (lambda* (#:key outputs #:allow-other-keys)
587 (let* ((out (assoc-ref outputs "out"))
588 (lib (string-append out "/lib/"))
589 (include (string-append out "/include/")))
590 (mkdir-p lib)
591 (mkdir-p include)
592 (copy-file "libiberty.a"
593 (string-append lib "libiberty.a"))
594 (copy-file "../include/libiberty.h"
595 (string-append include "libiberty.h"))
596 #t))))))
597 (inputs '())
598 (outputs '("out"))
599 (native-inputs '())
600 (propagated-inputs '())
0f665134 601 (properties '())
2b6b6d13
RW
602 (synopsis "Collection of subroutines used by various GNU programs")))
603
604(define-public libiberty
605 (make-libiberty gcc))
606
009b53fd
LC
607(define* (custom-gcc gcc name languages
608 #:optional
609 (search-paths (package-native-search-paths gcc))
610 #:key (separate-lib-output? #t))
611 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
612as the 'native-search-paths' field."
fdd6c726
NK
613 (package (inherit gcc)
614 (name name)
c4df90a5
MW
615 (outputs (if separate-lib-output?
616 (package-outputs gcc)
617 (delete "lib" (package-outputs gcc))))
009b53fd 618 (native-search-paths search-paths)
fbeb92d7 619 (properties (alist-delete 'hidden? (package-properties gcc)))
fdd6c726
NK
620 (arguments
621 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
622 (guix build utils)
623 (ice-9 regex)
624 (srfi srfi-1)
625 (srfi srfi-26))
626 ,@(package-arguments gcc))
627 ((#:configure-flags flags)
628 `(cons (string-append "--enable-languages="
629 ,(string-join languages ","))
630 (remove (cut string-match "--enable-languages.*" <>)
82f145ef
RW
631 ,flags)))
632 ((#:phases phases)
633 `(modify-phases ,phases
634 (add-after 'install 'remove-broken-or-conflicting-files
635 (lambda* (#:key outputs #:allow-other-keys)
636 (for-each delete-file
637 (find-files (string-append (assoc-ref outputs "out") "/bin")
a1a3b25d 638 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
82f145ef 639 #t))))))))
fdd6c726 640
009b53fd
LC
641(define %generic-search-paths
642 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
643 ;; not considered "system headers", which means GCC can raise warnings for
644 ;; issues in those headers. 'CPATH' is the only one that works for
645 ;; front-ends not in the C family.
646 (list (search-path-specification
647 (variable "CPATH")
648 (files '("include")))
649 (search-path-specification
650 (variable "LIBRARY_PATH")
651 (files '("lib" "lib64")))))
652
fdd6c726 653(define-public gfortran-4.8
a7c75b8d
KH
654 (hidden-package
655 (custom-gcc gcc-4.8 "gfortran" '("fortran")
656 %generic-search-paths)))
fdd6c726 657
c69a8b7b 658(define-public gfortran-4.9
a7c75b8d
KH
659 (hidden-package
660 (custom-gcc gcc-4.9 "gfortran" '("fortran")
661 %generic-search-paths)))
c69a8b7b 662
ce54f5db 663(define-public gfortran-5
a7c75b8d
KH
664 (hidden-package
665 (custom-gcc gcc-5 "gfortran" '("fortran")
666 %generic-search-paths)))
ce54f5db 667
4b13e28a 668(define-public gfortran-6
a7c75b8d
KH
669 (hidden-package
670 (custom-gcc gcc-6 "gfortran" '("fortran")
671 %generic-search-paths)))
4b13e28a 672
90027924 673(define-public gfortran-7
a7c75b8d
KH
674 (hidden-package
675 (custom-gcc gcc-7 "gfortran" '("fortran")
676 %generic-search-paths)))
90027924 677
f66be84d 678(define-public gfortran-8
a7c75b8d
KH
679 (hidden-package
680 (custom-gcc gcc-8 "gfortran" '("fortran")
681 %generic-search-paths)))
a00a946a
LC
682
683(define-public gfortran-9
a7c75b8d
KH
684 (hidden-package
685 (custom-gcc gcc-9 "gfortran" '("fortran")
686 %generic-search-paths)))
f66be84d 687
eed67cbb 688(define-public gfortran
9af07624
LC
689 ;; Note: Update this when GCC changes! We cannot use
690 ;; (custom-gcc gcc "fortran" …) because that would lead to a package object
cb4805e3
RW
691 ;; that is not 'eq?' with GFORTRAN-5, and thus 'fold-packages' would
692 ;; report two gfortran@5 that are in fact identical.
01e8263f 693 gfortran-7)
eed67cbb 694
76d2b9a2
JL
695(define-public libgccjit
696 (package
697 (inherit gcc-9)
698 (name "libgccjit")
699 (outputs (delete "lib" (package-outputs gcc)))
700 (properties (alist-delete 'hidden? (package-properties gcc)))
701 (arguments
702 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
703 (guix build utils)
704 (ice-9 regex)
705 (srfi srfi-1)
706 (srfi srfi-26))
707 ,@(package-arguments gcc))
708 ((#:configure-flags flags)
709 `(append `("--enable-host-shared"
710 ,(string-append "--enable-languages=jit"))
711 (remove (cut string-match "--enable-languages.*" <>)
712 ,flags)))
713 ((#:phases phases)
714 `(modify-phases ,phases
715 (add-after 'install 'remove-broken-or-conflicting-files
716 (lambda* (#:key outputs #:allow-other-keys)
717 (for-each delete-file
718 (find-files (string-append (assoc-ref outputs "out") "/bin")
719 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
720 #t))))))))
721
722
c8732e19
EF
723(define-public gccgo-4.9
724 (custom-gcc gcc-4.9 "gccgo" '("go")
009b53fd 725 %generic-search-paths
c4df90a5
MW
726 ;; Suppress the separate "lib" output, because otherwise the
727 ;; "lib" and "out" outputs would refer to each other, creating
728 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
729 #:separate-lib-output? #f))
fdd6c726
NK
730
731(define-public gcc-objc-4.8
009b53fd
LC
732 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
733 (list (search-path-specification
734 (variable "OBJC_INCLUDE_PATH")
735 (files '("include")))
736 (search-path-specification
737 (variable "LIBRARY_PATH")
738 (files '("lib" "lib64"))))))
fdd6c726 739
2d69c161
RW
740(define-public gcc-objc-4.9
741 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
742 (list (search-path-specification
743 (variable "OBJC_INCLUDE_PATH")
744 (files '("include")))
745 (search-path-specification
746 (variable "LIBRARY_PATH")
747 (files '("lib" "lib64"))))))
748
f51d01e1
EF
749(define-public gcc-objc-5
750 (custom-gcc gcc-5 "gcc-objc" '("objc")
751 (list (search-path-specification
752 (variable "OBJC_INCLUDE_PATH")
753 (files '("include")))
754 (search-path-specification
755 (variable "LIBRARY_PATH")
756 (files '("lib" "lib64"))))))
757
4072c10b
EF
758(define-public gcc-objc-6
759 (custom-gcc gcc-6 "gcc-objc" '("objc")
760 (list (search-path-specification
761 (variable "OBJC_INCLUDE_PATH")
762 (files '("include")))
763 (search-path-specification
764 (variable "LIBRARY_PATH")
765 (files '("lib" "lib64"))))))
ce9afe2b
EF
766
767(define-public gcc-objc-7
768 (custom-gcc gcc-7 "gcc-objc" '("objc")
769 (list (search-path-specification
770 (variable "OBJC_INCLUDE_PATH")
771 (files '("include")))
772 (search-path-specification
773 (variable "LIBRARY_PATH")
774 (files '("lib" "lib64"))))))
4072c10b 775
f66be84d
EB
776(define-public gcc-objc-8
777 (custom-gcc gcc-8 "gcc-objc" '("objc")
778 (list (search-path-specification
779 (variable "OBJC_INCLUDE_PATH")
780 (files '("include")))
781 (search-path-specification
782 (variable "LIBRARY_PATH")
783 (files '("lib" "lib64"))))))
784
01e8263f 785(define-public gcc-objc gcc-objc-7)
8b196ad2 786
fdd6c726 787(define-public gcc-objc++-4.8
009b53fd
LC
788 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
789 (list (search-path-specification
790 (variable "OBJCPLUS_INCLUDE_PATH")
791 (files '("include")))
792 (search-path-specification
793 (variable "LIBRARY_PATH")
794 (files '("lib" "lib64"))))))
fdd6c726 795
a5948c0d
RW
796(define-public gcc-objc++-4.9
797 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
798 (list (search-path-specification
799 (variable "OBJCPLUS_INCLUDE_PATH")
800 (files '("include")))
009b53fd
LC
801 (search-path-specification
802 (variable "LIBRARY_PATH")
803 (files '("lib" "lib64"))))))
fdd6c726 804
ed8cdab8
EF
805(define-public gcc-objc++-5
806 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
807 (list (search-path-specification
808 (variable "OBJCPLUS_INCLUDE_PATH")
809 (files '("include")))
810 (search-path-specification
811 (variable "LIBRARY_PATH")
812 (files '("lib" "lib64"))))))
813
7a7c6308
EF
814(define-public gcc-objc++-6
815 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
816 (list (search-path-specification
817 (variable "OBJCPLUS_INCLUDE_PATH")
818 (files '("include")))
819 (search-path-specification
820 (variable "LIBRARY_PATH")
821 (files '("lib" "lib64"))))))
822
e05f8d2f
EF
823(define-public gcc-objc++-7
824 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
825 (list (search-path-specification
826 (variable "OBJCPLUS_INCLUDE_PATH")
827 (files '("include")))
828 (search-path-specification
829 (variable "LIBRARY_PATH")
830 (files '("lib" "lib64"))))))
831
f66be84d
EB
832(define-public gcc-objc++-8
833 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
834 (list (search-path-specification
835 (variable "OBJCPLUS_INCLUDE_PATH")
836 (files '("include")))
837 (search-path-specification
838 (variable "LIBRARY_PATH")
839 (files '("lib" "lib64"))))))
840
01e8263f 841(define-public gcc-objc++ gcc-objc++-7)
987a1183 842
98b385d1
LC
843(define (make-libstdc++-doc gcc)
844 "Return a package with the libstdc++ documentation for GCC."
845 (package
846 (inherit gcc)
847 (name "libstdc++-doc")
848 (version (package-version gcc))
849 (synopsis "GNU libstdc++ documentation")
850 (outputs '("out"))
851 (native-inputs `(("doxygen" ,doxygen)
852 ("texinfo" ,texinfo)
853 ("libxml2" ,libxml2)
854 ("libxslt" ,libxslt)
855 ("docbook-xml" ,docbook-xml)
856 ("docbook-xsl" ,docbook-xsl)
857 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
858 (inputs '())
859 (propagated-inputs '())
860 (arguments
861 '(#:out-of-source? #t
862 #:tests? #f ;it's just documentation
863 #:phases (modify-phases %standard-phases
864 (add-before 'configure 'chdir
865 (lambda _
61a815eb
MW
866 (chdir "libstdc++-v3")
867 #t))
98b385d1
LC
868 (add-before 'configure 'set-xsl-directory
869 (lambda* (#:key inputs #:allow-other-keys)
870 (let ((docbook (assoc-ref inputs "docbook-xsl")))
871 (substitute* (find-files "doc"
872 "^Makefile\\.in$")
873 (("@XSL_STYLE_DIR@")
874 (string-append
875 docbook "/xml/xsl/"
61a815eb
MW
876 (strip-store-file-name docbook))))
877 #t)))
98b385d1
LC
878 (replace 'build
879 (lambda _
880 ;; XXX: There's also a 'doc-info' target, but it
881 ;; relies on docbook2X, which itself relies on
882 ;; DocBook 4.1.2, which is not really usable
883 ;; (lacks a catalog.xml.)
61a815eb
MW
884 (invoke "make"
885 "doc-html"
886 "doc-man")))
98b385d1
LC
887 (replace 'install
888 (lambda* (#:key outputs #:allow-other-keys)
889 (let ((out (assoc-ref outputs "out")))
61a815eb
MW
890 (invoke "make"
891 "doc-install-html"
798591b6
LC
892 "doc-install-man")))))))
893 (properties (alist-delete 'hidden? (package-properties gcc)))))
98b385d1 894
629f4d2e
MW
895(define-public libstdc++-doc-5
896 (make-libstdc++-doc gcc-5))
98b385d1 897
e7313ae2
LC
898(define-public libstdc++-doc-9
899 (make-libstdc++-doc gcc-9))
900
832abc76
LC
901(define-public isl
902 (package
903 (name "isl")
8449cc13 904 (version "0.21")
832abc76
LC
905 (source (origin
906 (method url-fetch)
907 (uri (list (string-append
590a4904 908 "http://isl.gforge.inria.fr/isl-"
832abc76
LC
909 version
910 ".tar.bz2")
911 (string-append %gcc-infrastructure
9f1da6ce 912 name "-" version ".tar.bz2")))
832abc76
LC
913 (sha256
914 (base32
8449cc13 915 "0ng8l3q1px9lkzb44nxnzhh6fhdbclrwng9xs2v9m8yii8gs336i"))))
832abc76
LC
916 (build-system gnu-build-system)
917 (inputs `(("gmp" ,gmp)))
590a4904 918 (home-page "http://isl.gforge.inria.fr/")
832abc76 919 (synopsis
9e771e3b
LC
920 "Manipulating sets and relations of integer points \
921bounded by linear constraints")
832abc76
LC
922 (description
923 "isl is a library for manipulating sets and relations of integer points
35b9e423 924bounded by linear constraints. Supported operations on sets include
832abc76
LC
925intersection, union, set difference, emptiness check, convex hull, (integer)
926affine hull, integer projection, computing the lexicographic minimum using
927parametric integer programming, coalescing and parametric vertex
35b9e423 928enumeration. It also includes an ILP solver based on generalized basis
832abc76
LC
929reduction, transitive closures on maps (which may encode infinite graphs),
930dependence analysis and bounds on piecewise step-polynomials.")
931 (license lgpl2.1+)))
932
25bd7267
MB
933(define-public isl-0.18
934 (package
935 (inherit isl)
936 (version "0.18")
937 (source (origin
938 (method url-fetch)
939 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
940 version ".tar.bz2")
941 (string-append %gcc-infrastructure
9f1da6ce 942 "isl-" version ".tar.bz2")))
25bd7267
MB
943 (sha256
944 (base32
945 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
946
ab53bdf0
EF
947(define-public isl-0.11
948 (package
949 (inherit isl)
950 (name "isl")
951 (version "0.11.1")
952 (source (origin
953 (method url-fetch)
954 (uri (list (string-append
955 "http://isl.gforge.inria.fr/isl-"
956 version
957 ".tar.bz2")
958 (string-append %gcc-infrastructure
9f1da6ce 959 name "-" version ".tar.bz2")))
ab53bdf0
EF
960 (sha256
961 (base32
962 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
963 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
964
832abc76
LC
965(define-public cloog
966 (package
967 (name "cloog")
968 (version "0.18.0")
969 (source
970 (origin
971 (method url-fetch)
972 (uri (list (string-append
973 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
974 version
975 ".tar.gz")
976 (string-append %gcc-infrastructure
977 name "-" version ".tar.gz")))
978 (sha256
979 (base32
980 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
981 (file-name (string-append name "-" version ".tar.gz"))))
982 (build-system gnu-build-system)
983 (inputs `(("gmp" ,gmp)
ab53bdf0 984 ("isl" ,isl-0.11)))
832abc76
LC
985 (arguments '(#:configure-flags '("--with-isl=system")))
986 (home-page "http://www.cloog.org/")
9e771e3b 987 (synopsis "Library to generate code for scanning Z-polyhedra")
832abc76
LC
988 (description
989 "CLooG is a free software library to generate code for scanning
990Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
991reaches each integral point of one or more parameterized polyhedra.
992CLooG has been originally written to solve the code generation problem
993for optimizing compilers based on the polytope model. Nevertheless it
994is used now in various area e.g., to build control automata for
995high-level synthesis or to find the best polynomial approximation of a
996function. CLooG may help in any situation where scanning polyhedra
997matters. While the user has full control on generated code quality,
998CLooG is designed to avoid control overhead and to produce a very
999effective code.")
1000 (license gpl2+)))
5c126b64 1001
50c7a1e2
LC
1002(define-public gnu-c-manual
1003 (package
1004 (name "gnu-c-manual")
d35f8c7c 1005 (version "0.2.5")
50c7a1e2
LC
1006 (source (origin
1007 (method url-fetch)
1008 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
1009 version ".tar.gz"))
1010 (sha256
1011 (base32
d35f8c7c 1012 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
50c7a1e2
LC
1013 (build-system gnu-build-system)
1014 (native-inputs `(("texinfo" ,texinfo)))
1015 (arguments
1016 '(#:phases (modify-phases %standard-phases
1017 (delete 'configure)
1018 (delete 'check)
1019 (replace 'build
1020 (lambda _
9feb4fd5
MW
1021 (invoke "make"
1022 "gnu-c-manual.info"
1023 "gnu-c-manual.html")))
50c7a1e2
LC
1024 (replace 'install
1025 (lambda* (#:key outputs #:allow-other-keys)
1026 (let* ((out (assoc-ref outputs "out"))
1027 (info (string-append out "/share/info"))
1028 (html (string-append
1029 out "/share/doc/gnu-c-manual")))
1030 (mkdir-p info)
1031 (mkdir-p html)
1032
1033 (for-each (lambda (file)
1034 (copy-file file
1035 (string-append info "/"
1036 file)))
1037 (find-files "." "\\.info(-[0-9])?$"))
1038 (for-each (lambda (file)
1039 (copy-file file
1040 (string-append html "/"
1041 file)))
1042 (find-files "." "\\.html$"))
1043 #t))))))
1044 (synopsis "Reference manual for the C programming language")
1045 (description
1046 "This is a reference manual for the C programming language, as
1047implemented by the GNU C Compiler (gcc). As a reference, it is not intended
1048to be a tutorial of the language. Rather, it outlines all of the constructs
1049of the language. Library functions are not included.")
6fd52309 1050 (home-page "https://www.gnu.org/software/gnu-c-manual/")
50c7a1e2 1051 (license fdl1.3+)))