gnu: Add libusbmuxd.
[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-4.9-libsanitizer-ustat.patch"
402 "gcc-arm-bug-71399.patch"
403 "gcc-asan-missing-include.patch"
404 "gcc-libvtv-runpath.patch"
405 "gcc-fix-texi2pod.patch"))
406 (modules '((guix build utils)))
407 ;; This is required for building with glibc-2.26.
408 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
409 (snippet
410 '(begin
411 (for-each
412 (lambda (dir)
413 (substitute* (string-append "libgcc/config/"
414 dir "/linux-unwind.h")
415 (("struct ucontext") "ucontext_t")))
416 '("aarch64" "alpha" "bfin" "i386" "m68k" "nios2"
417 "pa" "sh" "tilepro" "xtensa"))
418 #t))))
419 ;; Override inherited texinfo-5 with latest version.
420 (native-inputs `(("perl" ,perl) ;for manpages
421 ("texinfo" ,texinfo)))))
422
423 (define-public gcc-5
424 ;; Note: GCC >= 5 ships with .info files but 'make install' fails to install
425 ;; them in a VPATH build.
426 (package (inherit gcc-4.9)
427 (version "5.5.0")
428 (source (origin
429 (method url-fetch)
430 (uri (string-append "mirror://gnu/gcc/gcc-"
431 version "/gcc-" version ".tar.xz"))
432 (sha256
433 (base32
434 "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"))
435 (patches (search-patches "gcc-arm-bug-71399.patch"
436 "gcc-libsanitizer-ustat.patch"
437 "gcc-strmov-store-file-names.patch"
438 "gcc-5.0-libvtv-runpath.patch"
439 "gcc-5-source-date-epoch-1.patch"
440 "gcc-5-source-date-epoch-2.patch"
441 "gcc-fix-texi2pod.patch"))
442 (modules '((guix build utils)))
443 (snippet
444 ;; Fix 'libcc1/configure' error when cross-compiling GCC.
445 ;; Without that, 'libcc1/configure' wrongfully determines that
446 ;; '-rdynamic' support is missing because $gcc_cv_objdump is
447 ;; empty:
448 ;;
449 ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67590
450 ;; http://cgit.openembedded.org/openembedded-core/commit/?id=f6e47aa9b12f9ab61530c40e0343f451699d9077
451 '(begin
452 (substitute* "libcc1/configure"
453 (("\\$gcc_cv_objdump -T")
454 "$OBJDUMP_FOR_TARGET -T"))
455 #t))))
456 (inputs
457 `(;; GCC5 needs <isl/band.h> which is removed in later versions.
458 ("isl" ,isl-0.18)
459 ,@(package-inputs gcc-4.7)))))
460
461 (define-public gcc-6
462 (package
463 (inherit gcc-5)
464 (version "6.5.0")
465 (source (origin
466 (method url-fetch)
467 (uri (string-append "mirror://gnu/gcc/gcc-"
468 version "/gcc-" version ".tar.xz"))
469 (sha256
470 (base32
471 "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"))
472 (patches (search-patches "gcc-strmov-store-file-names.patch"
473 "gcc-6-source-date-epoch-1.patch"
474 "gcc-6-source-date-epoch-2.patch"
475 "gcc-5.0-libvtv-runpath.patch"))))
476 (inputs
477 `(("isl" ,isl)
478 ,@(package-inputs gcc-4.7)))
479
480 (native-search-paths
481 ;; We have to use 'CPATH' for GCC > 5, not 'C_INCLUDE_PATH' & co., due to
482 ;; <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129>.
483 (list (search-path-specification
484 (variable "CPATH")
485 (files '("include")))
486 (search-path-specification
487 (variable "LIBRARY_PATH")
488 (files '("lib" "lib64")))))))
489
490 (define-public gcc-7
491 (package
492 (inherit gcc-6)
493 (version "7.4.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 "0lgy170b0pp60j9cczqkmaqyjjb584vfamj4c30swd7k0j6y5pgd"))
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 (define-public gcc-8
509 (package
510 (inherit gcc-7)
511 (version "8.2.0")
512 (source (origin
513 (method url-fetch)
514 (uri (string-append "mirror://gnu/gcc/gcc-"
515 version "/gcc-" version ".tar.xz"))
516 (sha256
517 (base32
518 "10007smilswiiv2ymazr3b6x2i933c0ycxrr529zh4r6p823qv0r"))
519 (patches (search-patches "gcc-8-strmov-store-file-names.patch"
520 "gcc-5.0-libvtv-runpath.patch"))))))
521
522 ;; Note: When changing the default gcc version, update
523 ;; the gcc-toolchain-* definitions and the gfortran definition
524 ;; accordingly.
525 (define-public gcc gcc-5)
526
527 (define-public (make-libstdc++ gcc)
528 "Return a libstdc++ package based on GCC. The primary use case is when
529 using compilers other than GCC."
530 (package
531 (inherit gcc)
532 (name "libstdc++")
533 (arguments
534 `(#:out-of-source? #t
535 #:phases (alist-cons-before
536 'configure 'chdir
537 (lambda _
538 (chdir "libstdc++-v3")
539 #t)
540 %standard-phases)
541 #:configure-flags `("--disable-libstdcxx-pch"
542 ,(string-append "--with-gxx-include-dir="
543 (assoc-ref %outputs "out")
544 "/include"))))
545 (outputs '("out" "debug"))
546 (inputs '())
547 (native-inputs '())
548 (propagated-inputs '())
549 (synopsis "GNU C++ standard library")))
550
551 (define-public libstdc++-4.9
552 (make-libstdc++ gcc-4.9))
553
554 (define (make-libiberty gcc)
555 "Return a libiberty package based on GCC."
556 (package
557 (inherit gcc)
558 (name "libiberty")
559 (arguments
560 `(#:out-of-source? #t
561 #:phases
562 (modify-phases %standard-phases
563 (add-before 'configure 'chdir
564 (lambda _
565 (chdir "libiberty")
566 #t))
567 (replace
568 'install
569 (lambda* (#:key outputs #:allow-other-keys)
570 (let* ((out (assoc-ref outputs "out"))
571 (lib (string-append out "/lib/"))
572 (include (string-append out "/include/")))
573 (mkdir-p lib)
574 (mkdir-p include)
575 (copy-file "libiberty.a"
576 (string-append lib "libiberty.a"))
577 (copy-file "../include/libiberty.h"
578 (string-append include "libiberty.h"))
579 #t))))))
580 (inputs '())
581 (outputs '("out"))
582 (native-inputs '())
583 (propagated-inputs '())
584 (synopsis "Collection of subroutines used by various GNU programs")))
585
586 (define-public libiberty
587 (make-libiberty gcc))
588
589 (define* (custom-gcc gcc name languages
590 #:optional
591 (search-paths (package-native-search-paths gcc))
592 #:key (separate-lib-output? #t))
593 "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS
594 as the 'native-search-paths' field."
595 (package (inherit gcc)
596 (name name)
597 (outputs (if separate-lib-output?
598 (package-outputs gcc)
599 (delete "lib" (package-outputs gcc))))
600 (native-search-paths search-paths)
601 (arguments
602 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
603 (guix build utils)
604 (ice-9 regex)
605 (srfi srfi-1)
606 (srfi srfi-26))
607 ,@(package-arguments gcc))
608 ((#:configure-flags flags)
609 `(cons (string-append "--enable-languages="
610 ,(string-join languages ","))
611 (remove (cut string-match "--enable-languages.*" <>)
612 ,flags)))
613 ((#:phases phases)
614 `(modify-phases ,phases
615 (add-after 'install 'remove-broken-or-conflicting-files
616 (lambda* (#:key outputs #:allow-other-keys)
617 (for-each delete-file
618 (find-files (string-append (assoc-ref outputs "out") "/bin")
619 ".*(c\\+\\+|cpp|g\\+\\+|gcov|gcc|gcc-.*)"))
620 #t))))))))
621
622 (define %generic-search-paths
623 ;; This is the language-neutral search path for GCC. Entries in $CPATH are
624 ;; not considered "system headers", which means GCC can raise warnings for
625 ;; issues in those headers. 'CPATH' is the only one that works for
626 ;; front-ends not in the C family.
627 (list (search-path-specification
628 (variable "CPATH")
629 (files '("include")))
630 (search-path-specification
631 (variable "LIBRARY_PATH")
632 (files '("lib" "lib64")))))
633
634 (define-public gfortran-4.8
635 (custom-gcc gcc-4.8 "gfortran" '("fortran")
636 %generic-search-paths))
637
638 (define-public gfortran-4.9
639 (custom-gcc gcc-4.9 "gfortran" '("fortran")
640 %generic-search-paths))
641
642 (define-public gfortran-5
643 (custom-gcc gcc-5 "gfortran" '("fortran")
644 %generic-search-paths))
645
646 (define-public gfortran-6
647 (custom-gcc gcc-6 "gfortran" '("fortran")
648 %generic-search-paths))
649
650 (define-public gfortran-7
651 (custom-gcc gcc-7 "gfortran" '("fortran")
652 %generic-search-paths))
653
654 (define-public gfortran-8
655 (custom-gcc gcc-8 "gfortran" '("fortran")
656 %generic-search-paths))
657
658 (define-public gfortran
659 ;; Note: Update this when GCC changes! We cannot use
660 ;; (custom-gcc gcc "fortran" …) because that would lead to a package object
661 ;; that is not 'eq?' with GFORTRAN-5, and thus 'fold-packages' would
662 ;; report two gfortran@5 that are in fact identical.
663 gfortran-5)
664
665 (define-public gccgo-4.9
666 (custom-gcc gcc-4.9 "gccgo" '("go")
667 %generic-search-paths
668 ;; Suppress the separate "lib" output, because otherwise the
669 ;; "lib" and "out" outputs would refer to each other, creating
670 ;; a cyclic dependency. <http://debbugs.gnu.org/18101>
671 #:separate-lib-output? #f))
672
673 (define-public gcc-objc-4.8
674 (custom-gcc gcc-4.8 "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-4.9
683 (custom-gcc gcc-4.9 "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-5
692 (custom-gcc gcc-5 "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-6
701 (custom-gcc gcc-6 "gcc-objc" '("objc")
702 (list (search-path-specification
703 (variable "OBJC_INCLUDE_PATH")
704 (files '("include")))
705 (search-path-specification
706 (variable "LIBRARY_PATH")
707 (files '("lib" "lib64"))))))
708
709 (define-public gcc-objc-7
710 (custom-gcc gcc-7 "gcc-objc" '("objc")
711 (list (search-path-specification
712 (variable "OBJC_INCLUDE_PATH")
713 (files '("include")))
714 (search-path-specification
715 (variable "LIBRARY_PATH")
716 (files '("lib" "lib64"))))))
717
718 (define-public gcc-objc-8
719 (custom-gcc gcc-8 "gcc-objc" '("objc")
720 (list (search-path-specification
721 (variable "OBJC_INCLUDE_PATH")
722 (files '("include")))
723 (search-path-specification
724 (variable "LIBRARY_PATH")
725 (files '("lib" "lib64"))))))
726
727 (define-public gcc-objc gcc-objc-5)
728
729 (define-public gcc-objc++-4.8
730 (custom-gcc gcc-4.8 "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++-4.9
739 (custom-gcc gcc-4.9 "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++-5
748 (custom-gcc gcc-5 "gcc-objc++" '("obj-c++")
749 (list (search-path-specification
750 (variable "OBJCPLUS_INCLUDE_PATH")
751 (files '("include")))
752 (search-path-specification
753 (variable "LIBRARY_PATH")
754 (files '("lib" "lib64"))))))
755
756 (define-public gcc-objc++-6
757 (custom-gcc gcc-6 "gcc-objc++" '("obj-c++")
758 (list (search-path-specification
759 (variable "OBJCPLUS_INCLUDE_PATH")
760 (files '("include")))
761 (search-path-specification
762 (variable "LIBRARY_PATH")
763 (files '("lib" "lib64"))))))
764
765 (define-public gcc-objc++-7
766 (custom-gcc gcc-7 "gcc-objc++" '("obj-c++")
767 (list (search-path-specification
768 (variable "OBJCPLUS_INCLUDE_PATH")
769 (files '("include")))
770 (search-path-specification
771 (variable "LIBRARY_PATH")
772 (files '("lib" "lib64"))))))
773
774 (define-public gcc-objc++-8
775 (custom-gcc gcc-8 "gcc-objc++" '("obj-c++")
776 (list (search-path-specification
777 (variable "OBJCPLUS_INCLUDE_PATH")
778 (files '("include")))
779 (search-path-specification
780 (variable "LIBRARY_PATH")
781 (files '("lib" "lib64"))))))
782
783 (define-public gcc-objc++ gcc-objc++-5)
784
785 (define (make-libstdc++-doc gcc)
786 "Return a package with the libstdc++ documentation for GCC."
787 (package
788 (inherit gcc)
789 (name "libstdc++-doc")
790 (version (package-version gcc))
791 (synopsis "GNU libstdc++ documentation")
792 (outputs '("out"))
793 (native-inputs `(("doxygen" ,doxygen)
794 ("texinfo" ,texinfo)
795 ("libxml2" ,libxml2)
796 ("libxslt" ,libxslt)
797 ("docbook-xml" ,docbook-xml)
798 ("docbook-xsl" ,docbook-xsl)
799 ("graphviz" ,graphviz))) ;for 'dot', invoked by 'doxygen'
800 (inputs '())
801 (propagated-inputs '())
802 (arguments
803 '(#:out-of-source? #t
804 #:tests? #f ;it's just documentation
805 #:phases (modify-phases %standard-phases
806 (add-before 'configure 'chdir
807 (lambda _
808 (chdir "libstdc++-v3")
809 #t))
810 (add-before 'configure 'set-xsl-directory
811 (lambda* (#:key inputs #:allow-other-keys)
812 (let ((docbook (assoc-ref inputs "docbook-xsl")))
813 (substitute* (find-files "doc"
814 "^Makefile\\.in$")
815 (("@XSL_STYLE_DIR@")
816 (string-append
817 docbook "/xml/xsl/"
818 (strip-store-file-name docbook))))
819 #t)))
820 (replace 'build
821 (lambda _
822 ;; XXX: There's also a 'doc-info' target, but it
823 ;; relies on docbook2X, which itself relies on
824 ;; DocBook 4.1.2, which is not really usable
825 ;; (lacks a catalog.xml.)
826 (invoke "make"
827 "doc-html"
828 "doc-man")))
829 (replace 'install
830 (lambda* (#:key outputs #:allow-other-keys)
831 (let ((out (assoc-ref outputs "out")))
832 (invoke "make"
833 "doc-install-html"
834 "doc-install-man")))))))))
835
836 (define-public libstdc++-doc-4.9
837 (make-libstdc++-doc gcc-4.9))
838
839 (define-public libstdc++-doc-5
840 (make-libstdc++-doc gcc-5))
841
842 (define-public isl
843 (package
844 (name "isl")
845 (version "0.19")
846 (source (origin
847 (method url-fetch)
848 (uri (list (string-append
849 "http://isl.gforge.inria.fr/isl-"
850 version
851 ".tar.bz2")
852 (string-append %gcc-infrastructure
853 name "-" version ".tar.gz")))
854 (sha256
855 (base32
856 "1n4yz9rj24mv226hqbpw210ifvqkn8dgvpnkzf0s0lkq9zrjd5ym"))))
857 (build-system gnu-build-system)
858 (inputs `(("gmp" ,gmp)))
859 (home-page "http://isl.gforge.inria.fr/")
860 (synopsis
861 "Manipulating sets and relations of integer points \
862 bounded by linear constraints")
863 (description
864 "isl is a library for manipulating sets and relations of integer points
865 bounded by linear constraints. Supported operations on sets include
866 intersection, union, set difference, emptiness check, convex hull, (integer)
867 affine hull, integer projection, computing the lexicographic minimum using
868 parametric integer programming, coalescing and parametric vertex
869 enumeration. It also includes an ILP solver based on generalized basis
870 reduction, transitive closures on maps (which may encode infinite graphs),
871 dependence analysis and bounds on piecewise step-polynomials.")
872 (license lgpl2.1+)))
873
874 (define-public isl-0.18
875 (package
876 (inherit isl)
877 (version "0.18")
878 (source (origin
879 (method url-fetch)
880 (uri (list (string-append "http://isl.gforge.inria.fr/isl-"
881 version ".tar.bz2")
882 (string-append %gcc-infrastructure
883 "isl-" version ".tar.gz")))
884 (sha256
885 (base32
886 "06ybml6llhi4i56q90jnimbcgk1lpcdwhy9nxdxra2hxz3bhz2vb"))))))
887
888 (define-public isl-0.11
889 (package
890 (inherit isl)
891 (name "isl")
892 (version "0.11.1")
893 (source (origin
894 (method url-fetch)
895 (uri (list (string-append
896 "http://isl.gforge.inria.fr/isl-"
897 version
898 ".tar.bz2")
899 (string-append %gcc-infrastructure
900 name "-" version ".tar.gz")))
901 (sha256
902 (base32
903 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))
904 (patches (search-patches "isl-0.11.1-aarch64-support.patch"))))))
905
906 (define-public cloog
907 (package
908 (name "cloog")
909 (version "0.18.0")
910 (source
911 (origin
912 (method url-fetch)
913 (uri (list (string-append
914 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
915 version
916 ".tar.gz")
917 (string-append %gcc-infrastructure
918 name "-" version ".tar.gz")))
919 (sha256
920 (base32
921 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
922 (file-name (string-append name "-" version ".tar.gz"))))
923 (build-system gnu-build-system)
924 (inputs `(("gmp" ,gmp)
925 ("isl" ,isl-0.11)))
926 (arguments '(#:configure-flags '("--with-isl=system")))
927 (home-page "http://www.cloog.org/")
928 (synopsis "Library to generate code for scanning Z-polyhedra")
929 (description
930 "CLooG is a free software library to generate code for scanning
931 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
932 reaches each integral point of one or more parameterized polyhedra.
933 CLooG has been originally written to solve the code generation problem
934 for optimizing compilers based on the polytope model. Nevertheless it
935 is used now in various area e.g., to build control automata for
936 high-level synthesis or to find the best polynomial approximation of a
937 function. CLooG may help in any situation where scanning polyhedra
938 matters. While the user has full control on generated code quality,
939 CLooG is designed to avoid control overhead and to produce a very
940 effective code.")
941 (license gpl2+)))
942
943 (define-public gnu-c-manual
944 (package
945 (name "gnu-c-manual")
946 (version "0.2.5")
947 (source (origin
948 (method url-fetch)
949 (uri (string-append "mirror://gnu/gnu-c-manual/gnu-c-manual-"
950 version ".tar.gz"))
951 (sha256
952 (base32
953 "1sfsj9256w18qzylgag2h5h377aq8in8929svblfnj9svfriqcys"))))
954 (build-system gnu-build-system)
955 (native-inputs `(("texinfo" ,texinfo)))
956 (arguments
957 '(#:phases (modify-phases %standard-phases
958 (delete 'configure)
959 (delete 'check)
960 (replace 'build
961 (lambda _
962 (invoke "make"
963 "gnu-c-manual.info"
964 "gnu-c-manual.html")))
965 (replace 'install
966 (lambda* (#:key outputs #:allow-other-keys)
967 (let* ((out (assoc-ref outputs "out"))
968 (info (string-append out "/share/info"))
969 (html (string-append
970 out "/share/doc/gnu-c-manual")))
971 (mkdir-p info)
972 (mkdir-p html)
973
974 (for-each (lambda (file)
975 (copy-file file
976 (string-append info "/"
977 file)))
978 (find-files "." "\\.info(-[0-9])?$"))
979 (for-each (lambda (file)
980 (copy-file file
981 (string-append html "/"
982 file)))
983 (find-files "." "\\.html$"))
984 #t))))))
985 (synopsis "Reference manual for the C programming language")
986 (description
987 "This is a reference manual for the C programming language, as
988 implemented by the GNU C Compiler (gcc). As a reference, it is not intended
989 to be a tutorial of the language. Rather, it outlines all of the constructs
990 of the language. Library functions are not included.")
991 (home-page "https://www.gnu.org/software/gnu-c-manual/")
992 (license fdl1.3+)))