From 48ac8018ca0ed7ae9e5bc26c54357cdcb9c87799 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 27 Jun 2008 18:26:19 +0000 Subject: [PATCH] Improved support for building 32-bit binaries on x86_64-linux. * glibc_multi: a wrapper that combines the 32-bit and 64-bit Glibcs. This is necessary so that 64-bit GCC can find gnu/stubs-32.h and the 32-bit Glibc libraries. To build glibc_multi on x86_64-linux, you still need either the i686-linux Glibc derivation from a channel, or to have configured Nix with support for forwarding the build to a i686-linux machine. In the future this may become unnecessary by providing a prebuilt binary of 32-bit Glibc somewhere (like the binaries used in the stdenvLinux bootstrap). * With glibc_multi, it becomes possible to build gcc with multilib support (i.e. it builds 32-bit and 64-bit versions of libgcc, libstdc++, etc.). svn path=/nixpkgs/trunk/; revision=12203 --- .../development/compilers/gcc-4.3/default.nix | 6 ++-- pkgs/top-level/all-packages.nix | 36 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/gcc-4.3/default.nix b/pkgs/development/compilers/gcc-4.3/default.nix index 003433cf65e5..09d7ff7a807d 100644 --- a/pkgs/development/compilers/gcc-4.3/default.nix +++ b/pkgs/development/compilers/gcc-4.3/default.nix @@ -5,6 +5,7 @@ , texinfo ? null , gmp, mpfr , bison ? null, flex ? null +, enableMultilib ? false }: assert langC; @@ -43,6 +44,7 @@ stdenv.mkDerivation { ++ optionals langTreelang [bison flex]; configureFlags = " + ${if enableMultilib then "" else "--disable-multilib"} --disable-libstdcxx-pch --with-system-zlib --enable-languages=${ @@ -60,8 +62,8 @@ stdenv.mkDerivation { NIX_EXTRA_LDFLAGS = if staticCompiler then "-static" else ""; inherit gmp mpfr; - - passthru = { inherit langC langCC langFortran langTreelang; }; + + passthru = { inherit langC langCC langFortran langTreelang enableMultilib; }; meta = { homepage = "http://gcc.gnu.org/"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index daabd8c91a69..574e385d331e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1333,10 +1333,16 @@ let pkgs = rec { profiledCompiler = true; })); - gcc43 = lowPrio (wrapGCCWith (import ../build-support/gcc-wrapper-new) (import ../development/compilers/gcc-4.3 { + gcc43 = lowPrio (wrapGCCWith (import ../build-support/gcc-wrapper-new) glibc (import ../development/compilers/gcc-4.3 { inherit fetchurl stdenv texinfo gmp mpfr noSysDirs; profiledCompiler = false; - #langFortran = true; + })); + + gcc43multi = lowPrio (wrapGCCWith (import ../build-support/gcc-wrapper-new) glibc_multi (import ../development/compilers/gcc-4.3 { + stdenv = overrideGCC stdenv (wrapGCCWith (import ../build-support/gcc-wrapper) glibc_multi gcc42); + inherit fetchurl texinfo gmp mpfr noSysDirs; + profiledCompiler = false; + enableMultilib = true; })); gccApple = wrapGCC (import ../development/compilers/gcc-apple { @@ -1748,7 +1754,7 @@ let pkgs = rec { inherit fetchurl stdenv visualcpp windowssdk; }; - wrapGCCWith = gccWrapper: baseGCC: gccWrapper { + wrapGCCWith = gccWrapper: glibc: baseGCC: gccWrapper { nativeTools = stdenv ? gcc && stdenv.gcc.nativeTools; nativeLibc = stdenv ? gcc && stdenv.gcc.nativeLibc; nativePrefix = if stdenv ? gcc then stdenv.gcc.nativePrefix else ""; @@ -1757,7 +1763,7 @@ let pkgs = rec { inherit stdenv binutils; }; - wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper); + wrapGCC = wrapGCCWith (import ../build-support/gcc-wrapper) glibc; # FIXME: This is a specific hack for GCC-UPC. Eventually, we may # want to merge `gcc-upc-wrapper' and `gcc-wrapper'. @@ -2591,6 +2597,28 @@ let pkgs = rec { #installLocales = false; }); + glibc_multi = + assert system == "x86_64-linux"; + runCommand "${glibc.name}-multi" + { glibc64 = glibc; + glibc32 = (import ./all-packages.nix {system = "i686-linux";}).glibc; + } + '' + ensureDir $out + ln -s $glibc64/* $out/ + + rm $out/lib $out/lib64 + ensureDir $out/lib + ln -s $glibc64/lib/* $out/lib + ln -s $glibc32/lib $out/lib/32 + ln -s lib $out/lib64 + + rm $out/include + cp -rs $glibc32/include $out + chmod -R u+w $out/include + cp -rsf $glibc64/include $out + ''; # */ + gmime = import ../development/libraries/gmime { inherit fetchurl stdenv pkgconfig zlib; inherit (gtkLibs) glib;