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