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