Patchwork PATCH RFA: Build system: Check for -static-libstdc++

login
register
mail settings
Submitter Ian Taylor
Date Nov. 3, 2010, 2:23 p.m.
Message ID <mcrr5f2o59y.fsf@google.com>
Download mbox | patch
Permalink /patch/70008/
State New
Headers show

Comments

Ian Taylor - Nov. 3, 2010, 2:23 p.m.
Ralf Wildenhues <Ralf.Wildenhues@gmx.de> writes:

> This will not work with non-GCC compilers that print something other
> than "unrecognized option" upon such an option.  I think you should at
> least check that you can form a command with the flag that exits zero,
> that way you may still have warnings during Stage 1 but at least not a
> hard build failure.
>
> Alternatively, you could check whether $GXX is yes, to be sure to only
> accept the flag for GCC.

Good point.  I think testing $GXX is fine.  How about this patch?

Ian


2010-11-03  Ian Lance Taylor  <iant@google.com>

	* configure.ac: Set and substitute STATIC_LIBSTDCXX.
	* Makefile.in (STATIC_LIBSTDCXX): New variable.
	* configure: Rebuild.
Ralf Wildenhues - Nov. 3, 2010, 7:18 p.m.
* Ian Lance Taylor wrote on Wed, Nov 03, 2010 at 03:23:05PM CET:
> Ralf Wildenhues writes:
> > This will not work with non-GCC compilers that print something other
> > than "unrecognized option" upon such an option.  I think you should at
> > least check that you can form a command with the flag that exits zero,
> > that way you may still have warnings during Stage 1 but at least not a
> > hard build failure.
> >
> > Alternatively, you could check whether $GXX is yes, to be sure to only
> > accept the flag for GCC.
> 
> Good point.  I think testing $GXX is fine.  How about this patch?

This looks OK to me from a correctness POV, but I cannot approve nor do
I intend a statement regarding the other objections.

Cheers,
Ralf

> 2010-11-03  Ian Lance Taylor  <iant@google.com>
> 
> 	* configure.ac: Set and substitute STATIC_LIBSTDCXX.
> 	* Makefile.in (STATIC_LIBSTDCXX): New variable.
> 	* configure: Rebuild.

Patch

Index: configure.ac
===================================================================
--- configure.ac	(revision 166249)
+++ configure.ac	(working copy)
@@ -4497,6 +4497,24 @@  done
 # UNSORTED
 # --------
 
+# Test whether $CXX supports -static-libstdc++
+AC_CACHE_CHECK([whether $CXX supports -static-libstdc++],
+	gcc_cv_cxx_supports_static_libstdcxx,
+	[if test "$GXX" != "yes"; then
+	   gcc_cv_cxx_supports_static_libstdcxx=no
+	 elif $CXX -static-libstdc++ 2>&1 >/dev/null |
+	    grep 'unrecognized option' >/dev/null; then
+	   gcc_cv_cxx_supports_static_libstdcxx=no
+	 else
+	   gcc_cv_cxx_supports_static_libstdcxx=yes
+	 fi])
+if test "$gcc_cv_cxx_supports_static_libstdcxx" = yes; then
+  STATIC_LIBSTDCXX=-static-libstdc++
+else
+  STATIC_LIBSTDCXX=
+fi
+AC_SUBST(STATIC_LIBSTDCXX)
+
 # Create .gdbinit.
 
 echo "dir ." > .gdbinit
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 166249)
+++ Makefile.in	(working copy)
@@ -233,6 +233,10 @@  LINKER_FLAGS = $(CFLAGS)
 endif
 endif
 
+# This is set by the configure script to be -static-libstdc++ if
+# $(CXX) supports the option.
+STATIC_LIBSTDCXX = @STATIC_LIBSTDCXX@
+
 # -------------------------------------------
 # Programs which operate on the build machine
 # -------------------------------------------