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