gnu: perl-context-preserve: Update to 0.03.
[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 ;;;
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)
25 #:use-module ((guix licenses)
26 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+ fdl1.3+))
27 #:use-module (gnu packages)
28 #:use-module (gnu packages bootstrap)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages multiprecision)
31 #:use-module (gnu packages texinfo)
32 #:use-module (gnu packages dejagnu)
33 #:use-module (gnu packages documentation)
34 #:use-module (gnu packages xml)
35 #:use-module (gnu packages docbook)
36 #:use-module (gnu packages graphviz)
37 #:use-module (gnu packages elf)
38 #:use-module (gnu packages perl)
39 #:use-module (guix packages)
40 #:use-module (guix download)
41 #:use-module (guix build-system gnu)
42 #:use-module (guix build-system trivial)
43 #:use-module (guix utils)
44 #:use-module (srfi srfi-1)
45 #:use-module (ice-9 regex))
46
47 (define %gcc-infrastructure
48 ;; Base URL for GCC's infrastructure.
49 "mirror://gcc/infrastructure/")
50
51 (define (gcc-configure-flags-for-triplet target)
52 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
53
54 The purpose of this procedure is to translate extended GNU triplets---e.g.,
55 where 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"))
61
62 ((string-match "^arm.*-gnueabihf$" target)
63 '("--with-arch=armv7-a"
64 "--with-float=hard"
65 "--with-mode=thumb"
66 "--with-fpu=neon"))
67
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
76 (else
77 ;; TODO: Add `arm.*-gnueabi', etc.
78 '())))
79
80 (define-public gcc-4.7
81 (let* ((stripped? #t) ;whether to strip the compiler, not the libraries
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))
91 '("CC" "CXX" "LD" "AR" "NM" "OBJDUMP" "RANLIB" "STRIP")
92 '("gcc" "g++" "ld" "ar" "nm" "objdump" "ranlib" "strip"))
93 '()))))
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))))
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"
112 "--with-system-zlib"
113
114 ;; No pre-compiled libstdc++ headers, to save space.
115 "--disable-libstdcxx-pch"
116
117 "--with-local-prefix=/no-gcc-local-prefix"
118
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
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
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))
138
139 (maybe-target-tools))))))
140 (package
141 (name "gcc")
142 (version "4.7.4")
143 (source (origin
144 (method url-fetch)
145 (uri (string-append "mirror://gnu/gcc/gcc-"
146 version "/gcc-" version ".tar.bz2"))
147 (patches (search-patches "gcc-4-compile-with-gcc-5.patch"))
148 (sha256
149 (base32
150 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
151 (patches (search-patches "gcc-fix-texi2pod.patch"))))
152 (build-system gnu-build-system)
153
154 ;; Separate out the run-time support libraries because all the
155 ;; dynamic-linked objects depend on it.
156 (outputs '("out" ;commands, etc. (60+ MiB)
157 "lib" ;libgcc_s, libgomp, etc. (15+ MiB)
158 "debug")) ;debug symbols of run-time libraries
159
160 (inputs `(("gmp" ,gmp)
161 ("mpfr" ,mpfr)
162 ("mpc" ,mpc)
163 ("libelf" ,libelf)
164 ("zlib" ,zlib)))
165
166 ;; GCC < 5 is one of the few packages that doesn't ship .info files.
167 ;; Newer texinfos fail to build the manual, so we use an older one.
168 (native-inputs `(("perl" ,perl) ;for manpages
169 ("texinfo" ,texinfo-5)))
170
171 (arguments
172 `(#:out-of-source? #t
173 #:configure-flags ,(configure-flags)
174 #:make-flags
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")))))
199
200 #:tests? #f
201
202 #:phases
203 (alist-cons-before
204 'configure 'pre-configure
205 (lambda* (#:key inputs outputs #:allow-other-keys)
206 (let ((libdir ,(libdir))
207 (libc (assoc-ref inputs "libc")))
208 (when libc
209 ;; The following is not performed for `--without-headers'
210 ;; cross-compiler builds.
211
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"
217 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
218 (("(#define (GLIBC|GNU_USER)_DYNAMIC_LINKER.*)\\\\\n$" _ line)
219 line)))
220 '(1 2 3))
221
222 ;; Fix the dynamic linker's file name.
223 (substitute* (find-files "gcc/config"
224 "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
225 (("#define (GLIBC|GNU_USER)_DYNAMIC_LINKER([^ \t]*).*$"
226 _ gnu-user suffix)
227 (format #f "#define ~a_DYNAMIC_LINKER~a \"~a\"~%"
228 gnu-user suffix
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"
234 "^gnu-user.*\\.h$")
235 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
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
241 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
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.
247 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
248 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
249 libc libc libdir suffix))
250 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
251 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
252 #define STANDARD_STARTFILE_PREFIX_2 \"\"
253 ~a"
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))))
269
270 ;; Don't retain a dependency on the build-time sed.
271 (substitute* "fixincludes/fixincl.x"
272 (("static char const sed_cmd_z\\[\\] =.*;")
273 "static char const sed_cmd_z[] = \"sed\";"))
274
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
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)
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 ""))))
294
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
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"))))
318
319 (alist-cons-after
320 'configure 'post-configure
321 (lambda _
322 ;; Don't store configure flags, to avoid retaining references to
323 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
324 (substitute* "Makefile"
325 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
326 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
327 %standard-phases))))
328
329 (native-search-paths
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.
335 (list (search-path-specification
336 (variable "C_INCLUDE_PATH")
337 (files '("include")))
338 (search-path-specification
339 (variable "CPLUS_INCLUDE_PATH")
340 (files '("include")))
341 (search-path-specification
342 (variable "LIBRARY_PATH")
343 (files '("lib" "lib64")))))
344
345 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
346 (synopsis "GNU Compiler Collection")
347 (description
348 "GCC is the GNU Compiler Collection. It provides compiler front-ends
349 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
350 Go. It also includes runtime support libraries for these languages.")
351 (license gpl3+)
352 (supported-systems (delete "aarch64-linux" %supported-systems))
353 (home-page "https://gcc.gnu.org/"))))
354
355 (define-public gcc-4.8
356 (package (inherit gcc-4.7)
357 (version "4.8.5")
358 (source (origin
359 (method url-fetch)
360 (uri (string-append "mirror://gnu/gcc/gcc-"
361 version "/gcc-" version ".tar.bz2"))
362 (sha256
363 (base32
364 "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"))
365 (patches (search-patches "gcc-arm-link-spec-fix.patch"
366 "gcc-asan-missing-include.patch"
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")))))
379 (supported-systems %supported-systems)
380 (inputs
381 `(("isl" ,isl-0.11)
382 ("cloog" ,cloog)
383 ,@(package-inputs gcc-4.7)))))
384
385 (define-public gcc-4.9
386 (package (inherit gcc-4.8)
387 (version "4.9.4")
388 (source (origin
389 (method url-fetch)
390 (uri (string-append "mirror://gnu/gcc/gcc-"
391 version "/gcc-" version ".tar.bz2"))
392 (sha256
393 (base32
394 "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"))
395 (patches (search-patches "gcc-4.9-libsanitizer-fix.patch"
396 "gcc-arm-bug-71399.patch"
397 "gcc-asan-missing-include.patch"
398 "gcc-libvtv-runpath.patch"
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")))))
411 ;; Override inherited texinfo-5 with latest version.
412 (native-inputs `(("perl" ,perl) ;for manpages
413 ("texinfo" ,texinfo)))))
414
415 (define-public gcc-5
416 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
417 ;; them in a VPATH build.
418 (package (inherit gcc-4.9)
419 (version "5.5.0")
420 (source (origin
421 (method url-fetch)
422 (uri (string-append "mirror://gnu/gcc/gcc-"
423 version "/gcc-" version ".tar.xz"))
424 (sha256
425 (base32
426 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
427 (patches (search-patches "gcc-arm-bug-71399.patch"
428 "gcc-strmov-store-file-names.patch"
429 "gcc-5.0-libvtv-runpath.patch"
430 "gcc-5-source-date-epoch-1.patch"
431 "gcc-5-source-date-epoch-2.patch"
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")))))
445 (inputs
446 `(("isl" ,isl)
447 ,@(package-inputs gcc-4.7)))))
448
449 (define-public gcc-6
450 (package
451 (inherit gcc-5)
452 (version "6.4.0")
453 (source (origin
454 (method url-fetch)
455 (uri (string-append "mirror://gnu/gcc/gcc-"
456 version "/gcc-" version ".tar.xz"))
457 (sha256
458 (base32
459 "1m0lr7938lw5d773dkvwld90hjlcq2282517d1gwvrfzmwgg42w5"))
460 (patches (search-patches "gcc-libsanitizer-fix.patch"
461 "gcc-strmov-store-file-names.patch"
462 "gcc-6-source-date-epoch-1.patch"
463 "gcc-6-source-date-epoch-2.patch"
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")))))
477 (inputs
478 `(("isl" ,isl)
479 ,@(package-inputs gcc-4.7)))
480
481 (native-search-paths
482 ;; We have to use 'CPATH' for GCC > 5, not 'C_INCLUDE_PATH' & co., due to
483 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129>.
484 (list (search-path-specification
485 (variable "CPATH")
486 (files '("include")))
487 (search-path-specification
488 (variable "LIBRARY_PATH")
489 (files '("lib" "lib64")))))))
490
491 (define-public gcc-7
492 (package
493 (inherit gcc-6)
494 (version "7.3.0")
495 (source (origin
496 (method url-fetch)
497 (uri (string-append "mirror://gnu/gcc/gcc-"
498 version "/gcc-" version ".tar.xz"))
499 (sha256
500 (base32
501 "0p71bij6bfhzyrs8676a8jmpjsfz392s2rg862sdnsk30jpacb43"))
502 (patches (search-patches "gcc-strmov-store-file-names.patch"
503 "gcc-5.0-libvtv-runpath.patch"))))
504 (description
505 "GCC is the GNU Compiler Collection. It provides compiler front-ends
506 for several languages, including C, C++, Objective-C, Fortran, Ada, and Go.
507 It also includes runtime support libraries for these languages.")))
508
509 ;; Note: When changing the default gcc version, update
510 ;; the gcc-toolchain-* definitions and the gfortran definition
511 ;; accordingly.
512 (define-public gcc gcc-5)
513
514 (define-public (make-libstdc++ gcc)
515 "Return a libstdc++ package based on GCC. The primary use case is when
516 using compilers other than GCC."
517 (package
518 (inherit gcc)
519 (name "libstdc++")
520 (arguments
521 `(#:out-of-source? #t
522 #:phases (alist-cons-before
523 'configure 'chdir
524 (lambda _
525 (chdir "libstdc++-v3"))
526 %standard-phases)
527 #:configure-flags `("--disable-libstdcxx-pch"
528 ,(string-append "--with-gxx-include-dir="
529 (assoc-ref %outputs "out")
530 "/include"))))
531 (outputs '("out" "debug"))
532 (inputs '())
533 (native-inputs '())
534 (propagated-inputs '())
535 (synopsis "GNU C++ standard library")))
536
537 (define-public libstdc++-4.9
538 (make-libstdc++ gcc-4.9))
539
540 (define (make-libiberty gcc)
541 "Return a libiberty package based on GCC."
542 (package
543 (inherit gcc)
544 (name "libiberty")
545 (arguments
546 `(#:out-of-source? #t
547 #:phases
548 (modify-phases %standard-phases
549 (add-before 'configure 'chdir
550 (lambda _
551 (chdir "libiberty")
552 #t))
553 (replace
554 'install
555 (lambda* (#:key outputs #:allow-other-keys)
556 (let* ((out (assoc-ref outputs "out"))
557 (lib (string-append out "/lib/"))
558 (include (string-append out "/include/")))
559 (mkdir-p lib)
560 (mkdir-p include)
561 (copy-file "libiberty.a"
562 (string-append lib "libiberty.a"))
563 (copy-file "../include/libiberty.h"
564 (string-append include "libiberty.h"))
565 #t))))))
566 (inputs '())
567 (outputs '("out"))
568 (native-inputs '())
569 (propagated-inputs '())
570 (synopsis "Collection of subroutines used by various GNU programs")))
571
572 (define-public libiberty
573 (make-libiberty gcc))
574
575 (define* (custom-gcc gcc name languages
576 #:optional
577 (search-paths (package-native-search-paths gcc))
578 #:key (separate-lib-output? #t))
579 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
580 as the 'native-search-paths' field."
581 (package (inherit gcc)
582 (name name)
583 (outputs (if separate-lib-output?
584 (package-outputs gcc)
585 (delete "lib" (package-outputs gcc))))
586 (native-search-paths search-paths)
587 (arguments
588 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
589 (guix build utils)
590 (ice-9 regex)
591 (srfi srfi-1)
592 (srfi srfi-26))
593 ,@(package-arguments gcc))
594 ((#:configure-flags flags)
595 `(cons (string-append "--enable-languages="
596 ,(string-join languages ","))
597 (remove (cut string-match "--enable-languages.*" <>)
598 ,flags)))
599 ((#:phases phases)
600 `(modify-phases ,phases
601 (add-after 'install 'remove-broken-or-conflicting-files
602 (lambda* (#:key outputs #:allow-other-keys)
603 (for-each delete-file
604 (find-files (string-append (assoc-ref outputs "out") "/bin")
605 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc.*)"))
606 #t))))))))
607
608 (define %generic-search-paths
609 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
610 ;; not considered "system headers", which means GCC can raise warnings for
611 ;; issues in those headers. 'CPATH' is the only one that works for
612 ;; front-ends not in the C family.
613 (list (search-path-specification
614 (variable "CPATH")
615 (files '("include")))
616 (search-path-specification
617 (variable "LIBRARY_PATH")
618 (files '("lib" "lib64")))))
619
620 (define-public gfortran-4.8
621 (custom-gcc gcc-4.8 "gfortran" '("fortran")
622 %generic-search-paths))
623
624 (define-public gfortran-4.9
625 (custom-gcc gcc-4.9 "gfortran" '("fortran")
626 %generic-search-paths))
627
628 (define-public gfortran-5
629 (custom-gcc gcc-5 "gfortran" '("fortran")
630 %generic-search-paths))
631
632 (define-public gfortran-6
633 (custom-gcc gcc-6 "gfortran" '("fortran")
634 %generic-search-paths))
635
636 (define-public gfortran-7
637 (custom-gcc gcc-7 "gfortran" '("fortran")
638 %generic-search-paths))
639
640 (define-public gfortran
641 ;; Note: Update this when GCC changes! We cannot use
642 ;; (custom-gcc gcc "fortran" …) because that would lead to a package object
643 ;; that is not 'eq?' with GFORTRAN-5, and thus 'fold-packages' would
644 ;; report two gfortran@5 that are in fact identical.
645 gfortran-5)
646
647 (define-public gccgo-4.9
648 (custom-gcc gcc-4.9 "gccgo" '("go")
649 %generic-search-paths
650 ;; Suppress the separate "lib" output, because otherwise the
651 ;; "lib" and "out" outputs would refer to each other, creating
652 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
653 #:separate-lib-output? #f))
654
655 (define-public gcc-objc-4.8
656 (custom-gcc gcc-4.8 "gcc-objc" '("objc")
657 (list (search-path-specification
658 (variable "OBJC_INCLUDE_PATH")
659 (files '("include")))
660 (search-path-specification
661 (variable "LIBRARY_PATH")
662 (files '("lib" "lib64"))))))
663
664 (define-public gcc-objc-4.9
665 (custom-gcc gcc-4.9 "gcc-objc" '("objc")
666 (list (search-path-specification
667 (variable "OBJC_INCLUDE_PATH")
668 (files '("include")))
669 (search-path-specification
670 (variable "LIBRARY_PATH")
671 (files '("lib" "lib64"))))))
672
673 (define-public gcc-objc-5
674 (custom-gcc gcc-5 "gcc-objc" '("objc")
675 (list (search-path-specification
676 (variable "OBJC_INCLUDE_PATH")
677 (files '("include")))
678 (search-path-specification
679 (variable "LIBRARY_PATH")
680 (files '("lib" "lib64"))))))
681
682 (define-public gcc-objc-6
683 (custom-gcc gcc-6 "gcc-objc" '("objc")
684 (list (search-path-specification
685 (variable "OBJC_INCLUDE_PATH")
686 (files '("include")))
687 (search-path-specification
688 (variable "LIBRARY_PATH")
689 (files '("lib" "lib64"))))))
690
691 (define-public gcc-objc-7
692 (custom-gcc gcc-7 "gcc-objc" '("objc")
693 (list (search-path-specification
694 (variable "OBJC_INCLUDE_PATH")
695 (files '("include")))
696 (search-path-specification
697 (variable "LIBRARY_PATH")
698 (files '("lib" "lib64"))))))
699
700 (define-public gcc-objc gcc-objc-5)
701
702 (define-public gcc-objc++-4.8
703 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")
704 (list (search-path-specification
705 (variable "OBJCPLUS_INCLUDE_PATH")
706 (files '("include")))
707 (search-path-specification
708 (variable "LIBRARY_PATH")
709 (files '("lib" "lib64"))))))
710
711 (define-public gcc-objc++-4.9
712 (custom-gcc gcc-4.9 "gcc-objc++" '("obj-c++")
713 (list (search-path-specification
714 (variable "OBJCPLUS_INCLUDE_PATH")
715 (files '("include")))
716 (search-path-specification
717 (variable "LIBRARY_PATH")
718 (files '("lib" "lib64"))))))
719
720 (define-public gcc-objc++-5
721 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
722 (list (search-path-specification
723 (variable "OBJCPLUS_INCLUDE_PATH")
724 (files '("include")))
725 (search-path-specification
726 (variable "LIBRARY_PATH")
727 (files '("lib" "lib64"))))))
728
729 (define-public gcc-objc++-6
730 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
731 (list (search-path-specification
732 (variable "OBJCPLUS_INCLUDE_PATH")
733 (files '("include")))
734 (search-path-specification
735 (variable "LIBRARY_PATH")
736 (files '("lib" "lib64"))))))
737
738 (define-public gcc-objc++-7
739 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
740 (list (search-path-specification
741 (variable "OBJCPLUS_INCLUDE_PATH")
742 (files '("include")))
743 (search-path-specification
744 (variable "LIBRARY_PATH")
745 (files '("lib" "lib64"))))))
746
747 (define-public gcc-objc++ gcc-objc++-5)
748
749 (define (make-libstdc++-doc gcc)
750 "Return a package with the libstdc++ documentation for GCC."
751 (package
752 (inherit gcc)
753 (name "libstdc++-doc")
754 (version (package-version gcc))
755 (synopsis "GNU libstdc++ documentation")
756 (outputs '("out"))
757 (native-inputs `(("doxygen" ,doxygen)
758 ("texinfo" ,texinfo)
759 ("libxml2" ,libxml2)
760 ("libxslt" ,libxslt)
761 ("docbook-xml" ,docbook-xml)
762 ("docbook-xsl" ,docbook-xsl)
763 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
764 (inputs '())
765 (propagated-inputs '())
766 (arguments
767 '(#:out-of-source? #t
768 #:tests? #f ;it's just documentation
769 #:phases (modify-phases %standard-phases
770 (add-before 'configure 'chdir
771 (lambda _
772 (chdir "libstdc++-v3")))
773 (add-before 'configure 'set-xsl-directory
774 (lambda* (#:key inputs #:allow-other-keys)
775 (let ((docbook (assoc-ref inputs "docbook-xsl")))
776 (substitute* (find-files "doc"
777 "^Makefile\\.in$")
778 (("@XSL_STYLE_DIR@")
779 (string-append
780 docbook "/xml/xsl/"
781 (strip-store-file-name docbook)))))))
782 (replace 'build
783 (lambda _
784 ;; XXX: There's also a 'doc-info' target, but it
785 ;; relies on docbook2X, which itself relies on
786 ;; DocBook 4.1.2, which is not really usable
787 ;; (lacks a catalog.xml.)
788 (zero? (system* "make"
789 "doc-html"
790 "doc-man"))))
791 (replace 'install
792 (lambda* (#:key outputs #:allow-other-keys)
793 (let ((out (assoc-ref outputs "out")))
794 (zero? (system* "make"
795 "doc-install-html"
796 "doc-install-man"))))))))))
797
798 (define-public libstdc++-doc-4.9
799 (make-libstdc++-doc gcc-4.9))
800
801 (define-public libstdc++-doc-5
802 (make-libstdc++-doc gcc-5))
803
804 (define-public isl
805 (package
806 (name "isl")
807 (version "0.18")
808 (source (origin
809 (method url-fetch)
810 (uri (list (string-append
811 "http://isl.gforge.inria.fr/isl-"
812 version
813 ".tar.bz2")
814 (string-append %gcc-infrastructure
815 name "-" version ".tar.gz")))
816 (sha256
817 (base32
818 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))
819 (build-system gnu-build-system)
820 (inputs `(("gmp" ,gmp)))
821 (home-page "http://isl.gforge.inria.fr/")
822 (synopsis
823 "Manipulating sets and relations of integer points \
824 bounded by linear constraints")
825 (description
826 "isl is a library for manipulating sets and relations of integer points
827 bounded by linear constraints. Supported operations on sets include
828 intersection, union, set difference, emptiness check, convex hull, (integer)
829 affine hull, integer projection, computing the lexicographic minimum using
830 parametric integer programming, coalescing and parametric vertex
831 enumeration. It also includes an ILP solver based on generalized basis
832 reduction, transitive closures on maps (which may encode infinite graphs),
833 dependence analysis and bounds on piecewise step-polynomials.")
834 (license lgpl2.1+)))
835
836 (define-public isl-0.11
837 (package
838 (inherit isl)
839 (name "isl")
840 (version "0.11.1")
841 (source (origin
842 (method url-fetch)
843 (uri (list (string-append
844 "http://isl.gforge.inria.fr/isl-"
845 version
846 ".tar.bz2")
847 (string-append %gcc-infrastructure
848 name "-" version ".tar.gz")))
849 (sha256
850 (base32
851 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
852 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
853
854 (define-public cloog
855 (package
856 (name "cloog")
857 (version "0.18.0")
858 (source
859 (origin
860 (method url-fetch)
861 (uri (list (string-append
862 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
863 version
864 ".tar.gz")
865 (string-append %gcc-infrastructure
866 name "-" version ".tar.gz")))
867 (sha256
868 (base32
869 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
870 (file-name (string-append name "-" version ".tar.gz"))))
871 (build-system gnu-build-system)
872 (inputs `(("gmp" ,gmp)
873 ("isl" ,isl-0.11)))
874 (arguments '(#:configure-flags '("--with-isl=system")))
875 (home-page "http://www.cloog.org/")
876 (synopsis "Library to generate code for scanning Z-polyhedra")
877 (description
878 "CLooG is a free software library to generate code for scanning
879 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
880 reaches each integral point of one or more parameterized polyhedra.
881 CLooG has been originally written to solve the code generation problem
882 for optimizing compilers based on the polytope model. Nevertheless it
883 is used now in various area e.g., to build control automata for
884 high-level synthesis or to find the best polynomial approximation of a
885 function. CLooG may help in any situation where scanning polyhedra
886 matters. While the user has full control on generated code quality,
887 CLooG is designed to avoid control overhead and to produce a very
888 effective code.")
889 (license gpl2+)))
890
891 (define-public gnu-c-manual
892 (package
893 (name "gnu-c-manual")
894 (version "0.2.5")
895 (source (origin
896 (method url-fetch)
897 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
898 version ".tar.gz"))
899 (sha256
900 (base32
901 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
902 (build-system gnu-build-system)
903 (native-inputs `(("texinfo" ,texinfo)))
904 (arguments
905 '(#:phases (modify-phases %standard-phases
906 (delete 'configure)
907 (delete 'check)
908 (replace 'build
909 (lambda _
910 (zero? (system* "make"
911 "gnu-c-manual.info"
912 "gnu-c-manual.html"))))
913 (replace 'install
914 (lambda* (#:key outputs #:allow-other-keys)
915 (let* ((out (assoc-ref outputs "out"))
916 (info (string-append out "/share/info"))
917 (html (string-append
918 out "/share/doc/gnu-c-manual")))
919 (mkdir-p info)
920 (mkdir-p html)
921
922 (for-each (lambda (file)
923 (copy-file file
924 (string-append info "/"
925 file)))
926 (find-files "." "\\.info(-[0-9])?$"))
927 (for-each (lambda (file)
928 (copy-file file
929 (string-append html "/"
930 file)))
931 (find-files "." "\\.html$"))
932 #t))))))
933 (synopsis "Reference manual for the C programming language")
934 (description
935 "This is a reference manual for the C programming language, as
936 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
937 to be a tutorial of the language. Rather, it outlines all of the constructs
938 of the language. Library functions are not included.")
939 (home-page "https://www.gnu.org/software/gnu-c-manual/")
940 (license fdl1.3+)))