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