Patchwork Fix PR bootstrap/54820

login
register
mail settings
Submitter Eric Botcazou
Date Oct. 11, 2012, 12:56 p.m.
Message ID <10689037.f9KFBEBVzS@polaris>
Download mbox | patch
Permalink /patch/190905/
State New
Headers show

Comments

Eric Botcazou - Oct. 11, 2012, 12:56 p.m.
> 2012-10-09  Eric Botcazou  <ebotcazou@adacore.com
> 
> 	PR bootstrap/54820
> 	* Makefile.tpl (STAGE1_FLAGS_TO_PASS): New variable.
> 	(host_modules): Add STAGE1_FLAGS_TO_PASS to args.
> 	* Makefile.in: Regenerate.
> 	* configure.ac (have_static_libs): New variable and associated check.
> 	(stage1-ldflags): Move to after stage1_libs and set to -static-libstdc++
> 	-static-libgcc if stage1_libs is empty and have_static_libs is yes.
> 	* configure: Regenerate.
> gcc/ada
> 	* gcc-interface/Make-lang.in (GCC_LINK): Remove -static-libstdc++
> 	-static-libgcc.

The Makefile.tpl change was a bit rough...  Here is a better patch, where a 
new variable stage1_args is defined for the host modules.

Tested on x86_64-suse-linux, OK for the mainline?


2012-10-11  Eric Botcazou  <ebotcazou@adacore.com>

	PR bootstrap/54820
	* Makefile.tpl (STAGE1_FLAGS_TO_PASS): New variable.
	(all-[+prefix+][+module+]): Pass stage1_args to sub-makes.
	(all-stage[+id+]-[+prefix+][+module+]): Likewise, if prev is false.
	(clean-stage[+id+]-[+prefix+][+module+]): Likewise, if prev is false.
	(host_modules): Set stage1_args to STAGE1_FLAGS_TO_PASS.
	* Makefile.in: Regenerate.
	* configure.ac (have_static_libs): New variable and associated check.
	(stage1-ldflags): Move to after stage1_libs and set to -static-libstdc++
	-static-libgcc if stage1_libs is empty and have_static_libs is yes.
	* configure: Regenerate.
gcc/ada
	* gcc-interface/Make-lang.in (GCC_LINK): Remove hardcoded options.

Patch

Index: Makefile.tpl
===================================================================
--- Makefile.tpl	(revision 192353)
+++ Makefile.tpl	(working copy)
@@ -615,6 +615,12 @@  EXTRA_HOST_FLAGS = \
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
 
+# Flags to pass to stage1 or when not bootstrapping.
+
+STAGE1_FLAGS_TO_PASS = \
+	LDFLAGS="$${LDFLAGS}" \
+	HOST_LIBS="$${HOST_LIBS}"
+
 # Flags to pass to stage2 and later makes.
 
 POSTSTAGE1_FLAGS_TO_PASS = \
@@ -1076,7 +1082,7 @@  all-[+prefix+][+module+]: configure-[+pr
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	[+exports+] [+extra_exports+] \
 	(cd [+subdir+]/[+module+] && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) [+args+] [+extra_make_flags+] \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) [+args+] [+stage1_args+] [+extra_make_flags+] \
 		$(TARGET-[+prefix+][+module+]))
 @endif [+prefix+][+module+]
 
@@ -1109,9 +1115,8 @@  all-stage[+id+]-[+prefix+][+module+]: co
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		[+args+] [+
-		IF prev +][+poststage1_args+][+ ENDIF prev
-		+] [+extra_make_flags+] \
+		[+args+] [+IF prev +][+poststage1_args+][+ ELSE prev +] \
+		[+stage1_args+][+ ENDIF prev +] [+extra_make_flags+] \
 		TFLAGS="$(STAGE[+id+]_TFLAGS)" \
 		$(TARGET-stage[+id+]-[+prefix+][+module+])
 
@@ -1125,9 +1130,8 @@  clean-stage[+id+]-[+prefix+][+module+]:
 	  $(MAKE) stage[+id+]-start; \
 	fi; \
 	cd [+subdir+]/[+module+] && \
-	$(MAKE) [+args+] [+ IF prev +] \
-		[+poststage1_args+] [+ ENDIF prev +] \
-		[+extra_make_flags+] clean
+	$(MAKE) [+args+] [+ IF prev +][+poststage1_args+][+ ELSE prev +] \
+	[+stage1_args+][+ ENDIF prev +] [+extra_make_flags+] clean
 @endif [+prefix+][+module+]-bootstrap
 
 [+ ENDFOR bootstrap_stage +]
@@ -1162,6 +1166,7 @@  clean-stage[+id+]-[+prefix+][+module+]:
        exports="$(HOST_EXPORTS)"
        poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)"
        args="$(EXTRA_HOST_FLAGS)"
+       stage1_args="$(STAGE1_FLAGS_TO_PASS)"
        poststage1_args="$(POSTSTAGE1_FLAGS_TO_PASS)" +]
 
 .PHONY: check-[+module+] maybe-check-[+module+]
Index: configure.ac
===================================================================
--- configure.ac	(revision 192353)
+++ configure.ac	(working copy)
@@ -1182,6 +1182,22 @@  if test -z "$LD"; then
   fi
 fi
 
+# Check whether -static-libstdc++ -static-libgcc is supported
+have_static_libs=no
+if test "$GCC" = yes; then
+  saved_LDFLAGS="$LDFLAGS"
+
+  LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
+  AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
+  AC_LANG_PUSH(C++)
+  AC_LINK_IFELSE([int main() {}],
+    [AC_MSG_RESULT([yes]); have_static_libs=yes],
+    [AC_MSG_RESULT([no])])
+  AC_LANG_POP(C++)
+
+  LDFLAGS="$saved_LDFLAGS"
+fi
+
 ACX_PROG_GNAT
 ACX_PROG_CMP_IGNORE_INITIAL
 
@@ -1478,17 +1494,6 @@  case $with_host_libstdcxx in
     ;;
 esac
 
-# Linker flags to use for stage1 or when not boostrapping.
-AC_ARG_WITH(stage1-ldflags,
-[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])],
-[if test "$withval" = "no" -o "$withval" = "yes"; then
-   stage1_ldflags=
- else
-   stage1_ldflags=$withval
- fi],
-[stage1_ldflags=])
-AC_SUBST(stage1_ldflags)
-
 # Libraries to use for stage1 or when not bootstrapping.
 AC_ARG_WITH(stage1-libs,
 [AS_HELP_STRING([--with-stage1-libs=LIBS], [libraries for stage1])],
@@ -1500,6 +1505,23 @@  AC_ARG_WITH(stage1-libs,
 [stage1_libs=$with_host_libstdcxx])
 AC_SUBST(stage1_libs)
 
+# Linker flags to use for stage1 or when not bootstrapping.
+AC_ARG_WITH(stage1-ldflags,
+[AS_HELP_STRING([--with-stage1-ldflags=FLAGS], [linker flags for stage1])],
+[if test "$withval" = "no" -o "$withval" = "yes"; then
+   stage1_ldflags=
+ else
+   stage1_ldflags=$withval
+ fi],
+[stage1_ldflags=
+ # In stage 1, default to linking libstdc++ and libgcc statically with GCC
+ # if supported.  But if the user explicitly specified the libraries to use,
+ # trust that they are doing what they want.
+ if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then
+   stage1_ldflags="-static-libstdc++ -static-libgcc"
+ fi])
+AC_SUBST(stage1_ldflags)
+
 # Libraries to use for stage2 and later builds.  This defaults to the
 # argument passed to --with-host-libstdcxx.
 AC_ARG_WITH(boot-libs,
Index: gcc/ada/gcc-interface/Make-lang.in
===================================================================
--- gcc/ada/gcc-interface/Make-lang.in	(revision 192353)
+++ gcc/ada/gcc-interface/Make-lang.in	(working copy)
@@ -172,7 +172,7 @@  endif
 # Strip -Werror during linking for the LTO bootstrap
 GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS))
 
-GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) -static-libgcc -static-libstdc++ $(LDFLAGS)
+GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) $(LDFLAGS)
 
 # Lists of files for various purposes.