From d0ae140f694a6c8882af2ab75a7c560a28d20f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Tue, 8 Dec 2009 09:36:19 +0000 Subject: [PATCH] Renamed some old glibcCross to libcCross (we can use uclibc in cross builds already). Dealt with the gcc 4.4 expression for it to work well for a native and a cross compiler, adding a pair of patches to get the job done without much side effects. One (libtool problems on -B) comes from the gcc 4.3 expression, while the other fixes a bug already fixed in gcc 4.4.3. svn path=/nixpkgs/branches/stdenv-updates/; revision=18833 --- pkgs/development/compilers/gcc-4.3/builder.sh | 4 +- pkgs/development/compilers/gcc-4.4/builder.sh | 81 +++++++++---------- .../development/compilers/gcc-4.4/default.nix | 12 ++- .../compilers/gcc-4.4/libstdc++-target.patch | 15 ++++ .../compilers/gcc-4.4/libtool-glibc.patch | 48 +++++++++++ pkgs/top-level/all-packages.nix | 14 ++-- 6 files changed, 120 insertions(+), 54 deletions(-) create mode 100644 pkgs/development/compilers/gcc-4.4/libstdc++-target.patch create mode 100644 pkgs/development/compilers/gcc-4.4/libtool-glibc.patch diff --git a/pkgs/development/compilers/gcc-4.3/builder.sh b/pkgs/development/compilers/gcc-4.3/builder.sh index 6c3671bf7cb..0d25692ce65 100644 --- a/pkgs/development/compilers/gcc-4.3/builder.sh +++ b/pkgs/development/compilers/gcc-4.3/builder.sh @@ -42,8 +42,8 @@ if test "$noSysDirs" = "1"; then if test -n "$targetConfig"; then if test -z "$crossStageStatic"; then - extraXCFlags="-B${glibcCross}/lib -idirafter ${glibcCross}/include" - extraXLDFlags="-L${glibcCross}/lib" + extraXCFlags="-B${libcCross}/lib -idirafter ${libcCross}/include" + extraXLDFlags="-L${libcCross}/lib" export NIX_EXTRA_CFLAGS_TARGET=$extraXCFlags for i in $extraXLDFlags; do export NIX_EXTRA_LDFLAGS_TARGET="$NIX_EXTRA_LDFLAGS_TARGET -Wl,$i" diff --git a/pkgs/development/compilers/gcc-4.4/builder.sh b/pkgs/development/compilers/gcc-4.4/builder.sh index 0b4f9e89a0f..27ba79a0987 100644 --- a/pkgs/development/compilers/gcc-4.4/builder.sh +++ b/pkgs/development/compilers/gcc-4.4/builder.sh @@ -10,9 +10,9 @@ mkdir $NIX_FIXINC_DUMMY export CPP="gcc -E" if test "$staticCompiler" = "1"; then - EXTRA_LDFLAGS="-static" + NIX_EXTRA_LDFLAGS="-static" else - EXTRA_LDFLAGS="" + NIX_EXTRA_LDFLAGS="" fi if test "$noSysDirs" = "1"; then @@ -40,55 +40,47 @@ if test "$noSysDirs" = "1"; then export NIX_FIXINC_DUMMY=/usr/include fi - # We should not allow gcc find the headers of the native glibc - # (Here I only think of c,c++ compilers) - if test -z "$targetConfig"; then - # Setting $CPATH makes sure both `gcc' and `xgcc' find the C - # library headers, regarless of the language being compiled. - export CPATH="$NIX_FIXINC_DUMMY${CPATH:+:}$CPATH" - - # Likewise, to help it find `crti.o' and similar files. - export LIBRARY_PATH="$glibc_libdir${LIBRARY_PATH:+:}$LIBRARY_PATH" - - echo "setting \$CPATH to \`$CPATH'" - echo "setting \$LIBRARY_PATH to \`$LIBRARY_PATH'" - fi - - extraCFlags="-g0 $extraCFlags" - extraLDFlags="--strip-debug $extraLDFlags" + extraCFlags="-g0 -O2 -I$NIX_FIXINC_DUMMY $extraCFlags" + extraLDFlags="--strip-debug -L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" + export NIX_EXTRA_CFLAGS="$extraCFlags" for i in $extraLDFlags; do - export EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i" + export NIX_EXTRA_LDFLAGS="$NIX_EXTRA_LDFLAGS -Wl,$i" done if test -n "$targetConfig"; then + # Cross-compiling, we need gcc not to read ./specs in order to build + # the g++ compiler (after the specs for the cross-gcc are created). + # Having LIBRARY_PATH= makes gcc read the specs from ., and the build + # breaks. Having this variable comes from the default.nix code to bring + # gcj in. + unset LIBRARY_PATH + unset CPATH if test -z "$crossStageStatic"; then - extraXCFlags="-B${glibcCross}/lib -idirafter ${glibcCross}/include" - extraXLDFlags="-L${glibcCross}/lib" - export EXTRA_CFLAGS_TARGET=$extraXCFlags - for i in $extraXLDFlags; do - export EXTRA_LDFLAGS_TARGET="$EXTRA_LDFLAGS_TARGET -Wl,$i" - done + export NIX_EXTRA_CFLAGS_TARGET="-g0 -O2 -B${libcCross}/lib -idirafter ${libcCross}/include" + export NIX_EXTRA_LDFLAGS_TARGET="-Wl,-L${libcCross}/lib" fi - - makeFlagsArray=( \ - "${makeFlagsArray[@]}" \ - NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ - SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ - CFLAGS_FOR_TARGET="$EXTRA_CFLAGS_TARGET $EXTRA_LDFLAGS_TARGET" \ - LDFLAGS_FOR_TARGET="$EXTRA_CFLAGS_TARGET $EXTRA_LDFLAGS_TARGET" \ - ) else - export EXTRA_CFLAGS_TARGET=$EXTRA_CFLAGS - export EXTRA_LDFLAGS_TARGET=$EXTRA_LDFLAGS + # To be read by configure scripts (libtool-glibc.patch) + export NIX_EXTRA_CFLAGS_TARGET="$NIX_EXTRA_CFLAGS" + export NIX_EXTRA_LDFLAGS_TARGET="$NIX_EXTRA_LDFLAGS" + fi + + makeFlagsArray=( \ + "${makeFlagsArray[@]}" \ + NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ + SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ + CFLAGS_FOR_BUILD="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \ + CFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET" \ + LDFLAGS_FOR_BUILD="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \ + LDFLAGS_FOR_TARGET="$NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET" \ + ) + + if test -z "$targetConfig"; then makeFlagsArray=( \ "${makeFlagsArray[@]}" \ - NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ - SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ - CFLAGS_FOR_BUILD="$extraCflags $EXTRA_CFLAGS $EXTRA_LDFLAGS" \ - CFLAGS_FOR_TARGET="$EXTRA_CFLAGS $EXTRA_LDFLAGS" \ - LDFLAGS_FOR_BUILD="$extraCflags $EXTRA_CFLAGS $EXTRA_LDFLAGS" \ - LDFLAGS_FOR_TARGET="$EXTRA_CFLAGS $EXTRA_LDFLAGS" \ + BOOT_CFLAGS="$NIX_EXTRA_CFLAGS $NIX_EXTRA_LDFLAGS" \ + BOOT_LDFLAGS="$NIX_EXTRA_CFLAGS_TARGET $NIX_EXTRA_LDFLAGS_TARGET" \ ) fi @@ -119,6 +111,13 @@ preConfigure() { # Patch to get armvt5el working: sed -i -e 's/ arm)/ arm*)/' newlib/configure.host fi + # Bug - they packaged zlib + if test -d "zlib"; then + # This breaks the build without-headers, which should build only + # the target libgcc as target libraries. + # See 'configure:5370' + rm -Rf zlib + fi # Perform the build in a different directory. mkdir ../build diff --git a/pkgs/development/compilers/gcc-4.4/default.nix b/pkgs/development/compilers/gcc-4.4/default.nix index 1f4feddc6f4..d0c910adb7d 100644 --- a/pkgs/development/compilers/gcc-4.4/default.nix +++ b/pkgs/development/compilers/gcc-4.4/default.nix @@ -17,7 +17,7 @@ , name ? "gcc" , cross ? null , binutilsCross ? null -, glibcCross ? null +, libcCross ? null , crossStageStatic ? true }: @@ -61,7 +61,7 @@ let version = "4.4.2"; " --disable-libgomp " + " --disable-shared" else - " --with-headers=${glibcCross}/include" + + " --with-headers=${libcCross}/include" + " --enable-__cxa_atexit" + " --enable-long-long" + " --enable-threads=posix" + @@ -87,10 +87,14 @@ stdenv.mkDerivation ({ }; patches = - [./pass-cxxcpp.patch] + [./pass-cxxcpp.patch + ./libtool-glibc.patch # some libraries don't let the proper -Btargetglibcpath pass + ./libstdc++-target.patch # (fixed in gcc 4.4.3) bad mixture of build/target flags + ] ++ optional noSysDirs ./no-sys-dirs.patch; - inherit noSysDirs profiledCompiler staticCompiler langJava; + inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic + libcCross; buildInputs = [ texinfo gmp mpfr gettext which ] ++ (optional (ppl != null) ppl) diff --git a/pkgs/development/compilers/gcc-4.4/libstdc++-target.patch b/pkgs/development/compilers/gcc-4.4/libstdc++-target.patch new file mode 100644 index 00000000000..0b04b83d08d --- /dev/null +++ b/pkgs/development/compilers/gcc-4.4/libstdc++-target.patch @@ -0,0 +1,15 @@ +diff --git a/Makefile.in b/Makefile.in +index 245c770..8545b60 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -250,8 +250,8 @@ BASE_TARGET_EXPORTS = \ + RAW_CXX_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ + CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \ +- CXX="$(RAW_CXX_FOR_TARGET) $(CFLAGS_FOR_BUILD)"; export CXX; \ +- CXXCPP="$(RAW_CXX_FOR_TARGET) $(CFLAGS_FOR_BUILD) -E"; export CXXCPP; ++ CXX="$(RAW_CXX_FOR_TARGET) $(CFLAGS_FOR_TARGET)"; export CXX; \ ++ CXXCPP="$(RAW_CXX_FOR_TARGET) $(CFLAGS_FOR_TARGET) -E"; export CXXCPP; + + NORMAL_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ diff --git a/pkgs/development/compilers/gcc-4.4/libtool-glibc.patch b/pkgs/development/compilers/gcc-4.4/libtool-glibc.patch new file mode 100644 index 00000000000..6f69070beb3 --- /dev/null +++ b/pkgs/development/compilers/gcc-4.4/libtool-glibc.patch @@ -0,0 +1,48 @@ +diff --git a/libgomp/configure b/libgomp/configure +index deef673..9e4a790 100755 +--- a/libgomp/configure ++++ b/libgomp/configure +@@ -23848,6 +23848,11 @@ old_archive_cmds=$lt_old_archive_cmds + # A language specific compiler. + CC=$lt_compiler + ++# Ugly hack to get libmudflap (and 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_TARGET $NIX_EXTRA_LDFLAGS_TARGET" ++ + # Is the compiler the GNU compiler? + with_gcc=$GCC + +diff --git a/libmudflap/configure b/libmudflap/configure +index ae1be92..4ee1e18 100755 +--- a/libmudflap/configure ++++ b/libmudflap/configure +@@ -15044,6 +15044,11 @@ old_archive_cmds=$lt_old_archive_cmds + # A language specific compiler. + CC=$lt_compiler + ++# Ugly hack to get libmudflap (and 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_TARGET $NIX_EXTRA_LDFLAGS_TARGET" ++ + # Is the compiler the GNU compiler? + with_gcc=$GCC + +diff --git a/libssp/configure b/libssp/configure +index ee2a41f..7f3e1fd 100755 +--- a/libssp/configure ++++ b/libssp/configure +@@ -12926,6 +12926,11 @@ old_archive_cmds=$lt_old_archive_cmds + # A language specific compiler. + CC=$lt_compiler + ++# Ugly hack to get libmudflap (and 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_TARGET $NIX_EXTRA_LDFLAGS_TARGET" ++ + # Is the compiler the GNU compiler? + with_gcc=$GCC + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 18cd0c90651..bfc5fa7cc8a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1784,7 +1784,7 @@ let gcc43_realCross = cross : makeOverridable (import ../development/compilers/gcc-4.3) { inherit stdenv fetchurl texinfo gmp mpfr noSysDirs cross; binutilsCross = binutilsCross cross; - glibcCross = libcCross cross; + libcCross = libcCross cross; profiledCompiler = false; enableMultilib = true; crossStageStatic = false; @@ -1794,17 +1794,17 @@ let inherit stdenv fetchurl texinfo gmp mpfr ppl cloogppl noSysDirs cross gettext which; binutilsCross = binutilsCross cross; - glibcCross = libcCross cross; + libcCross = libcCross cross; profiledCompiler = false; enableMultilib = true; crossStageStatic = false; }; gccCrossStageStatic = cross: wrapGCCCross { - gcc = forceBuildDrv ((gcc43_realCross cross).override { + gcc = forceBuildDrv ((gcc44_realCross cross).override { crossStageStatic = true; langCC = false; - glibcCross = null; + libcCross = null; }); libc = null; binutils = binutilsCross cross; @@ -1812,7 +1812,7 @@ let }; gccCrossStageFinal = cross: wrapGCCCross { - gcc = forceBuildDrv (gcc43_realCross cross); + gcc = forceBuildDrv (gcc44_realCross cross); libc = libcCross cross; binutils = binutilsCross cross; inherit cross; @@ -3484,8 +3484,8 @@ let }); # We can choose: - # glibcCross = cross: glibc211Cross cross; - libcCross = cross: uclibcCross cross; + libcCross = cross: glibc211Cross cross; + # libcCross = cross: uclibcCross cross; eglibc = import ../development/libraries/eglibc { inherit fetchsvn stdenv kernelHeaders;