Patchwork Unable to build --enable-build-with-cxx --enable-languages=c,c++ --with-gold

login
register
mail settings
Submitter Ian Taylor
Date Oct. 5, 2010, 2:18 p.m.
Message ID <mcr7hhwena0.fsf@google.com>
Download mbox | patch
Permalink /patch/66833/
State New
Headers show

Comments

Ian Taylor - Oct. 5, 2010, 2:18 p.m.
Jerry Quinn <jlquinn@optonline.net> writes:

> This is on Debian testing.  I have a clean tree r164966.  I configure as
> follows:
>
> ../../gcc-in-cxx/configure --enable-build-with-cxx
> --enable-languages=c,c++ --with-gold
>
>
> I just run make and it fails as below.  Any ideas what might be wrong?

It's a problem with using a condition in autoconf.  The AC_REQUIRE
system that autoconf uses fails when some tests are run in conditions.

This patch fixes it.  Build maintainers: is the right approach, or is
there a better one?

Ian


2010-10-05  Ian Lance Taylor  <iant@google.com>

	* configure.ac: Run AC_PROG_EGREP outside of ENABLE_BUILD_WITH_CXX
	condition.  Run AC_HEADER_STDC inside of condition.
	* configure: Rebuild.
Andreas Schwab - Oct. 5, 2010, 3:04 p.m.
Ian Lance Taylor <iant@google.com> writes:

> Index: configure.ac
> ===================================================================
> --- configure.ac	(revision 164990)
> +++ configure.ac	(working copy)
> @@ -56,15 +56,22 @@ fi
>  AC_HEADER_TIME
>  ACX_HEADER_STRING
>  
> +# Running AC_CHECK_HEADERS in a conditional means that we will only
> +# test for supporting programs in a conditional.  Test for them here,
> +# so that the tests are run either way.
> +AC_PROG_EGREP
> +
>  # AC_CHECK_HEADERS is repeated to work around apparent autoconf 2.59 bug.  If
>  # AC_CHECK_HEADERS comes after the if clause, the last AC_LANG call gets used,
>  # no matter which branch is taken.
>  if test "$ENABLE_BUILD_WITH_CXX" = "no"; then
>     AC_LANG(C)
> +   AC_HEADER_STDC
>     AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \
>  	stdlib.h strings.h string.h sys/file.h unistd.h)
>  else
>     AC_LANG(C++)
> +   AC_HEADER_STDC
>     AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \
>  	stdlib.h strings.h string.h sys/stat.h sys/file.h unistd.h)
>  fi

You cannot put AC_LANG in a shell conditional like this in the first
place.  As it stands now all subsequent autoconf macros are using the
C++ language variants (try exchanging the two AC_LANG calls and compare
the generated configure script).  I think the only reliable way to
implement that is to put all tests in a macro, and expand it twice in
the two arms of the AS_IF macro with [test "$ENABLE_BUILD_WITH_CXX" =
"no"] as the condition.

Andreas.

Patch

Index: configure.ac
===================================================================
--- configure.ac	(revision 164990)
+++ configure.ac	(working copy)
@@ -56,15 +56,22 @@  fi
 AC_HEADER_TIME
 ACX_HEADER_STRING
 
+# Running AC_CHECK_HEADERS in a conditional means that we will only
+# test for supporting programs in a conditional.  Test for them here,
+# so that the tests are run either way.
+AC_PROG_EGREP
+
 # AC_CHECK_HEADERS is repeated to work around apparent autoconf 2.59 bug.  If
 # AC_CHECK_HEADERS comes after the if clause, the last AC_LANG call gets used,
 # no matter which branch is taken.
 if test "$ENABLE_BUILD_WITH_CXX" = "no"; then
    AC_LANG(C)
+   AC_HEADER_STDC
    AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \
 	stdlib.h strings.h string.h sys/file.h unistd.h)
 else
    AC_LANG(C++)
+   AC_HEADER_STDC
    AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \
 	stdlib.h strings.h string.h sys/stat.h sys/file.h unistd.h)
 fi
@@ -93,7 +100,6 @@  AC_CHECK_DECLS(m4_split(m4_normalize(lib
 
 # Checks for library functions.
 AC_FUNC_ALLOCA
-AC_HEADER_STDC
 AM_LANGINFO_CODESET
 ZW_GNU_GETTEXT_SISTER_DIR