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