Submitted By: Jim Gifford (jim at cross-lfs dot org)
Date: 02-18-2009
Initial Package Version: 4.3.3
Origin: Upstream
Upstream Status: Applied to Mainline
Description: This fixes a known build issue with Powerpc and GCC 4.3.3
             http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37739

diff -Naur gcc-4.3.3.orig/gcc/config/rs6000/x-linux-relax gcc-4.3.3/gcc/config/rs6000/x-linux-relax
--- gcc-4.3.3.orig/gcc/config/rs6000/x-linux-relax	1969-12-31 16:00:00.000000000 -0800
+++ gcc-4.3.3/gcc/config/rs6000/x-linux-relax	2009-02-18 10:19:52.235263584 -0800
@@ -0,0 +1,3 @@
+# At -O0 cc1 etc. are too large and -Wl,--relax is needed
+$(COMPILERS) : override LDFLAGS += -Wl,--relax
+
diff -Naur gcc-4.3.3.orig/gcc/config/x-cflags-O1 gcc-4.3.3/gcc/config/x-cflags-O1
--- gcc-4.3.3.orig/gcc/config/x-cflags-O1	1969-12-31 16:00:00.000000000 -0800
+++ gcc-4.3.3/gcc/config/x-cflags-O1	2009-02-18 10:19:24.149463891 -0800
@@ -0,0 +1,6 @@
+# At -O0 cc1 etc. are too large on some targets for successful
+# link; force building libbackend.a with -O1.
+ifeq ($(filter-out -O0,$(lastword $(filter -O%,$(CFLAGS)))),)
+$(OBJS) : override CFLAGS += -O1
+endif
+
diff -Naur gcc-4.3.3.orig/gcc/config.host gcc-4.3.3/gcc/config.host
--- gcc-4.3.3.orig/gcc/config.host	2007-08-08 12:33:24.000000000 -0700
+++ gcc-4.3.3/gcc/config.host	2009-02-18 10:18:57.471754434 -0800
@@ -116,6 +116,27 @@
         host_xmake_file="${host_xmake_file} rs6000/x-rs6000"
         ;;
     esac
+    case ${host} in
+      *-*-linux* )
+	if test "${GCC}:${ac_cv_sizeof_long}" = yes:4; then
+	  # On powerpc*-*-linux* use -Wl,--relax to link cc1,
+	  # if ld is new enough, otherwise force -O1 in CFLAGS.
+	  host_ppc_relax_xmake_file=
+	  host_ld_ver=`${CC} -Wl,--version 2>/dev/null | sed 1q`
+	  if echo "$host_ld_ver" | grep GNU > /dev/null; then
+	    host_ld_date=`echo $host_ld_ver \
+			  | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
+	    if test 0"$host_ld_date" -gt 20080806; then
+	      host_ppc_relax_xmake_file=rs6000/x-linux-relax
+	    fi
+	  fi
+	  if test -z "${host_ppc_relax_xmake_file}"; then
+	    host_ppc_relax_xmake_file=x-cflags-O1
+	  fi
+	  host_xmake_file="${host_xmake_file} ${host_ppc_relax_xmake_file}"
+	fi
+	;;
+    esac
     ;;
 esac
 
