bug#19311: regression: 1.14 may use ac_aux_dir before defined (again)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#19311: regression: 1.14 may use ac_aux_dir before defined (again)

Jan Engelhardt

When AC_SYSTEM_EXTENSIONS precedes AM_INIT_AUTOMAKE, it used to throw an
error - which has been fixed in
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15981 .

I have here another instance of what appears to be a similar issue. This
one is also a regression (used to work in 1.13.4), and the regression is
still present in {automake 1.14.1 + patch from #15981}. The problem
originates in libmemcached/configure.ac, and I have produced the
following reduced testcase that exhibits the issue:

$ cat <<EOF >configure.ac
AC_INIT([foo], [0])
AC_PROG_CC([cc gcc clang])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 subdir-objects foreign])
AC_OUTPUT([Makefile])
EOF
$ echo '' >Makefile.am
$ md m4
$ autoreconf -fi
configure.ac:2: installing 'build-aux/compile'
configure.ac:5: installing 'build-aux/install-sh'
configure.ac:5: installing 'build-aux/missing'
$ ./configure
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
configure: error: cannot find install-sh, install.sh, or shtool in "." "./.."
"./../.."

With automake-1.13.4, configure would succeed through to the end
("config.status: creating Makefile").



Reply | Threaded
Open this post in threaded view
|

bug#19311: regression: 1.14 may use ac_aux_dir before defined (again)

Stefano Lattarini
retitle 19311 AC_PROG_CC can force wrong $ac_aux_dir definition in automake 1.14
severity 19311 minor
thanks

On 12/08/2014 06:15 PM, Jan Engelhardt wrote:

>
> When AC_SYSTEM_EXTENSIONS precedes AM_INIT_AUTOMAKE, it used to throw an
> error - which has been fixed in
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15981 .
>
> I have here another instance of what appears to be a similar issue. This
> one is also a regression (used to work in 1.13.4), and the regression is
> still present in {automake 1.14.1 + patch from #15981}. The problem
> originates in libmemcached/configure.ac, and I have produced the
> following reduced testcase that exhibits the issue:
>
> $ cat <<EOF >configure.ac
> AC_INIT([foo], [0])
> AC_PROG_CC([cc gcc clang])
> AC_CONFIG_AUX_DIR([build-aux])
> AC_CONFIG_MACRO_DIR([m4])
> AM_INIT_AUTOMAKE([1.11 subdir-objects foreign])
> AC_OUTPUT([Makefile])
> EOF
> $ echo '' >Makefile.am
> $ md m4
> $ autoreconf -fi
> configure.ac:2: installing 'build-aux/compile'
> configure.ac:5: installing 'build-aux/install-sh'
> configure.ac:5: installing 'build-aux/missing'
> $ ./configure
> checking for cc... cc
> checking whether the C compiler works... yes
> checking for C compiler default output file name... a.out
> checking for suffix of executables...
> checking whether we are cross compiling... no
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether cc accepts -g... yes
> checking for cc option to accept ISO C89... none needed
> configure: error: cannot find install-sh, install.sh, or shtool in "." "./.."
> "./../.."
>
> With automake-1.13.4, configure would succeed through to the end
> ("config.status: creating Makefile").
>
>
This is due to the fact that automake actually rewrite AC_PROG_CC
in order to integrate it with the 'compile' script, and to do so, it
needs the $am_aux_dir variable to be defined.  That in turns requires
AC_CONFIG_AUX_DIR to be called beforehand.  If that macro isn't
called explicitly before the AC_PROG_CC invocation, then the code in
AM_AUX_DIR_EXPAND will force-expand it with its default behavior,
which is to have configure look into '.', '..' and '../..' for the
required auxiliary scripts, and bail out if they are not found.
Which is what is causing your issue.

The issue can be solved by moving the AC_CONFIG_AUX_DIR call before
the AC_PROG_CC call.  Arguably, a more user-friendly behavior would
be to automake patch AC_CONFIG_AUX_DIR so that it fails hard and with
a clear error message if it gets invoked after AM_AUX_DIR_EXPAND has
been called (explicitly or implicitly).  Patches welcome (either for
code or docs).

An even better solution *might* be to shuffle the expansion of
AC_CONFIG_AUX_DIR so that it goes immediately after the AC_INIT
explansion, but that requires more m4 magic than my rusty brain
can grasp at the momwnt; and in addition, I'm not sure whether
such a change could cause new backward incompatibilities (possibly
subtle ones).  Looping in Eric,Blake explicitly, who, being the m4
maintainer and one of the main Autoconf devs, is probably the best
person to give feedback.

Thanks,
   Stefano





Reply | Threaded
Open this post in threaded view
|

bug#19311: [FYI] {minor} Expose automake bug#19311

Stefano Lattarini
In reply to this post by Jan Engelhardt
AC_PROG_CC called before AC_CONFIG_AUX_DIR can silently force wrong
$ac_aux_dir definition.

* t/auxdir-pr19311.sh: New.
* t/list-of-tests.mk: Add it as an XFAIL test.

Signed-off-by: Stefano Lattarini <[hidden email]>
---
 t/auxdir-pr19311.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
 t/list-of-tests.mk  |  2 ++
 2 files changed, 47 insertions(+)
 create mode 100644 t/auxdir-pr19311.sh

diff --git a/t/auxdir-pr19311.sh b/t/auxdir-pr19311.sh
new file mode 100644
index 0000000..56c71a1
--- /dev/null
+++ b/t/auxdir-pr19311.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2014 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Automake bug#19311: AC_PROG_CC called before AC_CONFIG_AUX_DIR can
+# silently force wrong $ac_aux_dir definition.
+
+am_create_testdir=empty
+required=cc
+. test-init.sh
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_PROG_CC
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE
+AC_OUTPUT([Makefile])
+END
+
+: > Makefile.am
+
+mkdir build-aux
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+test -f build-aux/compile
+test -f build-aux/install-sh
+
+./configure
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index e6ee856..8d458f5 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -30,6 +30,7 @@ t/pm/Version3.pl
 
 XFAIL_TESTS = \
 t/all.sh \
+t/auxdir-pr19311.sh \
 t/cond17.sh \
 t/gcj6.sh \
 t/override-conditional-2.sh \
@@ -185,6 +186,7 @@ t/auxdir-autodetect.sh \
 t/auxdir-computed.tap \
 t/auxdir-misplaced.sh \
 t/auxdir-nonexistent.sh \
+t/auxdir-pr19311.sh \
 t/auxdir-unportable.tap \
 t/backcompat.sh \
 t/backcompat2.sh \
--
2.1.3