GNU bug report logs - #7864
odd configure bug with dependency checking and conditional C++ support

Previous Next

Package: automake;

Reported by: Eric Blake <eblake <at> redhat.com>

Date: Wed, 19 Jan 2011 04:45:02 UTC

Severity: normal

Done: Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7864 in the body.
You can then email your comments to 7864 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-automake <at> gnu.org:
bug#7864; Package automake. (Wed, 19 Jan 2011 04:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eric Blake <eblake <at> redhat.com>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Wed, 19 Jan 2011 04:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: bug-automake <at> gnu.org, bug-gnulib <bug-gnulib <at> gnu.org>
Subject: odd configure bug with dependency checking and conditional C++ support
Date: Tue, 18 Jan 2011 21:52:08 -0700
[Message part 1 (text/plain, inline)]
http://lists.gnu.org/archive/html/bug-m4/2010-12/msg00001.html
reported that on Haiku, builds of m4 fail with a strange error:

checking dependency style of :... mkdir: cannot create directory
`conftest.dir': File or Directory already exists
cp: accessing `conftest.dir': Bad data
./configure: line 28036: cd: conftest.dir: Not a directory
./configure: line 28047: ./depcomp: No such file or directory
none

I traced it to the following: M4 is using gnulib's ansi-c++-opt module
to enable support for optional C++ compilation support, and has this
line in configure.ac to disable C++ by default:

AC_DEFUN([gl_CXX_CHOICE_DEFAULT_NO])

Then, when gnulib finally gets around to invoking gl_PROG_ANSI_CXX, $CXX
is : (the default for not using C++), and the macro does this (rather
than directly calling AC_PROG_CXX which unconditionally requires a
working C++ compiler:

 dnl This macro invocation resolves an automake error:
  dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does
not appear in AM_CONDITIONAL
  dnl /usr/local/share/automake-1.11/am/depend2.am:   The usual way to
define `am__fastdepCXX' is to add `AC_PROG_CXX'
  dnl /usr/local/share/automake-1.11/am/depend2.am:   to `configure.ac'
and run `aclocal' and `autoconf' again.
  _AM_DEPENDENCIES([CXX])

Yes, Bruno is exploiting undocumented automake internals.  Normally,
_AM_DEPENDENCIES is called so early in the build process that
conftest.dir does not exist, but in m4's case, there is a leftover
conftest.dir from a prior test because the C++ compiler isn't checked
until about halfway through configure.  Also, _AM_DEPENDENCIES normally
assumes that $CXX is a valid compiler (since AC_PROG_CXX aborts
configure if the required compiler is not available), but obviously,
with Bruno's attempt to conditionalize things, CXX of : will flat out
fail the dependency check.

The end result is that halfway through configure, automake's attempt to
check for C++ dependency mode even though C++ compilation was not
requested ends up changing the working directory, so that the remainder
of the configure script falls flat because all sorts of assumptions
about running directly in $builddir have been violated.

First - should autoconf's m4/depend.m4 be changed to use mkdir -p
instead of mkdir, when creating conftest.dir?  Should it be taught that
if CXX is :, that the dependency check should be skipped?  Also, should
it be made more robust to cd failure, so that it does not leave the rest
of the configure running in an unknown temporary sub-directory?

Second - when gnulib is avoiding the C++ compiler, why is it still
trying to determine the dependency mode?  I'm applying this patch to
gnulib to avoid the issue in the first place when CXX=: (but it still
doesn't solve the automake issue of dependency checking not being robust
to a pre-existing conftest.dir when C++ compilation is requested via
./configure --enable-cxx).

From 8a5019c9db43ed95ad763683761a0023bf536efb Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake <at> redhat.com>
Date: Tue, 18 Jan 2011 21:49:45 -0700
Subject: [PATCH] ansi-c++-opt: skip C++ dependency style if C++ is unused

* m4/ansi-c++.m4 (gl_PROG_ANSI_CXX): Avoid full-blown dependency
tests when we know C++ compilation is not desired.
Reported by Scott McCreary.

Signed-off-by: Eric Blake <eblake <at> redhat.com>
---
 ChangeLog      |    7 +++++++
 m4/ansi-c++.m4 |   16 ++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 00f9ebe..263f1a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-01-18  Eric Blake  <eblake <at> redhat.com>
+
+	ansi-c++-opt: skip C++ dependency style if C++ is unused
+	* m4/ansi-c++.m4 (gl_PROG_ANSI_CXX): Avoid full-blown dependency
+	tests when we know C++ compilation is not desired.
+	Reported by Scott McCreary.
+
 2011-01-18  Bruno Haible  <bruno <at> clisp.org>

 	*printf-posix: Avoid test failures. Make tests work on MacOS X, Cygwin.
diff --git a/m4/ansi-c++.m4 b/m4/ansi-c++.m4
index b25cf56..d6352ee 100644
--- a/m4/ansi-c++.m4
+++ b/m4/ansi-c++.m4
@@ -1,4 +1,4 @@
-# ansi-c++.m4 serial 6
+# ansi-c++.m4 serial 7
 dnl Copyright (C) 2002-2003, 2005, 2010-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -116,9 +116,13 @@ EOF

   AM_CONDITIONAL([$2], [test "$$1" != ":"])

-  dnl This macro invocation resolves an automake error:
-  dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does
not appear in AM_CONDITIONAL
-  dnl /usr/local/share/automake-1.11/am/depend2.am:   The usual way to
define `am__fastdepCXX' is to add `AC_PROG_CXX'
-  dnl /usr/local/share/automake-1.11/am/depend2.am:   to `configure.ac'
and run `aclocal' and `autoconf' again.
-  _AM_DEPENDENCIES([CXX])
+  if test "$$1" != ":"; then
+    dnl This macro invocation resolves an automake error:
+    dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX
does not appear in AM_CONDITIONAL
+    dnl /usr/local/share/automake-1.11/am/depend2.am:   The usual way
to define `am__fastdepCXX' is to add `AC_PROG_CXX'
+    dnl /usr/local/share/automake-1.11/am/depend2.am:   to
`configure.ac' and run `aclocal' and `autoconf' again.
+    _AM_DEPENDENCIES([CXX])
+  else
+    AM_CONDITIONAL([am__fastdepCXX], [false])
+  fi
 ])
-- 
1.7.3.4



-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to owner <at> debbugs.gnu.org, bug-automake <at> gnu.org:
bug#7864; Package automake. (Wed, 19 Jan 2011 18:07:01 GMT) Full text and rfc822 format available.

Message #8 received at 7864 <at> debbugs.gnu.org (full text, mbox):

From: Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de>
To: Eric Blake <eblake <at> redhat.com>, automake-patches <at> gnu.org
Cc: 7864 <at> debbugs.gnu.org
Subject: Re: bug#7864: odd configure bug with dependency checking and
	conditional C++ support
Date: Wed, 19 Jan 2011 19:13:31 +0100
[ adding automake-patches, dropping bug-gnulib ]

Hi Eric,

thanks for the report!

* Eric Blake wrote on Wed, Jan 19, 2011 at 05:52:08AM CET:
> checking dependency style of :... mkdir: cannot create directory
> `conftest.dir': File or Directory already exists
> cp: accessing `conftest.dir': Bad data
> ./configure: line 28036: cd: conftest.dir: Not a directory
> ./configure: line 28047: ./depcomp: No such file or directory
> none

> First - should autoconf's m4/depend.m4 be changed to use mkdir -p
> instead of mkdir, when creating conftest.dir?

No, that won't help if it is a file, not a directory.

> Should it be taught that
> if CXX is :, that the dependency check should be skipped?

Maybe, but that is irrelevant for the actual bug AFAICS.

> Also, should
> it be made more robust to cd failure, so that it does not leave the rest
> of the configure running in an unknown temporary sub-directory?

This is all that should be needed in Automake.  I'll be pushing this to
maint in a little bit.

Cheers,
Ralf

    Allow _AM_DEPENDENCIES to be used later in configure.
    
    * m4/depend.m4 (_AM_DEPENDENCIES): Remove a previously existing
    conftest.dir before recreating it.
    Fixes bug#7864.
    Report by Eric Blake, from report by Scott McCreary against M4.

diff --git a/m4/depend.m4 b/m4/depend.m4
index 714bc9c..a5726c6 100644
--- a/m4/depend.m4
+++ b/m4/depend.m4
@@ -1,12 +1,12 @@
 ##                                                          -*- Autoconf -*-
 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009,
-# 2010  Free Software Foundation, Inc.
+# 2010, 2011 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 12
+# serial 13
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -46,6 +46,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # instance it was reported that on HP-UX the gcc test will end up
   # making a dummy file named `D' -- because `-MD' means `put the output
   # in D'.
+  rm -rf conftest.dir
   mkdir conftest.dir
   # Copy depcomp to subdir because otherwise we won't find it if we're
   # using a relative directory.





Reply sent to Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de>:
You have taken responsibility. (Wed, 19 Jan 2011 19:03:02 GMT) Full text and rfc822 format available.

Notification sent to Eric Blake <eblake <at> redhat.com>:
bug acknowledged by developer. (Wed, 19 Jan 2011 19:03:02 GMT) Full text and rfc822 format available.

Message #13 received at 7864-done <at> debbugs.gnu.org (full text, mbox):

From: Ralf Wildenhues <Ralf.Wildenhues <at> gmx.de>
To: Eric Blake <eblake <at> redhat.com>, 7864-done <at> debbugs.gnu.org
Subject: Re: bug#7864: odd configure bug with dependency checking and
	conditional C++ support
Date: Wed, 19 Jan 2011 20:10:05 +0100
Fixed by v1.11-293-gd652a1c.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 17 Feb 2011 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 128 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.