1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013 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 (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix utils)
31 #:use-module (ice-9 regex))
33 (define %gcc-infrastructure
34 ;; Base URL for GCC's infrastructure.
35 "ftp://gcc.gnu.org/pub/gcc/infrastructure/")
37 (define-public (gcc-configure-flags-for-triplet target)
38 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
40 The purpose of this procedure is to translate extended GNU triplets---e.g.,
41 where the OS part is overloaded to denote a specific ABI---into GCC
42 `configure' options. We take extended GNU triplets that glibc recognizes."
43 (cond ((string-match "^mips64el.*gnuabin?64$" target)
44 ;; Triplets recognized by glibc as denoting the N64 ABI; see
45 ;; ports/sysdeps/mips/preconfigure.
48 ;; TODO: Add `armel.*gnueabi', `hf', etc.
51 (define-public gcc-4.7
52 (let* ((stripped? #t) ; TODO: make this a parameter
55 ;; Return the `_FOR_TARGET' variables that are needed when
56 ;; cross-compiling GCC.
57 (let ((target (%current-target-system)))
59 (map (lambda (var tool)
60 (string-append (string-append var "_FOR_TARGET")
62 '("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP")
63 '("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip"))
67 ;; This is terrible. Since we have two levels of quasiquotation,
68 ;; we have to do this convoluted thing just so we can insert the
69 ;; contents of (maybe-target-tools).
73 "--enable-languages=c,c++"
76 ;; No pre-compiled libstdc++ headers, to save space.
77 "--disable-libstdcxx-pch"
79 "--with-local-prefix=/no-gcc-local-prefix"
81 ,(let ((libc (assoc-ref %build-inputs "libc")))
83 (string-append "--with-native-system-header-dir=" libc
85 "--without-headers")))
87 ;; When cross-compiling GCC, pass the right options for the
89 (or (and=> (%current-target-system)
90 gcc-configure-flags-for-triplet)
93 (maybe-target-tools))))))
99 (uri (string-append "mirror://gnu/gcc/gcc-"
100 version "/gcc-" version ".tar.bz2"))
103 "1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g"))))
104 (build-system gnu-build-system)
105 (inputs `(("gmp" ,gmp)
113 ;; GCC is one of the few packages that doesn't ship .info files.
114 (native-inputs `(("texinfo" ,texinfo)))
117 `(#:out-of-source? #t
118 #:strip-binaries? ,stripped?
119 #:configure-flags ,(configure-flags)
121 (let* ((libc (assoc-ref %build-inputs "libc"))
122 (libc-native (or (assoc-ref %build-inputs "libc-native")
125 (list (string-append "LDFLAGS_FOR_TARGET="
127 "-Wl,-dynamic-linker "
129 ,(glibc-dynamic-linker)))
132 ;; Native programs like 'genhooks' also need that right.
133 ,(string-append "LDFLAGS="
134 "-Wl,-rpath=" libc-native "/lib "
135 "-Wl,-dynamic-linker "
136 "-Wl," libc-native ,(glibc-dynamic-linker))
137 ,(string-append "BOOT_CFLAGS=-O2 "
138 ,(if stripped? "-g0" "-g"))))
143 'configure 'pre-configure
144 (lambda* (#:key inputs outputs #:allow-other-keys)
145 (let ((out (assoc-ref outputs "out"))
146 (libc (assoc-ref inputs "libc")))
148 ;; The following is not performed for `--without-headers'
149 ;; cross-compiler builds.
151 ;; Fix the dynamic linker's file name.
152 (substitute* (find-files "gcc/config"
153 "^linux(64|-elf)?\\.h$")
154 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
155 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
157 (string-append libc ,(glibc-dynamic-linker)))))
159 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
160 ;; `crt{begin,end}.o', which come with GCC.
161 (substitute* (find-files "gcc/config"
163 (("#define GNU_USER_TARGET_LIB_SPEC (.*)$" _ suffix)
164 ;; Note that with this "lib" spec, we may still add a
165 ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
166 ;; There's not much that can be done to avoid it, though.
167 (format #f "#define GNU_USER_TARGET_LIB_SPEC \
168 \"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a"
169 libc libc out out suffix))
170 (("#define GNU_USER_TARGET_STARTFILE_SPEC.*$" line)
171 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
172 #define STANDARD_STARTFILE_PREFIX_2 \"\"
176 ;; Use '-lgcc_s' rather than '--as-needed -lgcc_s', so that
177 ;; libgcc_s.so is always found by those programs that use
178 ;; 'pthread_cancel' (glibc dlopens libgcc_s.so when
179 ;; pthread_cancel support is needed, but having it in the
180 ;; application's RUNPATH isn't enough; see
181 ;; <http://sourceware.org/ml/libc-help/2013-11/msg00023.html>.)
182 ;; Also, "gcc_cv_ld_as_needed=no" as a configure flag doesn't
184 (substitute* "gcc/gcc.c"
185 (("#ifndef USE_LD_AS_NEEDED.*$" line)
186 (string-append "#undef USE_LD_AS_NEEDED\n" line)))
188 ;; Don't retain a dependency on the build-time sed.
189 (substitute* "fixincludes/fixincl.x"
190 (("static char const sed_cmd_z\\[\\] =.*;")
191 "static char const sed_cmd_z[] = \"sed\";"))))
194 'configure 'post-configure
196 ;; Don't store configure flags, to avoid retaining references to
197 ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
198 (substitute* "Makefile"
199 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
200 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
201 (alist-replace 'install
202 (lambda* (#:key outputs #:allow-other-keys)
208 %standard-phases)))))
211 (list (search-path-specification
213 (directories '("include")))
214 (search-path-specification
215 (variable "LIBRARY_PATH")
216 (directories '("lib" "lib64")))))
218 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
219 (synopsis "GNU Compiler Collection")
221 "GCC is the GNU Compiler Collection. It provides compiler front-ends
222 for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
223 Go. It also includes standard libraries for these languages.")
225 (home-page "http://gcc.gnu.org/"))))
227 (define-public gcc-4.8
228 (package (inherit gcc-4.7)
232 (uri (string-append "mirror://gnu/gcc/gcc-"
233 version "/gcc-" version ".tar.bz2"))
236 "1j6dwgby4g3p3lz7zkss32ghr45zpdidrg8xvazvn91lqxv25p09"))))))
238 (define (custom-gcc gcc name languages)
239 "Return a custom version of GCC that supports LANGUAGES."
240 (package (inherit gcc)
243 (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system)
248 ,@(package-arguments gcc))
249 ((#:configure-flags flags)
250 `(cons (string-append "--enable-languages="
251 ,(string-join languages ","))
252 (remove (cut string-match "--enable-languages.*" <>)
255 (define-public gfortran-4.8
256 (custom-gcc gcc-4.8 "gfortran" '("fortran")))
258 (define-public gccgo-4.8
259 (custom-gcc gcc-4.8 "gccgo" '("go")))
261 (define-public gcc-objc-4.8
262 (custom-gcc gcc-4.8 "gcc-objc" '("objc")))
264 (define-public gcc-objc++-4.8
265 (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++")))
273 (uri (list (string-append
274 "http://isl.gforge.inria.fr/isl-"
277 (string-append %gcc-infrastructure
278 name "-" version ".tar.gz")))
281 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))))
282 (build-system gnu-build-system)
283 (inputs `(("gmp" ,gmp)))
284 (home-page "http://isl.gforge.inria.fr/")
286 "A library for manipulating sets and relations of integer points bounded
287 by linear constraints")
289 "isl is a library for manipulating sets and relations of integer points
290 bounded by linear constraints. Supported operations on sets include
291 intersection, union, set difference, emptiness check, convex hull, (integer)
292 affine hull, integer projection, computing the lexicographic minimum using
293 parametric integer programming, coalescing and parametric vertex
294 enumeration. It also includes an ILP solver based on generalized basis
295 reduction, transitive closures on maps (which may encode infinite graphs),
296 dependence analysis and bounds on piecewise step-polynomials.")
306 (uri (list (string-append
307 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
310 (string-append %gcc-infrastructure
311 name "-" version ".tar.gz")))
314 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
315 (file-name (string-append name "-" version ".tar.gz"))))
316 (build-system gnu-build-system)
317 (inputs `(("gmp" ,gmp)
319 (arguments '(#:configure-flags '("--with-isl=system")))
320 (home-page "http://www.cloog.org/")
321 (synopsis "A library to generate code for scanning Z-polyhedra")
323 "CLooG is a free software library to generate code for scanning
324 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
325 reaches each integral point of one or more parameterized polyhedra.
326 CLooG has been originally written to solve the code generation problem
327 for optimizing compilers based on the polytope model. Nevertheless it
328 is used now in various area e.g., to build control automata for
329 high-level synthesis or to find the best polynomial approximation of a
330 function. CLooG may help in any situation where scanning polyhedra
331 matters. While the user has full control on generated code quality,
332 CLooG is designed to avoid control overhead and to produce a very
336 (define-public libelf
342 (uri (string-append "http://www.mr511.de/software/libelf-"
346 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
347 (build-system gnu-build-system)
348 (arguments '(#:phases (alist-replace
350 (lambda* (#:key outputs #:allow-other-keys)
351 ;; This old `configure' script doesn't support
352 ;; variables passed as arguments.
353 (let ((out (assoc-ref outputs "out")))
354 (setenv "CONFIG_SHELL" (which "bash"))
356 (system* "./configure"
357 (string-append "--prefix=" out)))))
359 (home-page "http://www.mr511.de/software/english.html")
360 (synopsis "An ELF object file access library")
361 (description "libelf is a C library to access ELF object files.")