1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (gnu packages gcc)
20 #:use-module ((guix licenses)
21 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+))
22 #:use-module (gnu packages)
23 #:use-module (gnu packages bootstrap)
24 #:use-module (gnu packages compression)
25 #:use-module (gnu packages multiprecision)
26 #:use-module (gnu packages texinfo)
27 #:use-module (gnu packages elf)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix utils)
32 #:use-module (ice-9 regex))
34 (define %gcc-infrastructure
35 ;; Base URL for GCC's infrastructure.
36 "ftp://gcc.gnu.org/pub/gcc/infrastructure/")
38 (define-public (gcc-configure-flags-for-triplet target)
39 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
41 The purpose of this procedure is to translate extended GNU triplets---e.g.,
42 where the OS part is overloaded to denote a specific ABI---into GCC
43 `configure' options. We take extended GNU triplets that glibc recognizes."
44 (cond ((string-match "^mips64el.*gnuabin?64$" target)
45 ;; Triplets recognized by glibc as denoting the N64 ABI; see
46 ;; ports/sysdeps/mips/preconfigure.
49 ;; TODO: Add `armel.*gnueabi', `hf', etc.
52 (define-public gcc-4.7
53 (let* ((stripped? #t) ; TODO: make this a parameter
56 ;; The 'install-strip' rule uses the native 'strip' instead of
57 ;; 'TARGET-strip' when cross-compiling. Thus, use 'install' in that
59 (if (and stripped? (not (%current-target-system)))
64 ;; Return the `_FOR_TARGET' variables that are needed when
65 ;; cross-compiling GCC.
66 (let ((target (%current-target-system)))
68 (map (lambda (var tool)
69 (string-append (string-append var "_FOR_TARGET")
71 '("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP")
72 '("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip"))
76 ;; This is terrible. Since we have two levels of quasiquotation,
77 ;; we have to do this convoluted thing just so we can insert the
78 ;; contents of (maybe-target-tools).
82 "--enable-languages=c,c++"
85 ;; No pre-compiled libstdc++ headers, to save space.
86 "--disable-libstdcxx-pch"
88 "--with-local-prefix=/no-gcc-local-prefix"
90 ;; With a separate "lib" output, the build system
91 ;; incorrectly guesses GPLUSPLUS_INCLUDE_DIR, so force
92 ;; it. (Don't use a versioned sub-directory, that's
94 ,(string-append "--with-gxx-include-dir="
95 (assoc-ref %outputs "out")
98 ,(let ((libc (assoc-ref %build-inputs "libc")))
100 (string-append "--with-native-system-header-dir=" libc
102 "--without-headers")))
104 ;; When cross-compiling GCC, pass the right options for the
106 (or (and=> (%current-target-system)
107 gcc-configure-flags-for-triplet)
110 (maybe-target-tools))))))
116 (uri (string-append "mirror://gnu/gcc/gcc-"
117 version "/gcc-" version ".tar.bz2"))
120 "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))))
121 (build-system gnu-build-system)
123 ;; Separate out the run-time support libraries because all the
124 ;; dynamic-linked objects depend on it.
125 (outputs '("out" ; commands, etc. (60+ MiB)
126 "lib")) ; libgcc_s, libgomp, etc. (15+ MiB)
128 (inputs `(("gmp" ,gmp)
136 ;; GCC is one of the few packages that doesn't ship .info files.
137 (native-inputs `(("texinfo" ,texinfo)))
140 `(#:out-of-source? #t
141 #:strip-binaries? ,stripped?
142 #:configure-flags ,(configure-flags)
144 ;; None of the flags below are needed when doing a Canadian cross.
145 ;; TODO: Simplify this.
146 ,(if (%current-target-system)
150 `(let* ((libc (assoc-ref %build-inputs "libc"))
151 (libc-native (or (assoc-ref %build-inputs "libc-native")
154 (list (string-append "LDFLAGS_FOR_TARGET="
156 "-Wl,-dynamic-linker "
158 ,(glibc-dynamic-linker)))
161 ;; Native programs like 'genhooks' also need that right.
162 ,(string-append "LDFLAGS="
163 "-Wl,-rpath=" libc-native "/lib "
164 "-Wl,-dynamic-linker "
165 "-Wl," libc-native ,(glibc-dynamic-linker))
166 ,(string-append "BOOT_CFLAGS=-O2 "
167 ,(if stripped? "-g0" "-g")))))
172 'configure 'pre-configure
173 (lambda* (#:key inputs outputs #:allow-other-keys)
174 (let ((libdir (or (assoc-ref outputs "lib")
175 (assoc-ref outputs "out")))
176 (libc (assoc-ref inputs "libc")))
178 ;; The following is not performed for `--without-headers'
179 ;; cross-compiler builds.
181 ;; Fix the dynamic linker's file name.
182 (substitute* (find-files "gcc/config"
183 "^linux(64|-elf)?\\.h$")
184 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
185 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
187 (string-append libc ,(glibc-dynamic-linker)))))
189 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
190 ;; `crt{begin,end}.o', which come with GCC.
191 (substitute* (find-files "gcc/config"
193 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
194 ;; Help libgcc_s.so be found (see also below.) Always use
195 ;; '-lgcc_s' so that libgcc_s.so is always found by those
196 ;; programs that use 'pthread_cancel' (glibc dlopens
197 ;; libgcc_s.so when pthread_cancel support is needed, but
198 ;; having it in the application's RUNPATH isn't enough; see
199 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
200 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
201 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib -lgcc_s}} \" ~a"
202 libc libc libdir libdir suffix))
203 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
204 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
205 #define STANDARD_STARTFILE_PREFIX_2 \"\"
209 ;; Don't retain a dependency on the build-time sed.
210 (substitute* "fixincludes/fixincl.x"
211 (("static char const sed_cmd_z\\[\\] =.*;")
212 "static char const sed_cmd_z[] = \"sed\";"))
214 ;; Move libstdc++*-gdb.py to the "lib" output to avoid a
215 ;; circularity between "out" and "lib". (Note:
216 ;; --with-python-dir is useless because it imposes $(prefix) as
217 ;; the parent directory.)
218 (substitute* "libstdc++-v3/python/Makefile.in"
220 (string-append "pythondir = " libdir "/share"
221 "/gcc-$(gcc_version)/python\n")))
223 ;; Avoid another circularity between the outputs: this #define
224 ;; ends up in auto-host.h in the "lib" output, referring to
225 ;; "out". (This variable is used to augment cpp's search path,
226 ;; but there's nothing useful to look for here.)
227 (substitute* "gcc/config.in"
228 (("PREFIX_INCLUDE_DIR")
229 "PREFIX_INCLUDE_DIR_isnt_necessary_here"))))
232 'configure 'post-configure
234 ;; Don't store configure flags, to avoid retaining references to
235 ;; build-time dependencies---e.g., `--with-ppl=/gnu/store/xxx'.
236 (substitute* "Makefile"
237 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
238 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
239 (alist-replace 'install
240 (lambda* (#:key outputs #:allow-other-keys)
242 (system* "make" ,(install-target))))
243 %standard-phases)))))
246 (list (search-path-specification
248 (directories '("include")))
249 (search-path-specification
250 (variable "LIBRARY_PATH")
251 (directories '("lib" "lib64")))))
253 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
254 (synopsis "GNU Compiler Collection")
256 "GCC is the GNU Compiler Collection. It provides compiler front-ends
257 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
258 Go. It also includes runtime support libraries for these languages.")
260 (home-page "http://gcc.gnu.org/"))))
262 (define-public gcc-4.8
263 (package (inherit gcc-4.7)
267 (uri (string-append "mirror://gnu/gcc/gcc-"
268 version "/gcc-" version ".tar.bz2"))
271 "07hg10zs7gnqz58my10ch0zygizqh0z0bz6pv4pgxx45n48lz3ka"))))))
273 (define-public gcc-4.9
274 (package (inherit gcc-4.7)
278 (uri (string-append "mirror://gnu/gcc/gcc-"
279 version "/gcc-" version ".tar.bz2"))
282 "0mqjxpw2klskls00lwx1k24pnyzm3whqxg3hk74c3sddgfllgc5r"))))))
284 (define (custom-gcc gcc name languages)
285 "Return a custom version of GCC that supports LANGUAGES."
286 (package (inherit gcc)
289 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
294 ,@(package-arguments gcc))
295 ((#:configure-flags flags)
296 `(cons (string-append "--enable-languages="
297 ,(string-join languages ","))
298 (remove (cut string-match "--enable-languages.*" <>)
301 (define-public gfortran-4.8
302 (custom-gcc gcc-4.8 "gfortran" '("fortran")))
304 (define-public gccgo-4.8
305 (custom-gcc gcc-4.8 "gccgo" '("go")))
307 (define-public gcc-objc-4.8
308 (custom-gcc gcc-4.8 "gcc-objc" '("objc")))
310 (define-public gcc-objc++-4.8
311 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")))
319 (uri (list (string-append
320 "http://isl.gforge.inria.fr/isl-"
323 (string-append %gcc-infrastructure
324 name "-" version ".tar.gz")))
327 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))))
328 (build-system gnu-build-system)
329 (inputs `(("gmp" ,gmp)))
330 (home-page "http://isl.gforge.inria.fr/")
332 "A library for manipulating sets and relations of integer points bounded
333 by linear constraints")
335 "isl is a library for manipulating sets and relations of integer points
336 bounded by linear constraints. Supported operations on sets include
337 intersection, union, set difference, emptiness check, convex hull, (integer)
338 affine hull, integer projection, computing the lexicographic minimum using
339 parametric integer programming, coalescing and parametric vertex
340 enumeration. It also includes an ILP solver based on generalized basis
341 reduction, transitive closures on maps (which may encode infinite graphs),
342 dependence analysis and bounds on piecewise step-polynomials.")
352 (uri (list (string-append
353 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
356 (string-append %gcc-infrastructure
357 name "-" version ".tar.gz")))
360 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
361 (file-name (string-append name "-" version ".tar.gz"))))
362 (build-system gnu-build-system)
363 (inputs `(("gmp" ,gmp)
365 (arguments '(#:configure-flags '("--with-isl=system")))
366 (home-page "http://www.cloog.org/")
367 (synopsis "A library to generate code for scanning Z-polyhedra")
369 "CLooG is a free software library to generate code for scanning
370 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
371 reaches each integral point of one or more parameterized polyhedra.
372 CLooG has been originally written to solve the code generation problem
373 for optimizing compilers based on the polytope model. Nevertheless it
374 is used now in various area e.g., to build control automata for
375 high-level synthesis or to find the best polynomial approximation of a
376 function. CLooG may help in any situation where scanning polyhedra
377 matters. While the user has full control on generated code quality,
378 CLooG is designed to avoid control overhead and to produce a very