Patchwork Don't require C++ bootstrap compiler (PR bootstrap/46810)

login
register
mail settings
Submitter Ian Taylor
Date Dec. 7, 2010, 6:45 p.m.
Message ID <mcry681pgll.fsf@google.com>
Download mbox | patch
Permalink /patch/74591/
State New
Headers show

Comments

Ian Taylor - Dec. 7, 2010, 6:45 p.m.
This is an example of the alternative approach I was thinking of: only
run the C++ tests if the C++ compiler works.  Does this look OK?

Ian


2010-12-07  Ian Lance Taylor  <iant@google.com>

	PR bootstrap/46810
	* configure.ac: Only run C++ tests if the C++ compiler works.
Jakub Jelinek - Dec. 7, 2010, 7:06 p.m.
On Tue, Dec 07, 2010 at 10:45:10AM -0800, Ian Lance Taylor wrote:
> This is an example of the alternative approach I was thinking of: only
> run the C++ tests if the C++ compiler works.  Does this look OK?

It could work, but I think you should
a) rm -f conftest.*
b) C++ ac_compile is
   $CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext
   so you should probably use $CXXFLAGS $CPPFLAGS too, not sure if
   .cc vs. .cpp extension could matter for any weird compilers.
c) >&5 should probably be >&AS_MESSAGE_LOG_FD

> 2010-12-07  Ian Lance Taylor  <iant@google.com>
> 
> 	PR bootstrap/46810
> 	* configure.ac: Only run C++ tests if the C++ compiler works.
> 
> 

> Index: configure.ac
> ===================================================================
> --- configure.ac	(revision 167515)
> +++ configure.ac	(working copy)
> @@ -913,13 +913,17 @@ AC_C_BIGENDIAN
>  # Checks for C++ headers
>  # ----------------------
>  
> -AC_LANG_PUSH(C++)
> +# Only run the tests if the C++ compiler works.
> +echo "int i;" > conftest.cc
> +if $CXX -c conftest.cc >&5; then
> +  AC_LANG_PUSH(C++)
> +
> +  AC_CHECK_HEADERS(unordered_map)
> +  AC_CHECK_HEADERS(tr1/unordered_map)
> +  AC_CHECK_HEADERS(ext/hash_map)
>  
> -AC_CHECK_HEADERS(unordered_map)
> -AC_CHECK_HEADERS(tr1/unordered_map)
> -AC_CHECK_HEADERS(ext/hash_map)
> -
> -AC_LANG_POP(C++)
> +  AC_LANG_POP(C++)
> +fi
>  
>  # --------
>  # UNSORTED


	Jakub
Ralf Wildenhues - Dec. 7, 2010, 7:15 p.m.
* Jakub Jelinek wrote on Tue, Dec 07, 2010 at 08:06:56PM CET:
> On Tue, Dec 07, 2010 at 10:45:10AM -0800, Ian Lance Taylor wrote:
> > This is an example of the alternative approach I was thinking of: only
> > run the C++ tests if the C++ compiler works.  Does this look OK?
> 
> It could work, but I think you should
> a) rm -f conftest.*
> b) C++ ac_compile is
>    $CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext
>    so you should probably use $CXXFLAGS $CPPFLAGS too, not sure if
>    .cc vs. .cpp extension could matter for any weird compilers.

For MSVC it makes a difference.  Not sure if there is any danger of GCC
ever being compiled with it though.  :-)

A compile-only test doesn't catch whether linking fails though, nor
whether preprocessing is borked for some other reason; I don't think
this is all that relevant though.

Agreed on all other accounts.

> c) >&5 should probably be >&AS_MESSAGE_LOG_FD

> > 2010-12-07  Ian Lance Taylor  <iant@google.com>
> > 
> > 	PR bootstrap/46810
> > 	* configure.ac: Only run C++ tests if the C++ compiler works.

Cheers,
Ralf

Patch

Index: configure.ac
===================================================================
--- configure.ac	(revision 167515)
+++ configure.ac	(working copy)
@@ -913,13 +913,17 @@  AC_C_BIGENDIAN
 # Checks for C++ headers
 # ----------------------
 
-AC_LANG_PUSH(C++)
+# Only run the tests if the C++ compiler works.
+echo "int i;" > conftest.cc
+if $CXX -c conftest.cc >&5; then
+  AC_LANG_PUSH(C++)
+
+  AC_CHECK_HEADERS(unordered_map)
+  AC_CHECK_HEADERS(tr1/unordered_map)
+  AC_CHECK_HEADERS(ext/hash_map)
 
-AC_CHECK_HEADERS(unordered_map)
-AC_CHECK_HEADERS(tr1/unordered_map)
-AC_CHECK_HEADERS(ext/hash_map)
-
-AC_LANG_POP(C++)
+  AC_LANG_POP(C++)
+fi
 
 # --------
 # UNSORTED