* Fix building the Fortran compiler.

svn path=/nixpkgs/trunk/; revision=12201
This commit is contained in:
Eelco Dolstra 2008-06-27 14:43:25 +00:00
parent eef2cd2f81
commit aaccd6f6e2
8 changed files with 36 additions and 187 deletions

View File

@ -75,7 +75,7 @@ doSubstitute() {
}
# Make wrapper scripts around gcc, g++, and g77. Also make symlinks
# Make wrapper scripts around gcc, g++, and gfortran. Also make symlinks
# cc, c++, and f77.
mkGccWrapper() {
local dst=$1
@ -97,8 +97,11 @@ ln -s gcc $out/bin/cc
mkGccWrapper $out/bin/g++ $gccPath/g++
ln -s g++ $out/bin/c++
mkGccWrapper $out/bin/g77 $gccPath/g77
ln -s g77 $out/bin/f77
if test -e $gccPath/gfortran; then
mkGccWrapper $out/bin/gfortran $gccPath/gfortran
ln -s gfortran $out/bin/g77
ln -s gfortran $out/bin/f77
fi
# Create a symlink to as (the assembler). This is useful when a

View File

@ -28,7 +28,7 @@ stdenv.mkDerivation {
name = if name == "" then gcc.name else name;
langC = if nativeTools then true else gcc.langC;
langCC = if nativeTools then true else gcc.langCC;
langF77 = if nativeTools then false else gcc.langF77;
langFortran = if nativeTools then false else gcc ? langFortran;
shell = if shell == "" then stdenv.shell else shell;
meta = if gcc != null && (gcc ? meta) then removeAttrs gcc.meta ["priority"] else

View File

@ -1,12 +1,14 @@
{ stdenv, fetchurl, noSysDirs
, langC ? true, langCC ? true, langF77 ? false
, langC ? true, langCC ? true, langFortran ? false, langTreelang ? false
, profiledCompiler ? false
, staticCompiler ? false
, texinfo ? null
, gmp, mpfr
, bison ? null, flex ? null
}:
assert langC;
assert langTreelang -> bison != null && flex != null;
with import ../../../lib;
@ -25,28 +27,30 @@ stdenv.mkDerivation {
url = "mirror://gnu/gcc/gcc-${version}/gcc-g++-${version}.tar.bz2";
sha256 = "0r74s60hylr8xrnb2j3x0dmf3cnxxg609g4h07r6ida8vk33bd25";
}) ++
optional langF77 (fetchurl {
optional langFortran (fetchurl {
url = "mirror://gnu/gcc/gcc-${version}/gcc-fortran-${version}.tar.bz2";
sha256 = "1fl76sajlz1ihnsmqsbs3i8g0h77w9hm35pwb1s2w6p4h5xy5dnb";
});
patches =
[./pass-cxxcpp.patch]
++ optional noSysDirs [./no-sys-dirs.patch];
++ optional noSysDirs ./no-sys-dirs.patch
++ optional (noSysDirs && langFortran) ./no-sys-dirs-fortran.patch;
inherit noSysDirs profiledCompiler staticCompiler;
buildInputs = [texinfo gmp mpfr];
buildInputs = [texinfo gmp mpfr]
++ optionals langTreelang [bison flex];
configureFlags = "
--disable-multilib
--disable-libstdcxx-pch
--with-system-zlib
--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langF77 "f77"
( optional langC "c"
++ optional langCC "c++"
++ optional langFortran "fortran"
++ optional langTreelang "treelang"
)
)
}
@ -56,9 +60,8 @@ stdenv.mkDerivation {
NIX_EXTRA_LDFLAGS = if staticCompiler then "-static" else "";
inherit gmp mpfr;
#X_CFLAGS = "-I${gmp}/include -I${mpfr}/include -L${gmp}/lib -L${mpfr}/lib";
passthru = { inherit langC langCC langF77; };
passthru = { inherit langC langCC langFortran langTreelang; };
meta = {
homepage = "http://gcc.gnu.org/";

View File

@ -1,73 +0,0 @@
{ stdenv, fetchurl, noSysDirs
, langC ? true, langCC ? true, langF77 ? false
, profiledCompiler ? false
, staticCompiler ? false
, gmp ? null
, mpfr ? null
, texinfo ? null
}:
assert langC || langF77;
with import ../../../lib;
let version = "4.2.3"; in
stdenv.mkDerivation {
name = "gcc-${version}";
builder = if langF77 then ./fortran.sh else ./builder.sh;
src =
optional /*langC*/ true (fetchurl {
url = "mirror://gnu/gcc/gcc-${version}/gcc-core-${version}.tar.bz2";
sha256 = "04y84s46wzy4h44hpacf7vyla7b5zfc1qvdq3myvrhp82cp0bv4r";
}) ++
optional langCC (fetchurl {
url = "mirror://gnu/gcc/gcc-${version}/gcc-g++-${version}.tar.bz2";
sha256 = "0spzz549fifwv02ym33azzwizl0zkq5m1fgy88ccmcyzmwpgyzfq";
}) ++
optional langF77 (fetchurl {
url = "mirror://gnu/gcc/gcc-${version}/gcc-fortran-${version}.tar.bz2";
sha256 = "1l3ww6qymrkcfqlssb41a5fdnh6w2hqk0v2ijx56jgjbdnzawyp0";
});
patches =
optional noSysDirs [./no-sys-dirs.patch];
inherit noSysDirs profiledCompiler staticCompiler;
buildInputs = [gmp mpfr texinfo];
configureFlags = "
--disable-multilib
--disable-libstdcxx-pch
--with-system-zlib
--enable-languages=${
concatStrings (intersperse ","
( optional langC "c"
++ optional langCC "c++"
++ optional langF77 "fortran"
)
)
}
${if stdenv.isi686 then "--with-arch=i686" else ""}
${if gmp != null then "--with-gmp=${gmp}" else ""}
${if mpfr != null then "--with-mpfr=${mpfr}" else ""}
";
makeFlags = if staticCompiler then "LDFLAGS=-static" else "";
passthru = { inherit langC langCC langF77; };
postInstall = "if test -f $out/bin/gfrotran; then ln -s $out/bin/gfortran $out/bin/g77; fi";
meta = {
homepage = "http://gcc.gnu.org/";
license = "GPL/LGPL";
description = "GNU Compiler Collection, 4.2.x";
# Give the real GCC a lower priority than the GCC wrapper so that
# both can be installed at the same time.
priority = "7";
};
}

View File

@ -1,86 +0,0 @@
source $stdenv/setup
export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy
mkdir $NIX_FIXINC_DUMMY
export X_CFLAGS="-I${gmp}/include -I${mpfr}/include -L${gmp}/lib -L${mpfr}/lib";
# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
# Thing.
export CPP="gcc -E"
if test "$noSysDirs" = "1"; then
if test -e $NIX_GCC/nix-support/orig-libc; then
# Figure out what extra flags to pass to the gcc compilers
# being generated to make sure that they use our glibc.
extraCFlags="$(cat $NIX_GCC/nix-support/libc-cflags)"
extraLDFlags="$(cat $NIX_GCC/nix-support/libc-ldflags) $(cat $NIX_GCC/nix-support/libc-ldflags-before)"
# Use *real* header files, otherwise a limits.h is generated
# that does not include Glibc's limits.h (notably missing
# SSIZE_MAX, which breaks the build).
export NIX_FIXINC_DUMMY=$(cat $NIX_GCC/nix-support/orig-libc)/include
else
# Hack: support impure environments.
extraCFlags="-isystem /usr/include"
extraLDFlags="-L/usr/lib64 -L/usr/lib"
export NIX_FIXINC_DUMMY=/usr/include
fi
extraCFlags="-g0 $extraCFlags"
extraLDFlags="--strip-debug $extraLDFlags"
export NIX_EXTRA_CFLAGS=$extraCFlags
for i in $extraLDFlags; do
export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i"
done
makeFlagsArray=( \
NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
LIMITS_H_TEST=true \
X_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
LDFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \
)
fi
preConfigure=preConfigure
preConfigure() {
# Perform the build in a different directory.
mkdir ../build
cd ../build
configureScript=../$sourceRoot/configure
}
postInstall=postInstall
postInstall() {
# Remove precompiled headers for now. They are very big and
# probably not very useful yet.
find $out/include -name "*.gch" -exec rm -rf {} \; -prune
# Remove `fixincl' to prevent a retained dependency on the
# previous gcc.
rm -rf $out/libexec/gcc/*/*/install-tools
# Get rid of some "fixed" header files
rm -rf $out/lib/gcc/*/*/include/root
}
if test -z "$staticCompiler"; then
if test -z "$profiledCompiler"; then
buildFlags="bootstrap $buildFlags"
else
buildFlags="profiledbootstrap $buildFlags"
fi
fi
genericBuild

View File

@ -0,0 +1,15 @@
diff -ru gcc-4.3.1-orig/libgfortran/configure gcc-4.3.1/libgfortran/configure
--- gcc-4.3.1-orig/libgfortran/configure 2008-06-06 16:49:11.000000000 +0200
+++ gcc-4.3.1/libgfortran/configure 2008-06-27 08:25:08.000000000 +0200
@@ -35405,6 +35405,11 @@
# A language specific compiler.
CC=$lt_compiler
+# Ugly hack to get libmudflap (and possibly other libraries) to build.
+# Libtool filters out \`-B' flags when linking (why?), so the \`-B' flag
+# to Glibc gets lost. Here we forcibly add it to any invocation.
+CC="\$CC $NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS"
+
# Is the compiler the GNU compiler?
with_gcc=$GCC

View File

@ -1,14 +0,0 @@
{stdenv, fetchurl, m4}:
assert m4 != null;
stdenv.mkDerivation {
name = "bison-1.875d";
src = fetchurl {
url = http://nix.cs.uu.nl/dist/tarballs/bison-1.875d.tar.gz;
md5 = "faaa4a271ca722fb6c769d72e18ade0b";
};
buildInputs = [m4];
} // {
glrSupport = true;
}

View File

@ -1336,6 +1336,7 @@ let pkgs = rec {
gcc43 = lowPrio (wrapGCCWith (import ../build-support/gcc-wrapper-new) (import ../development/compilers/gcc-4.3 {
inherit fetchurl stdenv texinfo gmp mpfr noSysDirs;
profiledCompiler = false;
#langFortran = true;
}));
gccApple = wrapGCC (import ../development/compilers/gcc-apple {