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