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 (ice-9 regex))
32 (define %gcc-infrastructure
33 ;; Base URL for GCC's infrastructure.
34 "ftp://gcc.gnu.org/pub/gcc/infrastructure/")
36 (define-public (gcc-configure-flags-for-triplet target)
37 "Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
39 The purpose of this procedure is to translate extended GNU triplets---e.g.,
40 where the OS part is overloaded to denote a specific ABI---into GCC
41 `configure' options. We take extended GNU triplets that glibc recognizes."
42 (cond ((string-match "^mips64el.*gnuabin?64$" target)
43 ;; Triplets recognized by glibc as denoting the N64 ABI; see
44 ;; ports/sysdeps/mips/preconfigure.
47 ;; TODO: Add `armel.*gnueabi', `hf', etc.
50 (define-public gcc-4.7
51 (let* ((stripped? #t) ; TODO: make this a parameter
54 ;; Return the `_FOR_TARGET' variables that are needed when
55 ;; cross-compiling GCC.
56 (let ((target (%current-target-system)))
58 (map (lambda (var tool)
59 (string-append (string-append var "_FOR_TARGET")
61 '("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP")
62 '("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip"))
66 ;; This is terrible. Since we have two levels of quasiquotation,
67 ;; we have to do this convoluted thing just so we can insert the
68 ;; contents of (maybe-target-tools).
72 "--enable-languages=c,c++"
75 "--with-local-prefix=/no-gcc-local-prefix"
77 ,(let ((libc (assoc-ref %build-inputs "libc")))
79 (string-append "--with-native-system-header-dir=" libc
81 "--without-headers")))
83 ;; When cross-compiling GCC, pass the right options for the
85 (or (and=> (%current-target-system)
86 gcc-configure-flags-for-triplet)
89 (maybe-target-tools))))))
95 (uri (string-append "mirror://gnu/gcc/gcc-"
96 version "/gcc-" version ".tar.bz2"))
99 "1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g"))))
100 (build-system gnu-build-system)
101 (inputs `(("gmp" ,gmp)
109 ;; GCC is one of the few packages that doesn't ship .info files.
110 (native-inputs `(("texinfo" ,texinfo)))
113 `(#:out-of-source? #t
114 #:strip-binaries? ,stripped?
115 #:configure-flags ,(configure-flags)
117 (let ((libc (assoc-ref %build-inputs "libc")))
119 (list (string-append "LDFLAGS_FOR_TARGET="
121 "-Wl,-dynamic-linker "
123 ,(glibc-dynamic-linker)))
125 ,(string-append "BOOT_CFLAGS=-O2 "
126 ,(if stripped? "-g0" "-g"))))
131 'configure 'pre-configure
132 (lambda* (#:key inputs outputs #:allow-other-keys)
133 (let ((out (assoc-ref outputs "out"))
134 (libc (assoc-ref inputs "libc")))
136 ;; The following is not performed for `--without-headers'
137 ;; cross-compiler builds.
139 ;; Fix the dynamic linker's file name.
140 (substitute* (find-files "gcc/config"
141 "^linux(64|-elf)?\\.h$")
142 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
143 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
145 (string-append libc ,(glibc-dynamic-linker)))))
147 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
148 ;; `crt{begin,end}.o', which come with GCC.
149 (substitute* (find-files "gcc/config"
150 "^(gnu-user(64)?|linux-elf)\\.h$")
151 (("#define LIB_SPEC (.*)$" _ suffix)
152 ;; Note that with this "lib" spec, we may still add a
153 ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
154 ;; There's not much that can be done to avoid it, though.
155 (format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
156 %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a"
157 libc libc out out suffix))
158 (("#define STARTFILE_SPEC.*$" line)
159 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
160 #define STANDARD_STARTFILE_PREFIX_2 \"\"
164 ;; Don't retain a dependency on the build-time sed.
165 (substitute* "fixincludes/fixincl.x"
166 (("static char const sed_cmd_z\\[\\] =.*;")
167 "static char const sed_cmd_z[] = \"sed\";"))))
170 'configure 'post-configure
172 ;; Don't store configure flags, to avoid retaining references to
173 ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
174 (substitute* "Makefile"
175 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
176 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
177 (alist-replace 'install
178 (lambda* (#:key outputs #:allow-other-keys)
184 %standard-phases)))))
187 (list (search-path-specification
189 (directories '("include")))
190 (search-path-specification
191 (variable "LIBRARY_PATH")
192 (directories '("lib" "lib64")))))
194 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
195 (synopsis "GNU Compiler Collection")
197 "The GNU Compiler Collection includes compiler front ends for C, C++,
198 Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
199 libraries for these languages (libstdc++, libgcj, libgomp,...).
201 GCC development is a part of the GNU Project, aiming to improve the compiler
202 used in the GNU system including the GNU/Linux variant.")
204 (home-page "http://gcc.gnu.org/"))))
206 (define-public gcc-4.8
207 (package (inherit gcc-4.7)
211 (uri (string-append "mirror://gnu/gcc/gcc-"
212 version "/gcc-" version ".tar.bz2"))
215 "04sqn0ds17ys8l6zn7vyyvjz1a7hsk4zb0381vlw9wnr7az48nsl"))))))
223 (uri (list (string-append
224 "ftp://ftp.linux.student.kuleuven.be/pub/people/skimo/isl/isl-"
227 (string-append %gcc-infrastructure
228 name "-" version ".tar.gz")))
231 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))))
232 (build-system gnu-build-system)
233 (inputs `(("gmp" ,gmp)))
234 (home-page "http://www.kotnet.org/~skimo/isl/")
236 "A library for manipulating sets and relations of integer points bounded
237 by linear constraints")
239 "isl is a library for manipulating sets and relations of integer points
240 bounded by linear constraints. Supported operations on sets include
241 intersection, union, set difference, emptiness check, convex hull, (integer)
242 affine hull, integer projection, computing the lexicographic minimum using
243 parametric integer programming, coalescing and parametric vertex
244 enumeration. It also includes an ILP solver based on generalized basis
245 reduction, transitive closures on maps (which may encode infinite graphs),
246 dependence analysis and bounds on piecewise step-polynomials.")
256 (uri (list (string-append
257 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
260 (string-append %gcc-infrastructure
261 name "-" version ".tar.gz")))
264 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
265 (file-name (string-append name "-" version ".tar.gz"))))
266 (build-system gnu-build-system)
267 (inputs `(("gmp" ,gmp)
269 (arguments '(#:configure-flags '("--with-isl=system")))
270 (home-page "http://www.cloog.org/")
271 (synopsis "A library to generate code for scanning Z-polyhedra")
273 "CLooG is a free software library to generate code for scanning
274 Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
275 reaches each integral point of one or more parameterized polyhedra.
276 CLooG has been originally written to solve the code generation problem
277 for optimizing compilers based on the polytope model. Nevertheless it
278 is used now in various area e.g., to build control automata for
279 high-level synthesis or to find the best polynomial approximation of a
280 function. CLooG may help in any situation where scanning polyhedra
281 matters. While the user has full control on generated code quality,
282 CLooG is designed to avoid control overhead and to produce a very
286 (define-public libelf
292 (uri (string-append "http://www.mr511.de/software/libelf-"
296 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
297 (build-system gnu-build-system)
298 (arguments '(#:phases (alist-replace
300 (lambda* (#:key outputs #:allow-other-keys)
301 ;; This old `configure' script doesn't support
302 ;; variables passed as arguments.
303 (let ((out (assoc-ref outputs "out")))
304 (setenv "CONFIG_SHELL" (which "bash"))
306 (system* "./configure"
307 (string-append "--prefix=" out)))))
309 (home-page "http://www.mr511.de/software/english.html")
310 (synopsis "An ELF object file access library")
311 (description "libelf is a C library to access ELF object files.")