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