From e9e78f55996c23624ebd792eed57dd60a571daaa Mon Sep 17 00:00:00 2001
From: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Date: Tue, 22 Jul 2014 01:32:29 +0000
Subject: Specify -save-temps for libgcc during dependency phase

This works around an internal compiler error when building
gcc for x86_64 with thread local storage enabled.

diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in
index 2353c9c..93eada2 100644
--- a/libcpp/Makefile.in
+++ b/libcpp/Makefile.in
@@ -207,7 +207,7 @@ ifeq ($(DEPMODE),depmode=gcc3)
 # Note that we put the dependencies into a .Tpo file, then move them
 # into place if the compile succeeds.  We need this because gcc does
 # not atomically write the dependency output file.
-COMPILE = $(COMPILE.base) -o $@ -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Tpo
+COMPILE = $(COMPILE.base) -o $@ -save-temps -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Tpo
 POSTCOMPILE = @mv $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 else
 COMPILE = source='$<' object='$@' libtool=no DEPDIR=$(DEPDIR) $(DEPMODE) \
-- 
1.8.3.4

From fc3eb46b47136ae82418e2a6f63f3e3d8e918c1f Mon Sep 17 00:00:00 2001
From: Oliver Tappe <zooey@hirschkaefer.de>
Date: Sat, 26 Jul 2014 13:19:29 +0200
Subject: Circumvent build problems on x86_64.

* Due to some yet unknown cause, --as-needed does not seem to work as
  expected on x86_64, which causes the gcc build to fail when it checks
  if it can execute built programs (as libgcc_s.so is needed by those
  programs and can't be found). Circumvent the problem for now by creating
  appropriate 'lib' symlinks such that libgcc_s.so will be found by
  runtime_loader.

diff --git a/gmp/configure b/gmp/configure
index e8378cc..68c8d69 100755
--- a/gmp/configure
+++ b/gmp/configure
@@ -9378,7 +9378,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     ;;
 esac
 
-
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../prev-gcc lib
 
 # The C compiler on the build system, and associated tests.
 
diff --git a/libquadmath/configure b/libquadmath/configure
index 76dfbdf..e58cf46 100755
--- a/libquadmath/configure
+++ b/libquadmath/configure
@@ -3381,6 +3381,9 @@ See \`config.log' for more details." "$LINENO" 5; }; }
 fi
 ac_exeext=$ac_cv_exeext
 
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../../gcc/ lib
+
 # Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
diff --git a/libssp/configure b/libssp/configure
index c42affe..20e2b87 100755
--- a/libssp/configure
+++ b/libssp/configure
@@ -3361,6 +3361,9 @@ See \`config.log' for more details." "$LINENO" 5; }; }
 fi
 ac_exeext=$ac_cv_exeext
 
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../../gcc/ lib
+
 # Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 6479114..72e04bd 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -3997,6 +3997,9 @@ See \`config.log' for more details." "$LINENO" 5; }; }
 fi
 ac_exeext=$ac_cv_exeext
 
+# create lib symlink such that the runtime loader will find libgcc_s.so
+ln -sfn ../../gcc/ lib
+
 # Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-- 
1.8.3.4

