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 #:use-module (gnu packages)
22 #:use-module (gnu packages bootstrap)
23 #:use-module (gnu packages compression)
24 #:use-module (gnu packages multiprecision)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix build-system gnu))
29 (define-public gcc-4.7
30 (let ((stripped? #t)) ; TODO: make this a parameter
36 (uri (string-append "mirror://gnu/gcc/gcc-"
37 version "/gcc-" version ".tar.bz2"))
40 "115h03hil99ljig8lkrq4qk426awmzh0g99wrrggxf8g07bq74la"))))
41 (build-system gnu-build-system)
42 (inputs `(("gmp" ,gmp)
44 ("mpc" ,mpc))) ; TODO: libelf, ppl, cloog, zlib, etc.
47 #:strip-binaries? ,stripped?
50 "--enable-languages=c,c++"
53 "--with-local-prefix=/no-gcc-local-prefix"
55 ,(let ((libc (assoc-ref %build-inputs "libc")))
57 (string-append "--with-native-system-header-dir=" libc
59 "--without-headers")))
61 (let ((libc (assoc-ref %build-inputs "libc")))
63 (list (string-append "LDFLAGS_FOR_BUILD="
65 "-Wl,-dynamic-linker "
67 ,(glibc-dynamic-linker)))
69 ,(string-append "BOOT_CFLAGS=-O2 "
70 ,(if stripped? "-g0" "-g"))))
75 'configure 'pre-configure
76 (lambda* (#:key inputs outputs #:allow-other-keys)
77 (let ((out (assoc-ref outputs "out"))
78 (libc (assoc-ref inputs "libc")))
80 ;; The following is not performed for `--without-headers'
81 ;; cross-compiler builds.
83 ;; Fix the dynamic linker's file name.
84 (substitute* (find-files "gcc/config"
85 "^linux(64|-elf)?\\.h$")
86 (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
87 (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
89 (string-append libc ,(glibc-dynamic-linker)))))
91 ;; Tell where to find libstdc++, libc, and `?crt*.o', except
92 ;; `crt{begin,end}.o', which come with GCC.
93 (substitute* (find-files "gcc/config"
94 "^(gnu-user(64)?|linux-elf)\\.h$")
95 (("#define LIB_SPEC (.*)$" _ suffix)
96 ;; Note that with this "lib" spec, we may still add a
97 ;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
98 ;; There's not much that can be done to avoid it, though.
99 (format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
100 %{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a~%"
101 libc libc out out suffix))
102 (("#define STARTFILE_SPEC.*$" line)
103 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
104 #define STANDARD_STARTFILE_PREFIX_2 \"\"
108 ;; Don't retain a dependency on the build-time sed.
109 (substitute* "fixincludes/fixincl.x"
110 (("static char const sed_cmd_z\\[\\] =.*;")
111 "static char const sed_cmd_z[] = \"sed\";"))))
114 'configure 'post-configure
116 ;; Don't store configure flags, to avoid retaining references to
117 ;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
118 (substitute* "Makefile"
119 (("^TOPLEVEL_CONFIGURE_ARGUMENTS=(.*)$" _ rest)
120 "TOPLEVEL_CONFIGURE_ARGUMENTS=\n")))
121 (alist-replace 'install
122 (lambda* (#:key outputs #:allow-other-keys)
128 %standard-phases)))))
130 (properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
131 (synopsis "The GNU Compiler Collection")
133 "The GNU Compiler Collection includes compiler front ends for C, C++,
134 Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
135 libraries for these languages (libstdc++, libgcj, libgomp,...).
137 GCC development is a part of the GNU Project, aiming to improve the compiler
138 used in the GNU system including the GNU/Linux variant.")
140 (home-page "http://gcc.gnu.org/"))))