gnu: Add python-user-agents.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
6 ;;; Copyright © 2015, 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll@gmail.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
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)
27 #:use-module ((guix licenses)
28 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
29 #:use-module (gnu packages)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages multiprecision)
33 #:use-module (gnu packages texinfo)
34 #:use-module (gnu packages dejagnu)
35 #:use-module (gnu packages documentation)
36 #:use-module (gnu packages xml)
37 #:use-module (gnu packages docbook)
38 #:use-module (gnu packages graphviz)
39 #:use-module (gnu packages elf)
40 #:use-module (gnu packages perl)
41 #:use-module (guix packages)
42 #:use-module (guix download)
43 #:use-module (guix build-system gnu)
44 #:use-module (guix build-system trivial)
45 #:use-module (guix utils)
46 #:use-module (srfi srfi-1)
47 #:use-module (ice-9 regex))
48
49 (define %gcc-infrastructure
50 ;; Base URL for GCC's infrastructure.
51 "mirror://gcc/infrastructure/")
52
53 (define (gcc-configure-flags-for-triplet target)
54 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
55
56 The purpose of this procedure is to translate extended GNU triplets---e.g.,
57 where 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"))
63
64 ((string-match "^arm.*-gnueabihf$" target)
65 '("--with-arch=armv7-a"
66 "--with-float=hard"
67 "--with-mode=thumb"
68 "--with-fpu=neon"))
69
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
78 (else
79 ;; TODO: Add `arm.*-gnueabi', etc.
80 '())))
81
82 (define-public gcc-4.7
83 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
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))
93 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
94 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
95 '()))))
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))))
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"
114 "--with-system-zlib"
115
116 ;; No pre-compiled libstdc++ headers, to save space.
117 "--disable-libstdcxx-pch"
118
119 "--with-local-prefix=/no-gcc-local-prefix"
120
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
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
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))
140
141 (maybe-target-tools))))))
142 (package
143 (name "gcc")
144 (version "4.7.4")
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
151 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
152 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
153 "gcc-fix-texi2pod.patch"))))
154 (build-system gnu-build-system)
155
156 ;; Separate out the run-time support libraries because all the
157 ;; dynamic-linked objects depend on it.
158 (outputs '("out" ;commands, etc. (60+ MiB)
159 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
160 "debug")) ;debug symbols of run-time libraries
161
162 (inputs `(("gmp" ,gmp)
163 ("mpfr" ,mpfr)
164 ("mpc" ,mpc)
165 ("libelf" ,libelf)
166 ("zlib" ,zlib)))
167
168 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
169 ;; Newer texinfos fail to build the manual, so we use an older one.
170 (native-inputs `(("perl" ,perl) ;for manpages
171 ("texinfo" ,texinfo-5)))
172
173 (arguments
174 `(#:out-of-source? #t
175 #:configure-flags ,(configure-flags)
176 #:make-flags
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")))))
201
202 #:tests? #f
203
204 #:phases
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 \
250 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
251 libc libc libdir suffix))
252 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
253 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
254 #define STANDARD_STARTFILE_PREFIX_2 \"\"
255 ~a"
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 \
264 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
265 libc libc libdir suffix))
266 (("#define STARTFILE_LINUX_SPEC.*$" line)
267 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
268 #define STANDARD_STARTFILE_PREFIX_2 \"\"
269 ~a"
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)))))
330
331 (native-search-paths
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.
337 (list (search-path-specification
338 (variable "C_INCLUDE_PATH")
339 (files '("include")))
340 (search-path-specification
341 (variable "CPLUS_INCLUDE_PATH")
342 (files '("include")))
343 (search-path-specification
344 (variable "LIBRARY_PATH")
345 (files '("lib" "lib64")))))
346
347 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
348 (synopsis "GNU Compiler Collection")
349 (description
350 "GCC is the GNU Compiler Collection. It provides compiler front-ends
351 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
352 Go. It also includes runtime support libraries for these languages.")
353 (license gpl3+)
354 (supported-systems (delete "aarch64-linux" %supported-systems))
355 (home-page "https://gcc.gnu.org/"))))
356
357 (define-public gcc-4.8
358 (package (inherit gcc-4.7)
359 (version "4.8.5")
360 (source (origin
361 (method url-fetch)
362 (uri (string-append "mirror://gnu/gcc/gcc-"
363 version "/gcc-" version ".tar.bz2"))
364 (sha256
365 (base32
366 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
367 (patches (search-patches "gcc-arm-link-spec-fix.patch"
368 "gcc-4.8-libsanitizer-fix.patch"
369 "gcc-asan-missing-include.patch"
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
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))))
384 (supported-systems %supported-systems)
385 (inputs
386 `(("isl" ,isl-0.11)
387 ("cloog" ,cloog)
388 ,@(package-inputs gcc-4.7)))))
389
390 (define-public gcc-4.9
391 (package (inherit gcc-4.8)
392 (version "4.9.4")
393 (source (origin
394 (method url-fetch)
395 (uri (string-append "mirror://gnu/gcc/gcc-"
396 version "/gcc-" version ".tar.bz2"))
397 (sha256
398 (base32
399 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
400 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
401 "gcc-arm-bug-71399.patch"
402 "gcc-asan-missing-include.patch"
403 "gcc-libvtv-runpath.patch"
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
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))))
418 ;; Override inherited texinfo-5 with latest version.
419 (native-inputs `(("perl" ,perl) ;for manpages
420 ("texinfo" ,texinfo)))))
421
422 (define-public gcc-5
423 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
424 ;; them in a VPATH build.
425 (package (inherit gcc-4.9)
426 (version "5.5.0")
427 (source (origin
428 (method url-fetch)
429 (uri (string-append "mirror://gnu/gcc/gcc-"
430 version "/gcc-" version ".tar.xz"))
431 (sha256
432 (base32
433 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
434 (patches (search-patches "gcc-arm-bug-71399.patch"
435 "gcc-strmov-store-file-names.patch"
436 "gcc-5.0-libvtv-runpath.patch"
437 "gcc-5-source-date-epoch-1.patch"
438 "gcc-5-source-date-epoch-2.patch"
439 "gcc-fix-texi2pod.patch"))
440 (modules '((guix build utils)))
441 (snippet
442 ;; Fix 'libcc1/configure' error when cross-compiling GCC.
443 ;; Without that, 'libcc1/configure' wrongfully determines that
444 ;; '-rdynamic' support is missing because $gcc_cv_objdump is
445 ;; empty:
446 ;;
447 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
448 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
449 '(begin
450 (substitute* "libcc1/configure"
451 (("\\$gcc_cv_objdump -T")
452 "$OBJDUMP_FOR_TARGET -T"))
453 #t))))
454 (inputs
455 `(("isl" ,isl)
456 ,@(package-inputs gcc-4.7)))))
457
458 (define-public gcc-6
459 (package
460 (inherit gcc-5)
461 (version "6.4.0")
462 (source (origin
463 (method url-fetch)
464 (uri (string-append "mirror://gnu/gcc/gcc-"
465 version "/gcc-" version ".tar.xz"))
466 (sha256
467 (base32
468 "1m0lr7938lw5d773dkvwld90hjlcq2282517d1gwvrfzmwgg42w5"))
469 (patches (search-patches "gcc-libsanitizer-fix.patch"
470 "gcc-strmov-store-file-names.patch"
471 "gcc-6-source-date-epoch-1.patch"
472 "gcc-6-source-date-epoch-2.patch"
473 "gcc-5.0-libvtv-runpath.patch"))
474 (modules '((guix build utils)))
475 ;; This is required for building with glibc-2.26.
476 ;; This can be removed when gcc-6.5.0 is released.
477 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
478 (snippet
479 '(begin
480 (for-each
481 (lambda (dir)
482 (substitute* (string-append "libgcc/config/"
483 dir "/linux-unwind.h")
484 (("struct ucontext") "ucontext_t")))
485 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
486 "pa" "sh" "tilepro" "xtensa"))
487 #t))))
488 (inputs
489 `(("isl" ,isl)
490 ,@(package-inputs gcc-4.7)))
491
492 (native-search-paths
493 ;; We have to use 'CPATH' for GCC > 5, not 'C_INCLUDE_PATH' & co., due to
494 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129>.
495 (list (search-path-specification
496 (variable "CPATH")
497 (files '("include")))
498 (search-path-specification
499 (variable "LIBRARY_PATH")
500 (files '("lib" "lib64")))))))
501
502 (define-public gcc-7
503 (package
504 (inherit gcc-6)
505 (version "7.3.0")
506 (source (origin
507 (method url-fetch)
508 (uri (string-append "mirror://gnu/gcc/gcc-"
509 version "/gcc-" version ".tar.xz"))
510 (sha256
511 (base32
512 "0p71bij6bfhzyrs8676a8jmpjsfz392s2rg862sdnsk30jpacb43"))
513 (patches (search-patches "gcc-strmov-store-file-names.patch"
514 "gcc-5.0-libvtv-runpath.patch"))))
515 (description
516 "GCC is the GNU Compiler Collection. It provides compiler front-ends
517 for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
518 It also includes runtime support libraries for these languages.")))
519
520 (define-public gcc-8
521 (package
522 (inherit gcc-7)
523 (version "8.2.0")
524 (source (origin
525 (method url-fetch)
526 (uri (string-append "mirror://gnu/gcc/gcc-"
527 version "/gcc-" version ".tar.xz"))
528 (sha256
529 (base32
530 "10007smilswiiv2ymazr3b6x2i933c0ycxrr529zh4r6p823qv0r"))
531 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
532 "gcc-5.0-libvtv-runpath.patch"))))))
533
534 ;; Note: When changing the default gcc version, update
535 ;; the gcc-toolchain-* definitions and the gfortran definition
536 ;; accordingly.
537 (define-public gcc gcc-5)
538
539 (define-public (make-libstdc++ gcc)
540 "Return a libstdc++ package based on GCC. The primary use case is when
541 using compilers other than GCC."
542 (package
543 (inherit gcc)
544 (name "libstdc++")
545 (arguments
546 `(#:out-of-source? #t
547 #:phases (alist-cons-before
548 'configure 'chdir
549 (lambda _
550 (chdir "libstdc++-v3")
551 #t)
552 %standard-phases)
553 #:configure-flags `("--disable-libstdcxx-pch"
554 ,(string-append "--with-gxx-include-dir="
555 (assoc-ref %outputs "out")
556 "/include"))))
557 (outputs '("out" "debug"))
558 (inputs '())
559 (native-inputs '())
560 (propagated-inputs '())
561 (synopsis "GNU C++ standard library")))
562
563 (define-public libstdc++-4.9
564 (make-libstdc++ gcc-4.9))
565
566 (define (make-libiberty gcc)
567 "Return a libiberty package based on GCC."
568 (package
569 (inherit gcc)
570 (name "libiberty")
571 (arguments
572 `(#:out-of-source? #t
573 #:phases
574 (modify-phases %standard-phases
575 (add-before 'configure 'chdir
576 (lambda _
577 (chdir "libiberty")
578 #t))
579 (replace
580 'install
581 (lambda* (#:key outputs #:allow-other-keys)
582 (let* ((out (assoc-ref outputs "out"))
583 (lib (string-append out "/lib/"))
584 (include (string-append out "/include/")))
585 (mkdir-p lib)
586 (mkdir-p include)
587 (copy-file "libiberty.a"
588 (string-append lib "libiberty.a"))
589 (copy-file "../include/libiberty.h"
590 (string-append include "libiberty.h"))
591 #t))))))
592 (inputs '())
593 (outputs '("out"))
594 (native-inputs '())
595 (propagated-inputs '())
596 (synopsis "Collection of subroutines used by various GNU programs")))
597
598 (define-public libiberty
599 (make-libiberty gcc))
600
601 (define* (custom-gcc gcc name languages
602 #:optional
603 (search-paths (package-native-search-paths gcc))
604 #:key (separate-lib-output? #t))
605 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
606 as the 'native-search-paths' field."
607 (package (inherit gcc)
608 (name name)
609 (outputs (if separate-lib-output?
610 (package-outputs gcc)
611 (delete "lib" (package-outputs gcc))))
612 (native-search-paths search-paths)
613 (arguments
614 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
615 (guix build utils)
616 (ice-9 regex)
617 (srfi srfi-1)
618 (srfi srfi-26))
619 ,@(package-arguments gcc))
620 ((#:configure-flags flags)
621 `(cons (string-append "--enable-languages="
622 ,(string-join languages ","))
623 (remove (cut string-match "--enable-languages.*" <>)
624 ,flags)))
625 ((#:phases phases)
626 `(modify-phases ,phases
627 (add-after 'install 'remove-broken-or-conflicting-files
628 (lambda* (#:key outputs #:allow-other-keys)
629 (for-each delete-file
630 (find-files (string-append (assoc-ref outputs "out") "/bin")
631 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
632 #t))))))))
633
634 (define %generic-search-paths
635 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
636 ;; not considered "system headers", which means GCC can raise warnings for
637 ;; issues in those headers. 'CPATH' is the only one that works for
638 ;; front-ends not in the C family.
639 (list (search-path-specification
640 (variable "CPATH")
641 (files '("include")))
642 (search-path-specification
643 (variable "LIBRARY_PATH")
644 (files '("lib" "lib64")))))
645
646 (define-public gfortran-4.8
647 (custom-gcc gcc-4.8 "gfortran" '("fortran")
648 %generic-search-paths))
649
650 (define-public gfortran-4.9
651 (custom-gcc gcc-4.9 "gfortran" '("fortran")
652 %generic-search-paths))
653
654 (define-public gfortran-5
655 (custom-gcc gcc-5 "gfortran" '("fortran")
656 %generic-search-paths))
657
658 (define-public gfortran-6
659 (custom-gcc gcc-6 "gfortran" '("fortran")
660 %generic-search-paths))
661
662 (define-public gfortran-7
663 (custom-gcc gcc-7 "gfortran" '("fortran")
664 %generic-search-paths))
665
666 (define-public gfortran-8
667 (custom-gcc gcc-8 "gfortran" '("fortran")
668 %generic-search-paths))
669
670 (define-public gfortran
671 ;; Note: Update this when GCC changes! We cannot use
672 ;; (custom-gcc gcc "fortran" …) because that would lead to a package object
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)
676
677 (define-public gccgo-4.9
678 (custom-gcc gcc-4.9 "gccgo" '("go")
679 %generic-search-paths
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))
684
685 (define-public gcc-objc-4.8
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"))))))
693
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
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
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"))))))
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"))))))
729
730 (define-public gcc-objc-8
731 (custom-gcc gcc-8 "gcc-objc" '("objc")
732 (list (search-path-specification
733 (variable "OBJC_INCLUDE_PATH")
734 (files '("include")))
735 (search-path-specification
736 (variable "LIBRARY_PATH")
737 (files '("lib" "lib64"))))))
738
739 (define-public gcc-objc gcc-objc-5)
740
741 (define-public gcc-objc++-4.8
742 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
743 (list (search-path-specification
744 (variable "OBJCPLUS_INCLUDE_PATH")
745 (files '("include")))
746 (search-path-specification
747 (variable "LIBRARY_PATH")
748 (files '("lib" "lib64"))))))
749
750 (define-public gcc-objc++-4.9
751 (custom-gcc gcc-4.9 "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
759 (define-public gcc-objc++-5
760 (custom-gcc gcc-5 "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
768 (define-public gcc-objc++-6
769 (custom-gcc gcc-6 "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
777 (define-public gcc-objc++-7
778 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
779 (list (search-path-specification
780 (variable "OBJCPLUS_INCLUDE_PATH")
781 (files '("include")))
782 (search-path-specification
783 (variable "LIBRARY_PATH")
784 (files '("lib" "lib64"))))))
785
786 (define-public gcc-objc++-8
787 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
788 (list (search-path-specification
789 (variable "OBJCPLUS_INCLUDE_PATH")
790 (files '("include")))
791 (search-path-specification
792 (variable "LIBRARY_PATH")
793 (files '("lib" "lib64"))))))
794
795 (define-public gcc-objc++ gcc-objc++-5)
796
797 (define (make-libstdc++-doc gcc)
798 "Return a package with the libstdc++ documentation for GCC."
799 (package
800 (inherit gcc)
801 (name "libstdc++-doc")
802 (version (package-version gcc))
803 (synopsis "GNU libstdc++ documentation")
804 (outputs '("out"))
805 (native-inputs `(("doxygen" ,doxygen)
806 ("texinfo" ,texinfo)
807 ("libxml2" ,libxml2)
808 ("libxslt" ,libxslt)
809 ("docbook-xml" ,docbook-xml)
810 ("docbook-xsl" ,docbook-xsl)
811 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
812 (inputs '())
813 (propagated-inputs '())
814 (arguments
815 '(#:out-of-source? #t
816 #:tests? #f ;it's just documentation
817 #:phases (modify-phases %standard-phases
818 (add-before 'configure 'chdir
819 (lambda _
820 (chdir "libstdc++-v3")
821 #t))
822 (add-before 'configure 'set-xsl-directory
823 (lambda* (#:key inputs #:allow-other-keys)
824 (let ((docbook (assoc-ref inputs "docbook-xsl")))
825 (substitute* (find-files "doc"
826 "^Makefile\\.in$")
827 (("@XSL_STYLE_DIR@")
828 (string-append
829 docbook "/xml/xsl/"
830 (strip-store-file-name docbook))))
831 #t)))
832 (replace 'build
833 (lambda _
834 ;; XXX: There's also a 'doc-info' target, but it
835 ;; relies on docbook2X, which itself relies on
836 ;; DocBook 4.1.2, which is not really usable
837 ;; (lacks a catalog.xml.)
838 (invoke "make"
839 "doc-html"
840 "doc-man")))
841 (replace 'install
842 (lambda* (#:key outputs #:allow-other-keys)
843 (let ((out (assoc-ref outputs "out")))
844 (invoke "make"
845 "doc-install-html"
846 "doc-install-man")))))))))
847
848 (define-public libstdc++-doc-4.9
849 (make-libstdc++-doc gcc-4.9))
850
851 (define-public libstdc++-doc-5
852 (make-libstdc++-doc gcc-5))
853
854 (define-public isl
855 (package
856 (name "isl")
857 (version "0.18")
858 (source (origin
859 (method url-fetch)
860 (uri (list (string-append
861 "http://isl.gforge.inria.fr/isl-"
862 version
863 ".tar.bz2")
864 (string-append %gcc-infrastructure
865 name "-" version ".tar.gz")))
866 (sha256
867 (base32
868 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))
869 (build-system gnu-build-system)
870 (inputs `(("gmp" ,gmp)))
871 (home-page "http://isl.gforge.inria.fr/")
872 (synopsis
873 "Manipulating sets and relations of integer points \
874 bounded by linear constraints")
875 (description
876 "isl is a library for manipulating sets and relations of integer points
877 bounded by linear constraints. Supported operations on sets include
878 intersection, union, set difference, emptiness check, convex hull, (integer)
879 affine hull, integer projection, computing the lexicographic minimum using
880 parametric integer programming, coalescing and parametric vertex
881 enumeration. It also includes an ILP solver based on generalized basis
882 reduction, transitive closures on maps (which may encode infinite graphs),
883 dependence analysis and bounds on piecewise step-polynomials.")
884 (license lgpl2.1+)))
885
886 (define-public isl-0.11
887 (package
888 (inherit isl)
889 (name "isl")
890 (version "0.11.1")
891 (source (origin
892 (method url-fetch)
893 (uri (list (string-append
894 "http://isl.gforge.inria.fr/isl-"
895 version
896 ".tar.bz2")
897 (string-append %gcc-infrastructure
898 name "-" version ".tar.gz")))
899 (sha256
900 (base32
901 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
902 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
903
904 (define-public cloog
905 (package
906 (name "cloog")
907 (version "0.18.0")
908 (source
909 (origin
910 (method url-fetch)
911 (uri (list (string-append
912 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
913 version
914 ".tar.gz")
915 (string-append %gcc-infrastructure
916 name "-" version ".tar.gz")))
917 (sha256
918 (base32
919 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
920 (file-name (string-append name "-" version ".tar.gz"))))
921 (build-system gnu-build-system)
922 (inputs `(("gmp" ,gmp)
923 ("isl" ,isl-0.11)))
924 (arguments '(#:configure-flags '("--with-isl=system")))
925 (home-page "http://www.cloog.org/")
926 (synopsis "Library to generate code for scanning Z-polyhedra")
927 (description
928 "CLooG is a free software library to generate code for scanning
929 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
930 reaches each integral point of one or more parameterized polyhedra.
931 CLooG has been originally written to solve the code generation problem
932 for optimizing compilers based on the polytope model. Nevertheless it
933 is used now in various area e.g., to build control automata for
934 high-level synthesis or to find the best polynomial approximation of a
935 function. CLooG may help in any situation where scanning polyhedra
936 matters. While the user has full control on generated code quality,
937 CLooG is designed to avoid control overhead and to produce a very
938 effective code.")
939 (license gpl2+)))
940
941 (define-public gnu-c-manual
942 (package
943 (name "gnu-c-manual")
944 (version "0.2.5")
945 (source (origin
946 (method url-fetch)
947 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
948 version ".tar.gz"))
949 (sha256
950 (base32
951 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
952 (build-system gnu-build-system)
953 (native-inputs `(("texinfo" ,texinfo)))
954 (arguments
955 '(#:phases (modify-phases %standard-phases
956 (delete 'configure)
957 (delete 'check)
958 (replace 'build
959 (lambda _
960 (invoke "make"
961 "gnu-c-manual.info"
962 "gnu-c-manual.html")))
963 (replace 'install
964 (lambda* (#:key outputs #:allow-other-keys)
965 (let* ((out (assoc-ref outputs "out"))
966 (info (string-append out "/share/info"))
967 (html (string-append
968 out "/share/doc/gnu-c-manual")))
969 (mkdir-p info)
970 (mkdir-p html)
971
972 (for-each (lambda (file)
973 (copy-file file
974 (string-append info "/"
975 file)))
976 (find-files "." "\\.info(-[0-9])?$"))
977 (for-each (lambda (file)
978 (copy-file file
979 (string-append html "/"
980 file)))
981 (find-files "." "\\.html$"))
982 #t))))))
983 (synopsis "Reference manual for the C programming language")
984 (description
985 "This is a reference manual for the C programming language, as
986 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
987 to be a tutorial of the language. Rather, it outlines all of the constructs
988 of the language. Library functions are not included.")
989 (home-page "https://www.gnu.org/software/gnu-c-manual/")
990 (license fdl1.3+)))