gnu: texinfo@5: Fix FTBFS with Perl >= 5.28.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
CommitLineData
e9c0b944 1;;; GNU Guix --- Functional package management for GNU
d6593070 2;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
f888d5bb 3;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
9117448e 4;;; Copyright © 2014, 2015, 2016, 2017 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))))))
e9c0b944 142 (package
de1d41f9 143 (name "gcc")
d2e2f142 144 (version "4.7.4")
de1d41f9
LC
145 (source (origin
146 (method url-fetch)
147 (uri (string-append "mirror://gnu/gcc/gcc-"
148 version "/gcc-" version ".tar.bz2"))
149 (sha256
150 (base32
19d27131 151 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
921f8e63
MW
152 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
153 "gcc-fix-texi2pod.patch"))))
de1d41f9 154 (build-system gnu-build-system)
84e6756c
LC
155
156 ;; Separate out the run-time support libraries because all the
157 ;; dynamic-linked objects depend on it.
9063ef0f
LC
158 (outputs '("out" ;commands, etc. (60+ MiB)
159 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
160 "debug")) ;debug symbols of run-time libraries
84e6756c 161
de1d41f9
LC
162 (inputs `(("gmp" ,gmp)
163 ("mpfr" ,mpfr)
164 ("mpc" ,mpc)
de1d41f9
LC
165 ("libelf" ,libelf)
166 ("zlib" ,zlib)))
c8ebc821 167
868c13c5 168 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
72246dc0 169 ;; Newer texinfos fail to build the manual, so we use an older one.
19d27131
MC
170 (native-inputs `(("perl" ,perl) ;for manpages
171 ("texinfo" ,texinfo-5)))
c8ebc821 172
de1d41f9
LC
173 (arguments
174 `(#:out-of-source? #t
de1d41f9
LC
175 #:configure-flags ,(configure-flags)
176 #:make-flags
fd0b2766
LC
177 ;; None of the flags below are needed when doing a Canadian cross.
178 ;; TODO: Simplify this.
179 ,(if (%current-target-system)
180 (if stripped?
181 ''("CFLAGS=-g0 -O2")
182 ''())
183 `(let* ((libc (assoc-ref %build-inputs "libc"))
184 (libc-native (or (assoc-ref %build-inputs "libc-native")
185 libc)))
186 `(,@(if libc
187 (list (string-append "LDFLAGS_FOR_TARGET="
188 "-B" libc "/lib "
189 "-Wl,-dynamic-linker "
190 "-Wl," libc
191 ,(glibc-dynamic-linker)))
192 '())
193
194 ;; Native programs like 'genhooks' also need that right.
195 ,(string-append "LDFLAGS="
196 "-Wl,-rpath=" libc-native "/lib "
197 "-Wl,-dynamic-linker "
198 "-Wl," libc-native ,(glibc-dynamic-linker))
199 ,(string-append "BOOT_CFLAGS=-O2 "
200 ,(if stripped? "-g0" "-g")))))
de1d41f9
LC
201
202 #:tests? #f
dfc8bb20 203
de1d41f9 204 #:phases
ba81ca6a
TGR
205 (modify-phases %standard-phases
206 (add-before 'configure 'pre-configure
207 (lambda* (#:key inputs outputs #:allow-other-keys)
208 (let ((libdir ,(libdir))
209 (libc (assoc-ref inputs "libc")))
210 (when libc
211 ;; The following is not performed for `--without-headers'
212 ;; cross-compiler builds.
213
214 ;; Join multi-line definitions of GLIBC_DYNAMIC_LINKER* into a
215 ;; single line, to allow the next step to work properly.
216 (for-each
217 (lambda (x)
218 (substitute* (find-files "gcc/config"
219 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
220 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
221 line)))
222 '(1 2 3))
223
224 ;; Fix the dynamic linker's file name.
225 (substitute* (find-files "gcc/config"
226 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
227 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
228 _ gnu-user suffix)
229 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
230 gnu-user suffix
231 (string-append libc ,(glibc-dynamic-linker)))))
232
233 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
234 ;; `crt{begin,end}.o', which come with GCC.
235 (substitute* (find-files "gcc/config"
236 "^gnu-user.*\\.h$")
237 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
238 ;; Help libgcc_s.so be found (see also below.) Always use
239 ;; '-lgcc_s' so that libgcc_s.so is always found by those
240 ;; programs that use 'pthread_cancel' (glibc dlopens
241 ;; libgcc_s.so when pthread_cancel support is needed, but
242 ;; having it in the application's RUNPATH isn't enough; see
243 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
244 ;;
245 ;; NOTE: The '-lgcc_s' added below needs to be removed in a
246 ;; later phase of %gcc-static. If you change the string
247 ;; below, make sure to update the relevant code in
248 ;; %gcc-static package as needed.
249 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
81197492 250\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
ba81ca6a
TGR
251 libc libc libdir suffix))
252 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
253 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
e9c0b944 254#define STANDARD_STARTFILE_PREFIX_2 \"\"
06213498 255~a"
ba81ca6a
TGR
256 libc line)))
257
258 ;; The rs6000 (a.k.a. powerpc) config in GCC does not use
259 ;; GNU_USER_* defines. Do the above for this case.
260 (substitute*
261 "gcc/config/rs6000/sysv4.h"
262 (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
263 (format #f "#define LIB_LINUX_SPEC \
fc649d0a 264\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
ba81ca6a
TGR
265 libc libc libdir suffix))
266 (("#define STARTFILE_LINUX_SPEC.*$" line)
267 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
fc649d0a
CSLL
268#define STANDARD_STARTFILE_PREFIX_2 \"\"
269~a"
ba81ca6a
TGR
270 libc line))))
271
272 ;; Don't retain a dependency on the build-time sed.
273 (substitute* "fixincludes/fixincl.x"
274 (("static char const sed_cmd_z\\[\\] =.*;")
275 "static char const sed_cmd_z[] = \"sed\";"))
276
277 ;; Aarch64 support didn't land in GCC until the 4.8 series.
278 (when (file-exists? "gcc/config/aarch64")
279 ;; Force Aarch64 libdir to be /lib and not /lib64
280 (substitute* "gcc/config/aarch64/t-aarch64-linux"
281 (("lib64") "lib")))
282
283 (when (file-exists? "libbacktrace")
284 ;; GCC 4.8+ comes with libbacktrace. By default it builds
285 ;; with -Werror, which fails with a -Wcast-qual error in glibc
286 ;; 2.21's stdlib-bsearch.h. Remove -Werror.
287 (substitute* "libbacktrace/configure"
288 (("WARN_FLAGS=(.*)-Werror" _ flags)
289 (string-append "WARN_FLAGS=" flags)))
290
291 (when (file-exists? "libsanitizer/libbacktrace")
292 ;; Same in libsanitizer's bundled copy (!) found in 4.9+.
293 (substitute* "libsanitizer/libbacktrace/Makefile.in"
294 (("-Werror")
295 ""))))
296
297 ;; Add a RUNPATH to libstdc++.so so that it finds libgcc_s.
298 ;; See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32354>
299 ;; and <http://bugs.gnu.org/20358>.
300 (substitute* "libstdc++-v3/src/Makefile.in"
301 (("^OPT_LDFLAGS = ")
302 "OPT_LDFLAGS = -Wl,-rpath=$(libdir) "))
303
304 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
305 ;; circularity between "out" and "lib". (Note:
306 ;; --with-python-dir is useless because it imposes $(prefix) as
307 ;; the parent directory.)
308 (substitute* "libstdc++-v3/python/Makefile.in"
309 (("pythondir = .*$")
310 (string-append "pythondir = " libdir "/share"
311 "/gcc-$(gcc_version)/python\n")))
312
313 ;; Avoid another circularity between the outputs: this #define
314 ;; ends up in auto-host.h in the "lib" output, referring to
315 ;; "out". (This variable is used to augment cpp's search path,
316 ;; but there's nothing useful to look for here.)
317 (substitute* "gcc/config.in"
318 (("PREFIX_INCLUDE_DIR")
319 "PREFIX_INCLUDE_DIR_isnt_necessary_here"))
320 #t)))
321
322 (add-after 'configure 'post-configure
323 (lambda _
324 ;; Don't store configure flags, to avoid retaining references to
325 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
326 (substitute* "Makefile"
327 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
328 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n"))
329 #t)))))
de1d41f9
LC
330
331 (native-search-paths
009b53fd
LC
332 ;; Use the language-specific variables rather than 'CPATH' because they
333 ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'.
334 ;; The intent is to allow headers that are in the search path to be
335 ;; treated as "system headers" (headers exempt from warnings) just like
336 ;; the typical /usr/include headers on an FHS system.
de1d41f9 337 (list (search-path-specification
009b53fd
LC
338 (variable "C_INCLUDE_PATH")
339 (files '("include")))
340 (search-path-specification
341 (variable "CPLUS_INCLUDE_PATH")
af070955 342 (files '("include")))
de1d41f9
LC
343 (search-path-specification
344 (variable "LIBRARY_PATH")
af070955 345 (files '("lib" "lib64")))))
de1d41f9
LC
346
347 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
348 (synopsis "GNU Compiler Collection")
349 (description
a22dc0c4
LC
350 "GCC is the GNU Compiler Collection. It provides compiler front-ends
351for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
79c311b8 352Go. It also includes runtime support libraries for these languages.")
de1d41f9 353 (license gpl3+)
721d7a69 354 (supported-systems (delete "aarch64-linux" %supported-systems))
6fd52309 355 (home-page "https://gcc.gnu.org/"))))
832abc76 356
3b401612 357(define-public gcc-4.8
3b401612 358 (package (inherit gcc-4.7)
ab5f49cf 359 (version "4.8.5")
3b401612 360 (source (origin
7e35b9dd
LC
361 (method url-fetch)
362 (uri (string-append "mirror://gnu/gcc/gcc-"
363 version "/gcc-" version ".tar.bz2"))
364 (sha256
365 (base32
ab5f49cf 366 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
19d27131 367 (patches (search-patches "gcc-arm-link-spec-fix.patch"
0b93d04a 368 "gcc-4.8-libsanitizer-fix.patch"
8e7ec29d 369 "gcc-asan-missing-include.patch"
7bbc708a
EF
370 "gcc-fix-texi2pod.patch"))
371 (modules '((guix build utils)))
372 ;; This is required for building with glibc-2.26.
373 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
374 (snippet
6cbee49d
MW
375 '(begin
376 (for-each
377 (lambda (dir)
378 (substitute* (string-append "libgcc/config/"
379 dir "/linux-unwind.h")
380 (("struct ucontext") "ucontext_t")))
381 '("aarch64" "alpha" "bfin" "i386" "m68k"
382 "pa" "sh" "tilepro" "xtensa"))
383 #t))))
2b8d4ce8
EF
384 (supported-systems %supported-systems)
385 (inputs
ab53bdf0 386 `(("isl" ,isl-0.11)
2b8d4ce8
EF
387 ("cloog" ,cloog)
388 ,@(package-inputs gcc-4.7)))))
3b401612 389
571aa6cd 390(define-public gcc-4.9
dd4efefd 391 (package (inherit gcc-4.8)
b0847497 392 (version "4.9.4")
571aa6cd 393 (source (origin
7e35b9dd
LC
394 (method url-fetch)
395 (uri (string-append "mirror://gnu/gcc/gcc-"
396 version "/gcc-" version ".tar.bz2"))
397 (sha256
398 (base32
b0847497 399 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
d6593070
LC
400 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
401 "gcc-arm-bug-71399.patch"
e80514bc 402 "gcc-asan-missing-include.patch"
19d27131 403 "gcc-libvtv-runpath.patch"
809b0a90
EF
404 "gcc-fix-texi2pod.patch"))
405 (modules '((guix build utils)))
406 ;; This is required for building with glibc-2.26.
407 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
408 (snippet
6cbee49d
MW
409 '(begin
410 (for-each
411 (lambda (dir)
412 (substitute* (string-append "libgcc/config/"
413 dir "/linux-unwind.h")
414 (("struct ucontext") "ucontext_t")))
415 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
416 "pa" "sh" "tilepro" "xtensa"))
417 #t))))
19d27131
MC
418 ;; Override inherited texinfo-5 with latest version.
419 (native-inputs `(("perl" ,perl) ;for manpages
420 ("texinfo" ,texinfo)))))
571aa6cd 421
629f4d2e 422(define-public gcc-5
7912677c
LC
423 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
424 ;; them in a VPATH build.
7e35b9dd 425 (package (inherit gcc-4.9)
404e3d8b 426 (version "5.5.0")
60e2d5fe 427 (source (origin
7e35b9dd
LC
428 (method url-fetch)
429 (uri (string-append "mirror://gnu/gcc/gcc-"
404e3d8b 430 version "/gcc-" version ".tar.xz"))
7e35b9dd
LC
431 (sha256
432 (base32
404e3d8b 433 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
b810a850 434 (patches (search-patches "gcc-arm-bug-71399.patch"
1aef659e 435 "gcc-libsanitizer-ustat.patch"
b810a850 436 "gcc-strmov-store-file-names.patch"
d71d6fe8
MB
437 "gcc-5.0-libvtv-runpath.patch"
438 "gcc-5-source-date-epoch-1.patch"
19d27131 439 "gcc-5-source-date-epoch-2.patch"
066ccc2c
LC
440 "gcc-fix-texi2pod.patch"))
441 (modules '((guix build utils)))
442 (snippet
443 ;; Fix 'libcc1/configure' error when cross-compiling GCC.
444 ;; Without that, 'libcc1/configure' wrongfully determines that
445 ;; '-rdynamic' support is missing because $gcc_cv_objdump is
446 ;; empty:
447 ;;
448 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
449 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
6cbee49d
MW
450 '(begin
451 (substitute* "libcc1/configure"
452 (("\\$gcc_cv_objdump -T")
453 "$OBJDUMP_FOR_TARGET -T"))
454 #t))))
eb9696e7 455 (inputs
25bd7267
MB
456 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
457 ("isl" ,isl-0.18)
eb9696e7 458 ,@(package-inputs gcc-4.7)))))
60e2d5fe 459
e760ec41
LC
460(define-public gcc-6
461 (package
462 (inherit gcc-5)
0dd87919 463 (version "6.4.0")
e760ec41
LC
464 (source (origin
465 (method url-fetch)
466 (uri (string-append "mirror://gnu/gcc/gcc-"
0dd87919 467 version "/gcc-" version ".tar.xz"))
e760ec41
LC
468 (sha256
469 (base32
0dd87919 470 "1m0lr7938lw5d773dkvwld90hjlcq2282517d1gwvrfzmwgg42w5"))
6149fdfb 471 (patches (search-patches "gcc-libsanitizer-fix.patch"
45c78bf9 472 "gcc-libsanitizer-ustat.patch"
6149fdfb 473 "gcc-strmov-store-file-names.patch"
aace9be8
MB
474 "gcc-6-source-date-epoch-1.patch"
475 "gcc-6-source-date-epoch-2.patch"
6149fdfb
EF
476 "gcc-5.0-libvtv-runpath.patch"))
477 (modules '((guix build utils)))
478 ;; This is required for building with glibc-2.26.
479 ;; This can be removed when gcc-6.5.0 is released.
480 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
481 (snippet
6cbee49d
MW
482 '(begin
483 (for-each
484 (lambda (dir)
485 (substitute* (string-append "libgcc/config/"
486 dir "/linux-unwind.h")
487 (("struct ucontext") "ucontext_t")))
488 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
489 "pa" "sh" "tilepro" "xtensa"))
490 #t))))
2b8d4ce8
EF
491 (inputs
492 `(("isl" ,isl)
91a56b4a
LC
493 ,@(package-inputs gcc-4.7)))
494
495 (native-search-paths
496 ;; We have to use 'CPATH' for GCC > 5, not 'C_INCLUDE_PATH' & co., due to
497 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129>.
498 (list (search-path-specification
499 (variable "CPATH")
500 (files '("include")))
501 (search-path-specification
502 (variable "LIBRARY_PATH")
503 (files '("lib" "lib64")))))))
2b8d4ce8 504
0c5658df
EF
505(define-public gcc-7
506 (package
507 (inherit gcc-6)
f888d5bb 508 (version "7.3.0")
0c5658df
EF
509 (source (origin
510 (method url-fetch)
511 (uri (string-append "mirror://gnu/gcc/gcc-"
2bccf1c0 512 version "/gcc-" version ".tar.xz"))
0c5658df
EF
513 (sha256
514 (base32
f888d5bb 515 "0p71bij6bfhzyrs8676a8jmpjsfz392s2rg862sdnsk30jpacb43"))
0c5658df 516 (patches (search-patches "gcc-strmov-store-file-names.patch"
45c78bf9 517 "gcc-libsanitizer-ustat.patch"
35dadded
EF
518 "gcc-5.0-libvtv-runpath.patch"))))
519 (description
520 "GCC is the GNU Compiler Collection. It provides compiler front-ends
521for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
522It also includes runtime support libraries for these languages.")))
e760ec41 523
a1fa2691
MB
524(define-public gcc-8
525 (package
526 (inherit gcc-7)
74a4fa50 527 (version "8.2.0")
a1fa2691
MB
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
74a4fa50 534 "10007smilswiiv2ymazr3b6x2i933c0ycxrr529zh4r6p823qv0r"))
a1fa2691
MB
535 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
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.
b810a850 541(define-public gcc gcc-5)
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)
fdd6c726
NK
617 (arguments
618 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
619 (guix build utils)
620 (ice-9 regex)
621 (srfi srfi-1)
622 (srfi srfi-26))
623 ,@(package-arguments gcc))
624 ((#:configure-flags flags)
625 `(cons (string-append "--enable-languages="
626 ,(string-join languages ","))
627 (remove (cut string-match "--enable-languages.*" <>)
82f145ef
RW
628 ,flags)))
629 ((#:phases phases)
630 `(modify-phases ,phases
631 (add-after 'install 'remove-broken-or-conflicting-files
632 (lambda* (#:key outputs #:allow-other-keys)
633 (for-each delete-file
634 (find-files (string-append (assoc-ref outputs "out") "/bin")
a1a3b25d 635 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
82f145ef 636 #t))))))))
fdd6c726 637
009b53fd
LC
638(define %generic-search-paths
639 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
640 ;; not considered "system headers", which means GCC can raise warnings for
641 ;; issues in those headers. 'CPATH' is the only one that works for
642 ;; front-ends not in the C family.
643 (list (search-path-specification
644 (variable "CPATH")
645 (files '("include")))
646 (search-path-specification
647 (variable "LIBRARY_PATH")
648 (files '("lib" "lib64")))))
649
fdd6c726 650(define-public gfortran-4.8
009b53fd
LC
651 (custom-gcc gcc-4.8 "gfortran" '("fortran")
652 %generic-search-paths))
fdd6c726 653
c69a8b7b 654(define-public gfortran-4.9
009b53fd
LC
655 (custom-gcc gcc-4.9 "gfortran" '("fortran")
656 %generic-search-paths))
c69a8b7b 657
ce54f5db
RW
658(define-public gfortran-5
659 (custom-gcc gcc-5 "gfortran" '("fortran")
660 %generic-search-paths))
661
4b13e28a
EF
662(define-public gfortran-6
663 (custom-gcc gcc-6 "gfortran" '("fortran")
664 %generic-search-paths))
665
90027924
EF
666(define-public gfortran-7
667 (custom-gcc gcc-7 "gfortran" '("fortran")
668 %generic-search-paths))
669
eed67cbb 670(define-public gfortran
9af07624
LC
671 ;; Note: Update this when GCC changes! We cannot use
672 ;; (custom-gcc gcc "fortran" …) because that would lead to a package object
cb4805e3
RW
673 ;; that is not 'eq?' with GFORTRAN-5, and thus 'fold-packages' would
674 ;; report two gfortran@5 that are in fact identical.
675 gfortran-5)
eed67cbb 676
c8732e19
EF
677(define-public gccgo-4.9
678 (custom-gcc gcc-4.9 "gccgo" '("go")
009b53fd 679 %generic-search-paths
c4df90a5
MW
680 ;; Suppress the separate "lib" output, because otherwise the
681 ;; "lib" and "out" outputs would refer to each other, creating
682 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
683 #:separate-lib-output? #f))
fdd6c726
NK
684
685(define-public gcc-objc-4.8
009b53fd
LC
686 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
687 (list (search-path-specification
688 (variable "OBJC_INCLUDE_PATH")
689 (files '("include")))
690 (search-path-specification
691 (variable "LIBRARY_PATH")
692 (files '("lib" "lib64"))))))
fdd6c726 693
2d69c161
RW
694(define-public gcc-objc-4.9
695 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
696 (list (search-path-specification
697 (variable "OBJC_INCLUDE_PATH")
698 (files '("include")))
699 (search-path-specification
700 (variable "LIBRARY_PATH")
701 (files '("lib" "lib64"))))))
702
f51d01e1
EF
703(define-public gcc-objc-5
704 (custom-gcc gcc-5 "gcc-objc" '("objc")
705 (list (search-path-specification
706 (variable "OBJC_INCLUDE_PATH")
707 (files '("include")))
708 (search-path-specification
709 (variable "LIBRARY_PATH")
710 (files '("lib" "lib64"))))))
711
4072c10b
EF
712(define-public gcc-objc-6
713 (custom-gcc gcc-6 "gcc-objc" '("objc")
714 (list (search-path-specification
715 (variable "OBJC_INCLUDE_PATH")
716 (files '("include")))
717 (search-path-specification
718 (variable "LIBRARY_PATH")
719 (files '("lib" "lib64"))))))
ce9afe2b
EF
720
721(define-public gcc-objc-7
722 (custom-gcc gcc-7 "gcc-objc" '("objc")
723 (list (search-path-specification
724 (variable "OBJC_INCLUDE_PATH")
725 (files '("include")))
726 (search-path-specification
727 (variable "LIBRARY_PATH")
728 (files '("lib" "lib64"))))))
4072c10b 729
14728ab7 730(define-public gcc-objc gcc-objc-5)
8b196ad2 731
fdd6c726 732(define-public gcc-objc++-4.8
009b53fd
LC
733 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
734 (list (search-path-specification
735 (variable "OBJCPLUS_INCLUDE_PATH")
736 (files '("include")))
737 (search-path-specification
738 (variable "LIBRARY_PATH")
739 (files '("lib" "lib64"))))))
fdd6c726 740
a5948c0d
RW
741(define-public gcc-objc++-4.9
742 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
743 (list (search-path-specification
744 (variable "OBJCPLUS_INCLUDE_PATH")
745 (files '("include")))
009b53fd
LC
746 (search-path-specification
747 (variable "LIBRARY_PATH")
748 (files '("lib" "lib64"))))))
fdd6c726 749
ed8cdab8
EF
750(define-public gcc-objc++-5
751 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
752 (list (search-path-specification
753 (variable "OBJCPLUS_INCLUDE_PATH")
754 (files '("include")))
755 (search-path-specification
756 (variable "LIBRARY_PATH")
757 (files '("lib" "lib64"))))))
758
7a7c6308
EF
759(define-public gcc-objc++-6
760 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
761 (list (search-path-specification
762 (variable "OBJCPLUS_INCLUDE_PATH")
763 (files '("include")))
764 (search-path-specification
765 (variable "LIBRARY_PATH")
766 (files '("lib" "lib64"))))))
767
e05f8d2f
EF
768(define-public gcc-objc++-7
769 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
770 (list (search-path-specification
771 (variable "OBJCPLUS_INCLUDE_PATH")
772 (files '("include")))
773 (search-path-specification
774 (variable "LIBRARY_PATH")
775 (files '("lib" "lib64"))))))
776
14728ab7 777(define-public gcc-objc++ gcc-objc++-5)
987a1183 778
98b385d1
LC
779(define (make-libstdc++-doc gcc)
780 "Return a package with the libstdc++ documentation for GCC."
781 (package
782 (inherit gcc)
783 (name "libstdc++-doc")
784 (version (package-version gcc))
785 (synopsis "GNU libstdc++ documentation")
786 (outputs '("out"))
787 (native-inputs `(("doxygen" ,doxygen)
788 ("texinfo" ,texinfo)
789 ("libxml2" ,libxml2)
790 ("libxslt" ,libxslt)
791 ("docbook-xml" ,docbook-xml)
792 ("docbook-xsl" ,docbook-xsl)
793 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
794 (inputs '())
795 (propagated-inputs '())
796 (arguments
797 '(#:out-of-source? #t
798 #:tests? #f ;it's just documentation
799 #:phases (modify-phases %standard-phases
800 (add-before 'configure 'chdir
801 (lambda _
61a815eb
MW
802 (chdir "libstdc++-v3")
803 #t))
98b385d1
LC
804 (add-before 'configure 'set-xsl-directory
805 (lambda* (#:key inputs #:allow-other-keys)
806 (let ((docbook (assoc-ref inputs "docbook-xsl")))
807 (substitute* (find-files "doc"
808 "^Makefile\\.in$")
809 (("@XSL_STYLE_DIR@")
810 (string-append
811 docbook "/xml/xsl/"
61a815eb
MW
812 (strip-store-file-name docbook))))
813 #t)))
98b385d1
LC
814 (replace 'build
815 (lambda _
816 ;; XXX: There's also a 'doc-info' target, but it
817 ;; relies on docbook2X, which itself relies on
818 ;; DocBook 4.1.2, which is not really usable
819 ;; (lacks a catalog.xml.)
61a815eb
MW
820 (invoke "make"
821 "doc-html"
822 "doc-man")))
98b385d1
LC
823 (replace 'install
824 (lambda* (#:key outputs #:allow-other-keys)
825 (let ((out (assoc-ref outputs "out")))
61a815eb
MW
826 (invoke "make"
827 "doc-install-html"
828 "doc-install-man")))))))))
98b385d1
LC
829
830(define-public libstdc++-doc-4.9
831 (make-libstdc++-doc gcc-4.9))
832
629f4d2e
MW
833(define-public libstdc++-doc-5
834 (make-libstdc++-doc gcc-5))
98b385d1 835
832abc76
LC
836(define-public isl
837 (package
838 (name "isl")
5b5a8d6b 839 (version "0.19")
832abc76
LC
840 (source (origin
841 (method url-fetch)
842 (uri (list (string-append
590a4904 843 "http://isl.gforge.inria.fr/isl-"
832abc76
LC
844 version
845 ".tar.bz2")
846 (string-append %gcc-infrastructure
847 name "-" version ".tar.gz")))
848 (sha256
849 (base32
5b5a8d6b 850 "1n4yz9rj24mv226hqbpw210ifvqkn8dgvpnkzf0s0lkq9zrjd5ym"))))
832abc76
LC
851 (build-system gnu-build-system)
852 (inputs `(("gmp" ,gmp)))
590a4904 853 (home-page "http://isl.gforge.inria.fr/")
832abc76 854 (synopsis
9e771e3b
LC
855 "Manipulating sets and relations of integer points \
856bounded by linear constraints")
832abc76
LC
857 (description
858 "isl is a library for manipulating sets and relations of integer points
35b9e423 859bounded by linear constraints. Supported operations on sets include
832abc76
LC
860intersection, union, set difference, emptiness check, convex hull, (integer)
861affine hull, integer projection, computing the lexicographic minimum using
862parametric integer programming, coalescing and parametric vertex
35b9e423 863enumeration. It also includes an ILP solver based on generalized basis
832abc76
LC
864reduction, transitive closures on maps (which may encode infinite graphs),
865dependence analysis and bounds on piecewise step-polynomials.")
866 (license lgpl2.1+)))
867
25bd7267
MB
868(define-public isl-0.18
869 (package
870 (inherit isl)
871 (version "0.18")
872 (source (origin
873 (method url-fetch)
874 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
875 version ".tar.bz2")
876 (string-append %gcc-infrastructure
877 "isl-" version ".tar.gz")))
878 (sha256
879 (base32
880 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
881
ab53bdf0
EF
882(define-public isl-0.11
883 (package
884 (inherit isl)
885 (name "isl")
886 (version "0.11.1")
887 (source (origin
888 (method url-fetch)
889 (uri (list (string-append
890 "http://isl.gforge.inria.fr/isl-"
891 version
892 ".tar.bz2")
893 (string-append %gcc-infrastructure
894 name "-" version ".tar.gz")))
895 (sha256
896 (base32
897 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
898 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
899
832abc76
LC
900(define-public cloog
901 (package
902 (name "cloog")
903 (version "0.18.0")
904 (source
905 (origin
906 (method url-fetch)
907 (uri (list (string-append
908 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
909 version
910 ".tar.gz")
911 (string-append %gcc-infrastructure
912 name "-" version ".tar.gz")))
913 (sha256
914 (base32
915 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
916 (file-name (string-append name "-" version ".tar.gz"))))
917 (build-system gnu-build-system)
918 (inputs `(("gmp" ,gmp)
ab53bdf0 919 ("isl" ,isl-0.11)))
832abc76
LC
920 (arguments '(#:configure-flags '("--with-isl=system")))
921 (home-page "http://www.cloog.org/")
9e771e3b 922 (synopsis "Library to generate code for scanning Z-polyhedra")
832abc76
LC
923 (description
924 "CLooG is a free software library to generate code for scanning
925Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
926reaches each integral point of one or more parameterized polyhedra.
927CLooG has been originally written to solve the code generation problem
928for optimizing compilers based on the polytope model. Nevertheless it
929is used now in various area e.g., to build control automata for
930high-level synthesis or to find the best polynomial approximation of a
931function. CLooG may help in any situation where scanning polyhedra
932matters. While the user has full control on generated code quality,
933CLooG is designed to avoid control overhead and to produce a very
934effective code.")
935 (license gpl2+)))
5c126b64 936
50c7a1e2
LC
937(define-public gnu-c-manual
938 (package
939 (name "gnu-c-manual")
d35f8c7c 940 (version "0.2.5")
50c7a1e2
LC
941 (source (origin
942 (method url-fetch)
943 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
944 version ".tar.gz"))
945 (sha256
946 (base32
d35f8c7c 947 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
50c7a1e2
LC
948 (build-system gnu-build-system)
949 (native-inputs `(("texinfo" ,texinfo)))
950 (arguments
951 '(#:phases (modify-phases %standard-phases
952 (delete 'configure)
953 (delete 'check)
954 (replace 'build
955 (lambda _
9feb4fd5
MW
956 (invoke "make"
957 "gnu-c-manual.info"
958 "gnu-c-manual.html")))
50c7a1e2
LC
959 (replace 'install
960 (lambda* (#:key outputs #:allow-other-keys)
961 (let* ((out (assoc-ref outputs "out"))
962 (info (string-append out "/share/info"))
963 (html (string-append
964 out "/share/doc/gnu-c-manual")))
965 (mkdir-p info)
966 (mkdir-p html)
967
968 (for-each (lambda (file)
969 (copy-file file
970 (string-append info "/"
971 file)))
972 (find-files "." "\\.info(-[0-9])?$"))
973 (for-each (lambda (file)
974 (copy-file file
975 (string-append html "/"
976 file)))
977 (find-files "." "\\.html$"))
978 #t))))))
979 (synopsis "Reference manual for the C programming language")
980 (description
981 "This is a reference manual for the C programming language, as
982implemented by the GNU C Compiler (gcc). As a reference, it is not intended
983to be a tutorial of the language. Rather, it outlines all of the constructs
984of the language. Library functions are not included.")
6fd52309 985 (home-page "https://www.gnu.org/software/gnu-c-manual/")
50c7a1e2 986 (license fdl1.3+)))