Mirror of GNU Guix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

312 lines
13 KiB

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
;;; This file is part of GNU Guix.
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; GNU General Public License for more details.
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages gcc)
#:use-module ((guix licenses)
#:select (gpl3+ gpl2+ lgpl2.1+ lgpl2.0+))
#:use-module (gnu packages)
#:use-module (gnu packages bootstrap)
#:use-module (gnu packages compression)
#:use-module (gnu packages multiprecision)
#:use-module (gnu packages texinfo)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix build-system gnu)
#:use-module (ice-9 regex))
(define %gcc-infrastructure
;; Base URL for GCC's infrastructure.
(define-public (gcc-configure-flags-for-triplet target)
"Return a list of additional GCC `configure' flags for TARGET, a GNU triplet.
The purpose of this procedure is to translate extended GNU triplets---e.g.,
where the OS part is overloaded to denote a specific ABI---into GCC
`configure' options. We take extended GNU triplets that glibc recognizes."
(cond ((string-match "^mips64el.*gnuabin?64$" target)
;; Triplets recognized by glibc as denoting the N64 ABI; see
;; ports/sysdeps/mips/preconfigure.
;; TODO: Add `armel.*gnueabi', `hf', etc.
(define-public gcc-4.7
(let* ((stripped? #t) ; TODO: make this a parameter
(lambda ()
;; Return the `_FOR_TARGET' variables that are needed when
;; cross-compiling GCC.
(let ((target (%current-target-system)))
(if target
(map (lambda (var tool)
(string-append (string-append var "_FOR_TARGET")
"=" target "-" tool))
'("CC" "CXX" "LD" "AR" "NM" "RANLIB" "STRIP")
'("gcc" "g++" "ld" "ar" "nm" "ranlib" "strip"))
(lambda ()
;; This is terrible. Since we have two levels of quasiquotation,
;; we have to do this convoluted thing just so we can insert the
;; contents of (maybe-target-tools).
(list 'quasiquote
,(let ((libc (assoc-ref %build-inputs "libc")))
(if libc
(string-append "--with-native-system-header-dir=" libc
;; When cross-compiling GCC, pass the right options for the
;; target triplet.
(or (and=> (%current-target-system)
(name "gcc")
(version "4.7.3")
(source (origin
(method url-fetch)
(uri (string-append "mirror://gnu/gcc/gcc-"
version "/gcc-" version ".tar.bz2"))
(build-system gnu-build-system)
(inputs `(("gmp" ,gmp)
("mpfr" ,mpfr)
("mpc" ,mpc)
("isl" ,isl)
("cloog" ,cloog)
("libelf" ,libelf)
("zlib" ,zlib)))
;; GCC is one of the few packages that doesn't ship .info files.
(native-inputs `(("texinfo" ,texinfo)))
`(#:out-of-source? #t
#:strip-binaries? ,stripped?
#:configure-flags ,(configure-flags)
(let ((libc (assoc-ref %build-inputs "libc")))
`(,@(if libc
(list (string-append "LDFLAGS_FOR_TARGET="
"-B" libc "/lib "
"-Wl,-dynamic-linker "
"-Wl," libc
,(string-append "BOOT_CFLAGS=-O2 "
,(if stripped? "-g0" "-g"))))
#:tests? #f
'configure 'pre-configure
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(libc (assoc-ref inputs "libc")))
(when libc
;; The following is not performed for `--without-headers'
;; cross-compiler builds.
;; Fix the dynamic linker's file name.
(substitute* (find-files "gcc/config"
(("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
(format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
(string-append libc ,(glibc-dynamic-linker)))))
;; Tell where to find libstdc++, libc, and `?crt*.o', except
;; `crt{begin,end}.o', which come with GCC.
(substitute* (find-files "gcc/config"
(("#define LIB_SPEC (.*)$" _ suffix)
;; Note that with this "lib" spec, we may still add a
;; RUNPATH to GCC even when `libgcc_s' is not NEEDED.
;; There's not much that can be done to avoid it, though.
(format #f "#define LIB_SPEC \"-L~a/lib %{!static:-rpath=~a/lib \
%{!static-libgcc:-rpath=~a/lib64 -rpath=~a/lib}} \" ~a"
libc libc out out suffix))
(("#define STARTFILE_SPEC.*$" line)
(format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
libc line))))
;; Don't retain a dependency on the build-time sed.
(substitute* "fixincludes/fixincl.x"
(("static char const sed_cmd_z\\[\\] =.*;")
"static char const sed_cmd_z[] = \"sed\";"))))
'configure 'post-configure
(lambda _
;; Don't store configure flags, to avoid retaining references to
;; build-time dependencies---e.g., `--with-ppl=/nix/store/xxx'.
(substitute* "Makefile"
(alist-replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(system* "make"
,(if stripped?
(list (search-path-specification
(variable "CPATH")
(directories '("include")))
(variable "LIBRARY_PATH")
(directories '("lib" "lib64")))))
(properties `((gcc-libc . ,(assoc-ref inputs "libc"))))
(synopsis "GNU Compiler Collection")
"The GNU Compiler Collection includes compiler front ends for C, C++,
Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well as
libraries for these languages (libstdc++, libgcj, libgomp,...).
GCC development is a part of the GNU Project, aiming to improve the compiler
used in the GNU system including the GNU/Linux variant.")
(license gpl3+)
(home-page "http://gcc.gnu.org/"))))
(define-public gcc-4.8
(package (inherit gcc-4.7)
(version "4.8.1")
(source (origin
(method url-fetch)
(uri (string-append "mirror://gnu/gcc/gcc-"
version "/gcc-" version ".tar.bz2"))
(define-public isl
(name "isl")
(version "0.11.1")
(source (origin
(method url-fetch)
(uri (list (string-append
(string-append %gcc-infrastructure
name "-" version ".tar.gz")))
(build-system gnu-build-system)
(inputs `(("gmp" ,gmp)))
(home-page "http://isl.gforge.inria.fr/")
"A library for manipulating sets and relations of integer points bounded
by linear constraints")
"isl is a library for manipulating sets and relations of integer points
bounded by linear constraints. Supported operations on sets include
intersection, union, set difference, emptiness check, convex hull, (integer)
affine hull, integer projection, computing the lexicographic minimum using
parametric integer programming, coalescing and parametric vertex
enumeration. It also includes an ILP solver based on generalized basis
reduction, transitive closures on maps (which may encode infinite graphs),
dependence analysis and bounds on piecewise step-polynomials.")
(license lgpl2.1+)))
(define-public cloog
(name "cloog")
(version "0.18.0")
(method url-fetch)
(uri (list (string-append
(string-append %gcc-infrastructure
name "-" version ".tar.gz")))
(file-name (string-append name "-" version ".tar.gz"))))
(build-system gnu-build-system)
(inputs `(("gmp" ,gmp)
("isl" ,isl)))
(arguments '(#:configure-flags '("--with-isl=system")))
(home-page "http://www.cloog.org/")
(synopsis "A library to generate code for scanning Z-polyhedra")
"CLooG is a free software library to generate code for scanning
Z-polyhedra. That is, it finds a code (e.g., in C, FORTRAN...) that
reaches each integral point of one or more parameterized polyhedra.
CLooG has been originally written to solve the code generation problem
for optimizing compilers based on the polytope model. Nevertheless it
is used now in various area e.g., to build control automata for
high-level synthesis or to find the best polynomial approximation of a
function. CLooG may help in any situation where scanning polyhedra
matters. While the user has full control on generated code quality,
CLooG is designed to avoid control overhead and to produce a very
effective code.")
(license gpl2+)))
(define-public libelf
(name "libelf")
(version "0.8.13")
(source (origin
(method url-fetch)
(uri (string-append "http://www.mr511.de/software/libelf-"
version ".tar.gz"))
(build-system gnu-build-system)
(arguments '(#:phases (alist-replace
(lambda* (#:key outputs #:allow-other-keys)
;; This old `configure' script doesn't support
;; variables passed as arguments.
(let ((out (assoc-ref outputs "out")))
(setenv "CONFIG_SHELL" (which "bash"))
(system* "./configure"
(string-append "--prefix=" out)))))
(home-page "http://www.mr511.de/software/english.html")
(synopsis "An ELF object file access library")
(description "libelf is a C library to access ELF object files.")
(license lgpl2.0+)))