summary refs log tree commit diff
path: root/pkgs/development/compilers/gcc-4.5/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/gcc-4.5/default.nix')
-rw-r--r--pkgs/development/compilers/gcc-4.5/default.nix21
1 files changed, 19 insertions, 2 deletions
diff --git a/pkgs/development/compilers/gcc-4.5/default.nix b/pkgs/development/compilers/gcc-4.5/default.nix
index 0726d277f819..0e0029f9f94d 100644
--- a/pkgs/development/compilers/gcc-4.5/default.nix
+++ b/pkgs/development/compilers/gcc-4.5/default.nix
@@ -146,13 +146,17 @@ stdenv.mkDerivation ({
 
   postPatch =
     if (stdenv.system == "i586-pc-gnu"
+        || (libcCross != null                  # e.g., building `gcc.hostDrv'
+            && libcCross ? crossConfig
+            && libcCross.crossConfig == "i586-pc-gnu")
         || (cross != null && cross.config == "i586-pc-gnu"
             && libcCross != null))
     then
       # On GNU/Hurd glibc refers to Hurd & Mach headers and libpthread is not
       # in glibc, so add the right `-I' flags to the default spec string.
+      assert libcCross != null -> libpthreadCross != null;
       let
-        libc = if cross != null then libcCross else stdenv.glibc;
+        libc = if libcCross != null then libcCross else stdenv.glibc;
         gnu_h = "gcc/config/gnu.h";
         i386_gnu_h = "gcc/config/i386/gnu.h";
         extraCPPDeps =
@@ -174,12 +178,18 @@ stdenv.mkDerivation ({
            echo "augmenting \`LIB_SPEC' in \`${gnu_h}' with \`${extraLibSpec}'..."
            sed -i "${gnu_h}" \
                -es'|LIB_SPEC *"\(.*\)$|LIB_SPEC "${extraLibSpec} \1|g'
+
+           echo "setting \`NATIVE_SYSTEM_HEADER_DIR' and \`STANDARD_INCLUDE_DIR' to \`${libc}/include'..."
+           sed -i "${gnu_h}" \
+               -es'|#define STANDARD_INCLUDE_DIR.*$|#define STANDARD_INCLUDE_DIR "${libc}/include"|g'
+           sed -i gcc/config/t-gnu \
+               -es'|NATIVE_SYSTEM_HEADER_DIR.*$|NATIVE_SYSTEM_HEADER_DIR = ${libc}/include|g'
         ''
     else if cross != null || stdenv.gcc.libc != null then
       # On NixOS, use the right path to the dynamic linker instead of
       # `/lib/ld*.so'.
       let
-        libc = if (cross != null && libcCross != null) then libcCross else stdenv.gcc.libc;
+        libc = if (libcCross != null) then libcCross else stdenv.gcc.libc;
       in
         '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..."
            for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h
@@ -384,6 +394,13 @@ stdenv.mkDerivation ({
   };
 }
 
+// optionalAttrs (cross != null || libcCross != null) {
+  # `builder.sh' sets $CPP, which leads configure to use "gcc -E" instead of,
+  # say, "i586-pc-gnu-gcc -E" when building `gcc.hostDrv'.
+  # FIXME: Fix `builder.sh' directly in the next stdenv-update.
+  postUnpack = "unset CPP";
+}
+
 // optionalAttrs (cross != null && cross.libc == "msvcrt" && crossStageStatic) {
   makeFlags = [ "all-gcc" "all-target-libgcc" ];
   installTargets = "install-gcc install-target-libgcc";