gnu: cross-base: Make `glibc-dynamic-linker' do the right thing.
[jackhill/guix/guix.git] / gnu / packages / gcc.scm
CommitLineData
e9c0b944
LC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18
19(define-module (gnu packages gcc)
c6d7e299
LC
20 #:use-module ((guix licenses)
21 #:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+))
e9c0b944
LC
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 (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system gnu))
29
832abc76
LC
30(define %gcc-infrastructure
31 ;; Base URL for GCC's infrastructure.
32 "ftp://gcc.gnu.org/pub/gcc/infrastructure/")
33
e9c0b944
LC
34(define-public gcc-4.7
35 (let ((stripped? #t)) ; TODO: make this a parameter
36 (package
37 (name "gcc")
3b401612 38 (version "4.7.3")
e9c0b944
LC
39 (source (origin
40 (method url-fetch)
41 (uri (string-append "mirror://gnu/gcc/gcc-"
42 version "/gcc-" version ".tar.bz2"))
43 (sha256
44 (base32
3b401612 45 "1hx9h64ivarlzi4hxvq42as5m9vlr5cyzaaq4gzj4i619zmkfz1g"))))
e9c0b944 46 (build-system gnu-build-system)
3b401612
LC
47 (inputs `(("gmp" ,gmp)
48 ("mpfr" ,mpfr)
49 ("mpc" ,mpc)
50 ("isl" ,isl)
51 ("cloog" ,cloog)
52 ("libelf" ,libelf)
53 ("zlib" ,zlib)))
e9c0b944
LC
54 (arguments
55 `(#:out-of-source? #t
56 #:strip-binaries? ,stripped?
57 #:configure-flags
58 `("--enable-plugin"
59 "--enable-languages=c,c++"
60 "--disable-multilib"
61
62 "--with-local-prefix=/no-gcc-local-prefix"
63
64 ,(let ((libc (assoc-ref %build-inputs "libc")))
65 (if libc
66 (string-append "--with-native-system-header-dir=" libc
67 "/include")
68 "--without-headers")))
69 #:make-flags
70 (let ((libc (assoc-ref %build-inputs "libc")))
71 `(,@(if libc
4928e500
LC
72 (list (string-append "LDFLAGS_FOR_TARGET="
73 "-B" libc "/lib "
e9c0b944
LC
74 "-Wl,-dynamic-linker "
75 "-Wl," libc
76 ,(glibc-dynamic-linker)))
77 '())
78 ,(string-append "BOOT_CFLAGS=-O2 "
79 ,(if stripped? "-g0" "-g"))))
80
81 #:tests? #f
82 #:phases
83 (alist-cons-before
84 'configure 'pre-configure
85 (lambda* (#:key inputs outputs #:allow-other-keys)
86 (let ((out (assoc-ref outputs "out"))
87 (libc (assoc-ref inputs "libc")))
88 (when libc
89 ;; The following is not performed for `--without-headers'
90 ;; cross-compiler builds.
91
92 ;; Fix the dynamic linker's file name.
93 (substitute* (find-files "gcc/config"
94 "^linux(64|-elf)?\\.h$")
95 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
96 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
97 suffix
98 (string-append libc ,(glibc-dynamic-linker)))))
99
100 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
101 ;; `crt{begin,end}.o', which come with GCC.
102 (substitute* (find-files "gcc/config"
103 "^(gnu-user(64)?|linux-elf)\\.h$")
104 (("#define LIB_SPEC (.*)$" _ suffix)
105 ;; Note that with this "lib" spec, we may still add a
106 ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
107 ;; There's not much that can be done to avoid it, though.
108 (format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
4928e500 109%{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a"
e9c0b944
LC
110 libc libc out out suffix))
111 (("#define STARTFILE_SPEC.*$" line)
112 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
113#define STANDARD_STARTFILE_PREFIX_2 \"\"
114~a~%"
115 libc line))))
116
117 ;; Don't retain a dependency on the build-time sed.
118 (substitute* "fixincludes/fixincl.x"
119 (("static char const sed_cmd_z\\[\\] =.*;")
120 "static char const sed_cmd_z[] = \"sed\";"))))
121
122 (alist-cons-after
123 'configure 'post-configure
124 (lambda _
125 ;; Don't store configure flags, to avoid retaining references to
126 ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
127 (substitute* "Makefile"
128 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
129 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
130 (alist-replace 'install
131 (lambda* (#:key outputs #:allow-other-keys)
132 (zero?
133 (system* "make"
134 ,(if stripped?
135 "install-strip"
136 "install"))))
137 %standard-phases)))))
138
a18eda27
LC
139 (native-search-paths
140 (list (search-path-specification
141 (variable "CPATH")
142 (directories '("include")))
143 (search-path-specification
144 (variable "LIBRARY_PATH")
145 (directories '("lib" "lib64")))))
146
e9c0b944 147 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
f50d2669 148 (synopsis "GNU Compiler Collection")
e9c0b944
LC
149 (description
150 "The GNU Compiler Collection includes compiler front ends for C, C++,
151Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
152libraries for these languages (libstdc++, libgcj, libgomp,...).
153
154GCC development is a part of the GNU Project, aiming to improve the compiler
155used in the GNU system including the GNU/Linux variant.")
156 (license gpl3+)
157 (home-page "http://gcc.gnu.org/"))))
832abc76 158
3b401612
LC
159(define-public gcc-4.8
160 ;; FIXME: Move to gcc.scm when Binutils is updated.
161 (package (inherit gcc-4.7)
162 (version "4.8.0")
163 (source (origin
164 (method url-fetch)
165 (uri (string-append "mirror://gnu/gcc/gcc-"
166 version "/gcc-" version ".tar.bz2"))
167 (sha256
168 (base32
169 "0b6cp9d1sas3vq6dj3zrgd134p9b569fqhbixb9cl7mp698zwdxh"))))))
170
832abc76
LC
171(define-public isl
172 (package
173 (name "isl")
174 (version "0.11.1")
175 (source (origin
176 (method url-fetch)
177 (uri (list (string-append
178 "ftp://ftp.linux.student.kuleuven.be/pub/people/skimo/isl/isl-"
179 version
180 ".tar.bz2")
181 (string-append %gcc-infrastructure
182 name "-" version ".tar.gz")))
183 (sha256
184 (base32
185 "13d9cqa5rzhbjq0xf0b2dyxag7pqa72xj9dhsa03m8ccr1a4npq9"))))
186 (build-system gnu-build-system)
187 (inputs `(("gmp" ,gmp)))
188 (home-page "http://www.kotnet.org/~skimo/isl/")
189 (synopsis
190 "A library for manipulating sets and relations of integer points bounded
191by linear constraints")
192 (description
193 "isl is a library for manipulating sets and relations of integer points
194bounded by linear constraints. Supported operations on sets include
195intersection, union, set difference, emptiness check, convex hull, (integer)
196affine hull, integer projection, computing the lexicographic minimum using
197parametric integer programming, coalescing and parametric vertex
198enumeration. It also includes an ILP solver based on generalized basis
199reduction, transitive closures on maps (which may encode infinite graphs),
200dependence analysis and bounds on piecewise step-polynomials.")
201 (license lgpl2.1+)))
202
203(define-public cloog
204 (package
205 (name "cloog")
206 (version "0.18.0")
207 (source
208 (origin
209 (method url-fetch)
210 (uri (list (string-append
211 "http://www.bastoul.net/cloog/pages/download/count.php3?url=cloog-"
212 version
213 ".tar.gz")
214 (string-append %gcc-infrastructure
215 name "-" version ".tar.gz")))
216 (sha256
217 (base32
218 "0a12rwfwp22zd0nlld0xyql11cj390rrq1prw35yjsw8wzfshjhw"))
219 (file-name (string-append name "-" version ".tar.gz"))))
220 (build-system gnu-build-system)
221 (inputs `(("gmp" ,gmp)
222 ("isl" ,isl)))
223 (arguments '(#:configure-flags '("--with-isl=system")))
224 (home-page "http://www.cloog.org/")
225 (synopsis "A library to generate code for scanning Z-polyhedra")
226 (description
227 "CLooG is a free software library to generate code for scanning
228Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
229reaches each integral point of one or more parameterized polyhedra.
230CLooG has been originally written to solve the code generation problem
231for optimizing compilers based on the polytope model. Nevertheless it
232is used now in various area e.g., to build control automata for
233high-level synthesis or to find the best polynomial approximation of a
234function. CLooG may help in any situation where scanning polyhedra
235matters. While the user has full control on generated code quality,
236CLooG is designed to avoid control overhead and to produce a very
237effective code.")
238 (license gpl2+)))
5c126b64
LC
239
240(define-public libelf
241 (package
242 (name "libelf")
243 (version "0.8.13")
244 (source (origin
245 (method url-fetch)
246 (uri (string-append "http://www.mr511.de/software/libelf-"
247 version ".tar.gz"))
248 (sha256
249 (base32
250 "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"))))
251 (build-system gnu-build-system)
252 (arguments '(#:phases (alist-replace
253 'configure
254 (lambda* (#:key outputs #:allow-other-keys)
255 ;; This old `configure' script doesn't support
256 ;; variables passed as arguments.
257 (let ((out (assoc-ref outputs "out")))
258 (setenv "CONFIG_SHELL" (which "bash"))
259 (zero?
260 (system* "./configure"
261 (string-append "--prefix=" out)))))
262 %standard-phases)))
263 (home-page "http://www.mr511.de/software/english.html")
264 (synopsis "An ELF object file access library")
265 (description "libelf is a C library to access ELF object files.")
266 (license lgpl2.0+)))