[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with AC_REQUIRE expansion order
Re: Problem with AC_REQUIRE expansion order
Mon, 04 Aug 2008 22:26:40 -0600
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:18.104.22.168) Gecko/20080708 Thunderbird/22.214.171.124 Mnenhy/0.7.5.666
-----BEGIN PGP SIGNED MESSAGE-----
According to Andreas Schwab on 6/27/2008 7:06 AM:
| When AC_USE_SYSTEM_EXTENSIONS is expanded from a macro that also expands
| AC_PROG_CC for the first time then expansion order is wrong:
| $ cat configure.ac
| This is also a problem with legacy configure scripts, since AC_AIX and
| AC_MINIX are now aliases of AC_USE_SYSTEM_EXTENSIONS.
The above file failed even with autoconf 2.60 or 2.61, even when I used
AC_AIX and AC_MINIX instead of AC_USE_SYSTEM_EXTENSIONS, so at first, I
didn't see the regression.
But I finally figured out what you were complaining about. It turns out
that AC_GNU_SOURCE didn't need to invoke the preprocessor or compiler
prior to 2.62; but it does now that it forwards to
AC_USE_SYSTEM_EXTENSIONS and inherited the additional compiler-dependent
checks. In other words, the regression occurs on this file (works in
2.61, fails in 2.62):
This really boils down to a bigger problem, that has been present for some
time now, and something related has come up on the list a few times .
Basically, AC_PROG_CC doesn't AC_REQUIRE its own body, and this is because
the user is allowed to specify alternate compilers in the argument to
AC_PROG_CC, but the AC_REQUIRE mechanism doesn't really preserve
arguments. We need a way to honor the user's list while still ensuring
that the body of AC_PROG_CC gets hoisted by any macro that does
AC_REQUIRE([AC_PROG_CC]). And in the process, that should make AC_PROG_CC
usable within AS_IF, although I have not tested that yet.
I've tested that this patch fixes the above configure.ac on cygwin (on top
of my other AC_USE_SYSTEM_EXTENSIONS patch); and am currently running the
full testsuite on both Linux and cygwin (unfortunately, the complete
testsuite takes several hours on cygwin). Any comments on my approach?
For those who want to test this patch prior to committing it to the
official repository, you can do:
$ git fetch git://repo.or.cz/autoconf/ericb.git refs/heads/master
or view it at http://repo.or.cz/w/autoconf/ericb.git
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
>From c308e3f1a6d2a3667b22f4228be2d3b8a7f6e4df Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 4 Aug 2008 22:10:24 -0600
Subject: [PATCH] Fix autoconf 2.62 regression in AC_GNU_SOURCE vs. AC_PROG_CC.
* lib/autoconf/c.m4 (AC_PROG_CC): Put user selection of
compilers into earlier diversion...
(_AC_PROG_CC): ...so that remaining code can be split into new
macro that is guaranteed to be emitted once by first AC_REQUIRE.
* lib/autoconf/specific.m4 (AC_USE_SYSTEM_EXTENSIONS): Require the
compiler to be found first.
* tests/c.at (AC_USE_SYSTEM_EXTENSIONS): Add to the test.
Reported by Andreas Schwab.
Signed-off-by: Eric Blake <address@hidden>
ChangeLog | 10 ++++++++++
lib/autoconf/c.m4 | 23 ++++++++++++++++++-----
lib/autoconf/specific.m4 | 1 +
tests/c.at | 20 ++++++++++++++++++++
4 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8aa2d51..911154b 100644
@@ -1,5 +1,15 @@
2008-08-04 Eric Blake <address@hidden>
+ Fix autoconf 2.62 regression in AC_GNU_SOURCE vs. AC_PROG_CC.
+ * lib/autoconf/c.m4 (AC_PROG_CC): Put user selection of
+ compilers into earlier diversion...
+ (_AC_PROG_CC): ...so that remaining code can be split into new
+ macro that is guaranteed to be emitted once by first AC_REQUIRE.
+ * lib/autoconf/specific.m4 (AC_USE_SYSTEM_EXTENSIONS): Require the
+ compiler to be found first.
+ * tests/c.at (AC_USE_SYSTEM_EXTENSIONS): Add to the test.
+ Reported by Andreas Schwab.
Fix autoheader 2.62 regression on AC_DEFINE([__EXTENSIONS__]).
* lib/autoconf/specific.m4 (AC_USE_SYSTEM_EXTENSIONS): Use a
unique key for the AH_VERBATIM.
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index ffaa06e..fbefeb6 100644
@@ -1,7 +1,7 @@
# This file is part of Autoconf. -*- Autoconf -*-
# Programming languages support.
-# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-# Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free
+# Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -544,18 +544,31 @@ AU_DEFUN([ac_cv_prog_gcc],
# COMPILER ... is a space separated list of C compilers to search for.
# This just gives the user an opportunity to specify an alternative
# search list for the C compiler.
+# We want to honor the user's list, while still respecting the many
+# macros that do AC_REQUIRE([AC_PROG_CC]) expecting to get the entire
+# C compiler check in advance. Hence, the AC_REQUIRE'd body and
+# dumping of the user's list in an earlier diversion.
AC_ARG_VAR([CC], [C compiler command])dnl
AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
- [AC_CHECK_TOOLS(CC, [$1])],
+AS_IF([test -n "$ac_prog_cc_list"],
if test -z "$CC"; then
dnl Here we want:
@@ -595,7 +608,7 @@ fi
diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4
index 5fcfe37..0fd439e 100644
@@ -386,6 +386,7 @@ matches *mingw32*])# AC_MINGW32
AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
if test "$MINIX" = yes; then
diff --git a/tests/c.at b/tests/c.at
index bc07c6e..3c5e167 100644
@@ -254,4 +254,24 @@ _AT_CHECK_AC_MACRO(
AC_DEFINE([__EXTENSIONS__], , [Manually defined for Solaris])
+# Some existing configure.ac want to use both AC_GNU_SOURCE and
+# AC_PROG_CC from a single macro; this was broken in 2.62 when
+# AC_GNU_SOURCE started requiring the compiler.
- Re: Problem with AC_REQUIRE expansion order,
Eric Blake <=