Patchwork Fix libbacktrace and libiberty tests fail on sanitized GCC due to wrong link options.

login
register
mail settings
Submitter max
Date Sept. 1, 2014, 7:19 a.m.
Message ID <54041DEB.2080906@partner.samsung.com>
Download mbox | patch
Permalink /patch/384679/
State New
Headers show

Comments

max - Sept. 1, 2014, 7:19 a.m.
On 08/25/2014 07:21 PM, Bernhard Reutner-Fischer wrote:
> On 25 August 2014 16:23:54 CEST, Yury Gribov <y.gribov@samsung.com> wrote:
>> On 08/25/2014 11:04 AM, Maxim Ostapenko wrote:
>>> This patch adds necessary flags to provide a linkage of these tests
>> in
>>> bootstrap-asan case.
>> I think you'll want to modify Makefile.def and Makefile.tpl because
>> Makefile is generated from them.
Thanks, got it. Here the updated version of previous patch.

Does the patch look sane now?

> Sounds like this would fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56781
>
> Thanks,
>
>
-Maxim
Jakub Jelinek - Sept. 1, 2014, 7:29 a.m.
On Mon, Sep 01, 2014 at 11:19:07AM +0400, Maxim Ostapenko wrote:
> libiberty/ChangeLog:
> 
> 2014-09-01  Max Ostapenko  <m.ostapenko@partner.samsung.com>
> 
> 	* testsuite/Makefile.in(LIBCFLAGS): Add LDFLAGS.

Space before (.

>  # Flags to pass down to makes which are built with the target environment.
>  # The double $ decreases the length of the command line; those variables
>  # are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them.  The
> @@ -3518,9 +3526,9 @@ check-bfd:
>  	@: $(MAKE); $(unstage)
>  	@r=`${PWD_COMMAND}`; export r; \
>  	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
> -	$(HOST_EXPORTS) \
> +	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
>  	(cd $(HOST_SUBDIR)/bfd && \
> -	  $(MAKE) $(FLAGS_TO_PASS)  check)
> +	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)

I'd put the double space right before check instead of in between
different flags, or use a single space everywhere.

> @@ -4392,9 +4400,9 @@ check-opcodes:
>  	@: $(MAKE); $(unstage)
>  	@r=`${PWD_COMMAND}`; export r; \
>  	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
> -	$(HOST_EXPORTS) \
> +	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
>  	(cd $(HOST_SUBDIR)/opcodes && \
> -	  $(MAKE) $(FLAGS_TO_PASS)  check)
> +	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)

Ditto etc.

> @@ -6138,7 +6146,7 @@ check-cgen:
>  	@: $(MAKE); $(unstage)
>  	@r=`${PWD_COMMAND}`; export r; \
>  	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
> -	$(HOST_EXPORTS) \
> +	$(HOST_EXPORTS)  \

Why?

	Jakub
max - Sept. 1, 2014, 8:33 a.m.
On 09/01/2014 11:29 AM, Jakub Jelinek wrote:
> On Mon, Sep 01, 2014 at 11:19:07AM +0400, Maxim Ostapenko wrote:
>> libiberty/ChangeLog:
>>
>> 2014-09-01  Max Ostapenko  <m.ostapenko@partner.samsung.com>
>>
>> 	* testsuite/Makefile.in(LIBCFLAGS): Add LDFLAGS.
> Space before (.
Ugh, sorry.
>
>>   # Flags to pass down to makes which are built with the target environment.
>>   # The double $ decreases the length of the command line; those variables
>>   # are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them.  The
>> @@ -3518,9 +3526,9 @@ check-bfd:
>>   	@: $(MAKE); $(unstage)
>>   	@r=`${PWD_COMMAND}`; export r; \
>>   	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
>> -	$(HOST_EXPORTS) \
>> +	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
>>   	(cd $(HOST_SUBDIR)/bfd && \
>> -	  $(MAKE) $(FLAGS_TO_PASS)  check)
>> +	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
> I'd put the double space right before check instead of in between
> different flags, or use a single space everywhere.
Here the first space appears because extra_make_flags (EXTRA_GCC_FLAGS) 
is empty and autogen replaces this with a space. Removing the second one 
will lead to concatinating of $(EXTRA_GCC_FLAGS) and 
$(EXTRA_BOOTSTRAP_FLAGS). I know, two spaces look ugly, but is there 
more convenient way to avoid this?
>> @@ -4392,9 +4400,9 @@ check-opcodes:
>>   	@: $(MAKE); $(unstage)
>>   	@r=`${PWD_COMMAND}`; export r; \
>>   	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
>> -	$(HOST_EXPORTS) \
>> +	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
>>   	(cd $(HOST_SUBDIR)/opcodes && \
>> -	  $(MAKE) $(FLAGS_TO_PASS)  check)
>> +	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
> Ditto etc.
>
>> @@ -6138,7 +6146,7 @@ check-cgen:
>>   	@: $(MAKE); $(unstage)
>>   	@r=`${PWD_COMMAND}`; export r; \
>>   	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
>> -	$(HOST_EXPORTS) \
>> +	$(HOST_EXPORTS)  \
> Why?
This is pretty the same. For all libs, that wouldn't be bootstrapped, 
autogen inserts a space instead of $(EXTRA_HOST_EXPORTS).

Perhaps I should always insert $(EXTRA_HOST_EXPORTS) and 
$(EXTRA_BOOTSTRAP_FLAGS) with empty/nonempty values instead of tracking 
libraries, that would/wouldn't be bootstrapped?

-Maxim
> 	Jakub
>

Patch

libiberty/ChangeLog:

2014-09-01  Max Ostapenko  <m.ostapenko@partner.samsung.com>

	* testsuite/Makefile.in(LIBCFLAGS): Add LDFLAGS.

ChangeLog:

2014-09-01  Max Ostapenko  <m.ostapenko@partner.samsung.com>

	* Makefile.tpl (EXTRA_HOST_EXPORTS): New variables.
	(EXTRA_BOOTSTRAP_FLAGS): Likewise.
	(check-[+module+]): Add EXTRA_HOST_EXPORTS and EXTRA_BOOTSTRAP_FLAGS.
	* Makefile.in: Regenerate.


diff --git a/Makefile.in b/Makefile.in
index add8cf6..b0917e3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -830,6 +830,14 @@  POSTSTAGE1_FLAGS_TO_PASS = \
 	HOST_LIBS="$${HOST_LIBS}" \
 	"`echo 'ADAFLAGS=$(BOOT_ADAFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
 
+@if gcc-bootstrap
+EXTRA_HOST_EXPORTS = if [ $(current_stage) != stage1 ]; then \
+		       $(POSTSTAGE1_HOST_EXPORTS) \
+		     fi ;
+
+EXTRA_BOOTSTRAP_FLAGS = CC="$$CC" CXX="$$CXX" LDFLAGS="$$LDFLAGS"
+@endif gcc-bootstrap
+
 # Flags to pass down to makes which are built with the target environment.
 # The double $ decreases the length of the command line; those variables
 # are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them.  The
@@ -3518,9 +3526,9 @@  check-bfd:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/bfd && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif bfd
 
@@ -4392,9 +4400,9 @@  check-opcodes:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/opcodes && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif opcodes
 
@@ -5266,9 +5274,9 @@  check-binutils:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/binutils && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif binutils
 
@@ -5696,9 +5704,9 @@  check-bison:
 	@if [ '$(host)' = '$(target)' ] ; then \
 	  r=`${PWD_COMMAND}`; export r; \
 	  s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	  $(HOST_EXPORTS) \
+	  $(HOST_EXPORTS)  \
 	  (cd $(HOST_SUBDIR)/bison && \
-	    $(MAKE) $(FLAGS_TO_PASS)  check); \
+	    $(MAKE) $(FLAGS_TO_PASS)  check)
 	fi
 
 @endif bison
@@ -6138,7 +6146,7 @@  check-cgen:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/cgen && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -6579,7 +6587,7 @@  check-dejagnu:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/dejagnu && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -7020,7 +7028,7 @@  check-etc:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/etc && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -7463,9 +7471,9 @@  check-fastjar:
 	@if [ '$(host)' = '$(target)' ] ; then \
 	  r=`${PWD_COMMAND}`; export r; \
 	  s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	  $(HOST_EXPORTS) \
+	  $(HOST_EXPORTS)  \
 	  (cd $(HOST_SUBDIR)/fastjar && \
-	    $(MAKE) $(FLAGS_TO_PASS)  check); \
+	    $(MAKE) $(FLAGS_TO_PASS)  check)
 	fi
 
 @endif fastjar
@@ -8351,9 +8359,9 @@  check-fixincludes:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/fixincludes && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif fixincludes
 
@@ -8766,9 +8774,9 @@  check-flex:
 	@if [ '$(host)' = '$(target)' ] ; then \
 	  r=`${PWD_COMMAND}`; export r; \
 	  s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	  $(HOST_EXPORTS) \
+	  $(HOST_EXPORTS)  \
 	  (cd $(HOST_SUBDIR)/flex && \
-	    $(MAKE) $(FLAGS_TO_PASS)  check); \
+	    $(MAKE) $(FLAGS_TO_PASS)  check)
 	fi
 
 @endif flex
@@ -9654,9 +9662,9 @@  check-gas:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/gas && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif gas
 
@@ -10528,9 +10536,9 @@  check-gcc:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/gcc && \
-	  $(MAKE) $(FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) check)
+	  $(MAKE) $(FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif gcc
 
@@ -11408,9 +11416,9 @@  check-gmp:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/gmp && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif gmp
 
@@ -12276,9 +12284,9 @@  check-mpfr:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/mpfr && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif mpfr
 
@@ -13144,9 +13152,9 @@  check-mpc:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/mpc && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif mpc
 
@@ -14012,9 +14020,9 @@  check-isl:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/isl && \
-	  $(MAKE) $(FLAGS_TO_PASS) V=1 check)
+	  $(MAKE) $(FLAGS_TO_PASS) V=1 $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif isl
 
@@ -14880,9 +14888,9 @@  check-cloog:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/cloog && \
-	  $(MAKE) $(FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 check)
+	  $(MAKE) $(FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif cloog
 
@@ -15748,9 +15756,9 @@  check-libelf:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/libelf && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif libelf
 
@@ -16610,9 +16618,9 @@  check-gold:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/gold && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif gold
 
@@ -17038,7 +17046,7 @@  check-gprof:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gprof && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -17925,9 +17933,9 @@  check-intl:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/intl && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif intl
 
@@ -18353,7 +18361,7 @@  check-tcl:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/tcl && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -18779,7 +18787,7 @@  check-itcl:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/itcl && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -19666,9 +19674,9 @@  check-ld:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/ld && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif ld
 
@@ -20540,9 +20548,9 @@  check-libbacktrace:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/libbacktrace && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif libbacktrace
 
@@ -21414,9 +21422,9 @@  check-libcpp:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/libcpp && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif libcpp
 
@@ -22288,9 +22296,9 @@  check-libdecnumber:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/libdecnumber && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif libdecnumber
 
@@ -22716,7 +22724,7 @@  check-libgui:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libgui && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -23609,9 +23617,9 @@  check-libiberty:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/libiberty && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	  $(MAKE) $(FLAGS_TO_PASS)  $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif libiberty
 
@@ -24489,9 +24497,9 @@  check-libiberty-linker-plugin:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/libiberty-linker-plugin && \
-	  $(MAKE) $(FLAGS_TO_PASS) @extra_linker_plugin_flags@ check)
+	  $(MAKE) $(FLAGS_TO_PASS) @extra_linker_plugin_flags@ $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif libiberty-linker-plugin
 
@@ -24917,7 +24925,7 @@  check-libiconv:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libiconv && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -25295,7 +25303,7 @@  check-m4:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/m4 && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -25736,7 +25744,7 @@  check-readline:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/readline && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -26177,7 +26185,7 @@  check-sid:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/sid && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -26618,7 +26626,7 @@  check-sim:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/sim && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -27059,7 +27067,7 @@  check-texinfo:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/texinfo && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -28344,7 +28352,7 @@  check-gdb:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gdb && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -28785,7 +28793,7 @@  check-expect:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/expect && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -29226,7 +29234,7 @@  check-guile:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/guile && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -29667,7 +29675,7 @@  check-tk:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/tk && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -30918,7 +30926,7 @@  check-gnattools:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gnattools && \
 	  $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -31811,9 +31819,9 @@  check-lto-plugin:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/lto-plugin && \
-	  $(MAKE) $(FLAGS_TO_PASS) @extra_linker_plugin_flags@ check)
+	  $(MAKE) $(FLAGS_TO_PASS) @extra_linker_plugin_flags@ $(EXTRA_BOOTSTRAP_FLAGS) check)
 
 @endif lto-plugin
 
diff --git a/Makefile.tpl b/Makefile.tpl
index 00dba36..022f746 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -635,6 +635,14 @@  POSTSTAGE1_FLAGS_TO_PASS = \
 	HOST_LIBS="$${HOST_LIBS}" \
 	"`echo 'ADAFLAGS=$(BOOT_ADAFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
 
+@if gcc-bootstrap
+EXTRA_HOST_EXPORTS = if [ $(current_stage) != stage1 ]; then \
+		       $(POSTSTAGE1_HOST_EXPORTS) \
+		     fi ;
+
+EXTRA_BOOTSTRAP_FLAGS = CC="$$CC" CXX="$$CXX" LDFLAGS="$$LDFLAGS"
+@endif gcc-bootstrap
+
 # Flags to pass down to makes which are built with the target environment.
 # The double $ decreases the length of the command line; those variables
 # are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them.  The
@@ -1187,18 +1195,22 @@  check-[+module+]:
 	@if [ '$(host)' = '$(target)' ] ; then \
 	  r=`${PWD_COMMAND}`; export r; \
 	  s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	  $(HOST_EXPORTS) \
+	  $(HOST_EXPORTS) [+ IF bootstrap +]$(EXTRA_HOST_EXPORTS)[+
+	  ENDIF bootstrap +] \
 	  (cd $(HOST_SUBDIR)/[+module+] && \
-	    $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] check); \
+	    $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+][+
+	    IF bootstrap +] $(EXTRA_BOOTSTRAP_FLAGS)[+ ENDIF bootstrap +] check)
 	fi
 [+ ELSE check +]
 check-[+module+]:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) \
+	$(HOST_EXPORTS) [+ IF bootstrap +]$(EXTRA_HOST_EXPORTS)[+
+	ENDIF bootstrap +] \
 	(cd $(HOST_SUBDIR)/[+module+] && \
-	  $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+] check)
+	  $(MAKE) $(FLAGS_TO_PASS) [+extra_make_flags+][+
+	  IF bootstrap +] $(EXTRA_BOOTSTRAP_FLAGS)[+ ENDIF bootstrap +] check)
 [+ ENDIF no_check +]
 @endif [+module+]
diff --git a/libiberty/testsuite/Makefile.in b/libiberty/testsuite/Makefile.in
index d23c09c..ef693c2 100644
--- a/libiberty/testsuite/Makefile.in
+++ b/libiberty/testsuite/Makefile.in
@@ -33,7 +33,7 @@  SHELL = @SHELL@
 
 CC = @CC@
 CFLAGS = @CFLAGS@
-LIBCFLAGS = $(CFLAGS)
+LIBCFLAGS = $(CFLAGS) $(LDFLAGS)
 
 # Multilib support variables.
 MULTISRCTOP =