* Stepan Kasal wrote on Sat, May 20, 2006 at 04:08:38PM CEST:
> > Ralf Wildenhues <[EMAIL PROTECTED]> writes:
> >
> > > I'm still wondering whether we should just simply revert both patches,
>
> I have talked with Ralf by phone, and I agree with him that backing
> out my cleanup (plus later fixes to it) and replacing it by a couple
> of straightforward fixes for the known issues is the most safe
> option.
...and here's a hopefully-complete writeup of that:
Stepan's patch[1] addressed some issues:
- The computation of the executable suffix (EXEEXT/ac_cv_exeext) was not
properly overridable by the user. This is a real problem when you
want to get a package to work with a compiler Autoconf doesn't know
about[2,3].
OTOH, the old semantics were implemented for a reason:
# Be careful to initialize this variable, since it used to be cached.
# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
- Removed some outdated comment about a connection to Libtool, that was
also questioning whether Libtool is maintained (which is outdated, too :)
- Some typo fixes.
- The macros needed some cleanup. This can safely be postponed to some
time early in a release cycle.
Unfortunately, the patch introduced regressions:
- The typo Eric found and was fixed a couple of days later (in the same
thread).
- The issue that prompted this thread, namely:
It does not suffice to look for a compiler extension with
$CC -o conftest conftest.$ac_ext
Why? For example, on Cygwin or MinGW, the compiler will create the
file "conftest.exe". There, we will be fine: we do make sure to not
get fooled by the Cygwin file testing "features". But with a
cross-compiler GNU/Linux -> MinGW the above line will simply create
the file "conftest". This isn't what we want though: the executable
should be transferable to a MinGW system without renaming. So, we
have to also make use of what the compiler creates by default, with
$CC conftest.$ac_ext
which will be a.exe.
So, I propose to undo Stepan's and Eric's patch (see first attachment),
fix the comment and the typos, address the old caching semantics in a
new comment, and fix the caching issue. I also propose to document the
overridability now (though I'm not sure whether that is ok), all in the
second attachment.
What do you think?
Cheers,
Ralf
[1] http://lists.gnu.org/archive/html/autoconf-patches/2006-04/msg00027.html
[2] http://lists.gnu.org/archive/html/autoconf/2006-05/msg00071.html
[3] http://lists.gnu.org/archive/html/autoconf/2005-11/msg00033.html
2006-05-22 Ralf Wildenhues <[EMAIL PROTECTED]>
Revert these two patches:
2006-04-06 Eric Blake <[EMAIL PROTECTED]>
* lib/autoconf/lang.m4 (_AC_COMPILER_EXEEXT_O): Inside cache
check, s/ac_exeext/ac_cv_exeext/. Fixes regression introduced
2006-04-01.
2006-04-01 Stepan Kasal <[EMAIL PROTECTED]>
Clean up _AC_COMPILER_EXEEXT* macros.
* lib/autoconf/lang.m4 (_AC_COMPILER_EXEEXT_DEFAULT): Don't try to
detect exeext, it will be done by _AC_COMPILER_EXEEXT_O; just set
ac_file to the name of the default output file and call
_AC_COMPILER_EXEEXT_WORKS. Move the definition of ac_files and the
initial `rm' of the candidate files...
(_AC_COMPILER_EXEEXT): ... here and simplify them. Moreover, use
the same list in subsequent `rm' calls, and for the temporary
redefinition of ac_clean_files; call _AC_COMPILER_OBJEXT at the end,
and don't call the other _AC_COMPILER_EXEEXT_* macros directly, use...
(_AC_COMPILER_EXEEXT_TESTS): ... this new macro.
(_AC_COMPILER_EXEEXT_O): Don't export ac_cv_exeext, it's not needed (or
no longer needed) by libtool. Make it a cache check.
(_AC_COMPILER_EXEEXT_CROSS): Remove the comment, it was obviously
copied here by mistake.
(AC_NO_EXECUTABLES): Redefine _AC_COMPILER_EXEEXT_TESTS, not
_AC_COMPILER_EXEEXT.
* lib/autoconf/c.m4 (AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC): Do not call
_AC_COMPILER_OBJEXT directly.
* lib/autoconf/fortran.m4 (_AC_PROG_FC): Likewise.
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.226
diff -u -r1.226 c.m4
--- lib/autoconf/c.m4 20 May 2006 15:49:27 -0000 1.226
+++ lib/autoconf/c.m4 22 May 2006 18:32:47 -0000
@@ -548,6 +548,7 @@
_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
_AC_LANG_COMPILER_GNU
GCC=`test $ac_compiler_gnu = yes && echo yes`
_AC_PROG_CC_G
@@ -775,6 +776,7 @@
_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
_AC_LANG_COMPILER_GNU
GXX=`test $ac_compiler_gnu = yes && echo yes`
_AC_PROG_CXX_G
@@ -937,6 +939,7 @@
_AC_EVAL([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
_AC_LANG_COMPILER_GNU
GOBJC=`test $ac_compiler_gnu = yes && echo yes`
_AC_PROG_OBJC_G
Index: lib/autoconf/fortran.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/fortran.m4,v
retrieving revision 1.207
diff -u -r1.207 fortran.m4
--- lib/autoconf/fortran.m4 20 May 2006 05:39:03 -0000 1.207
+++ lib/autoconf/fortran.m4 22 May 2006 18:32:47 -0000
@@ -370,6 +370,7 @@
rm -f a.out
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
# If we don't use `.F' as extension, the preprocessor is not run on the
# input file. (Note that this only needs to work for GNU compilers.)
ac_save_ext=$ac_ext
Index: lib/autoconf/lang.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/lang.m4,v
retrieving revision 1.180
diff -u -r1.180 lang.m4
--- lib/autoconf/lang.m4 6 Apr 2006 18:34:24 -0000 1.180
+++ lib/autoconf/lang.m4 22 May 2006 18:32:47 -0000
@@ -378,10 +378,11 @@
AC_BEFORE([$0], [_AC_COMPILER_EXEEXT])
AC_BEFORE([$0], [AC_LINK_IFELSE])
-m4_define([_AC_COMPILER_EXEEXT_TESTS],
-[if AC_TRY_EVAL(ac_link); then
+m4_define([_AC_COMPILER_EXEEXT],
+[AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
+if AC_TRY_EVAL(ac_link); then
ac_no_link=no
- ]m4_defn([_AC_COMPILER_EXEEXT_TESTS])[
+ ]m4_defn([_AC_COMPILER_EXEEXT])[
else
ac_no_link=yes
# Setting cross_compile will disable run tests; it will
@@ -474,32 +475,61 @@
# of exeext.
AC_MSG_CHECKING([for _AC_LANG compiler default output file name])
ac_link_default=`echo "$ac_link" | sed ['s/ -o *conftest[^ ]*//']`
+#
+# List of possible output files, starting from the most likely.
+# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
+# only as a last resort. b.out is created by i960 compilers.
+ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
+#
+# The IRIX 6 linker writes into existing files which may not be
+# executable, retaining their permissions. Remove them first so a
+# subsequent execution test works.
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ _AC_COMPILER_EXEEXT_REJECT ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
AS_IF([AC_TRY_EVAL(ac_link_default)],
-[for ac_file in $ac_outfiles a.* conftest.* NO
+[# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+for ac_file in $ac_files
do
test -f "$ac_file" || continue
case $ac_file in
- _AC_COMPILER_EXEEXT_REJECT ) ;;
- * ) break;;
+ _AC_COMPILER_EXEEXT_REJECT )
+ ;;
+ [[ab]].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
esac
-done
-AS_IF([test "$ac_file" = NO], [AC_MSG_FAILURE([no output file found])])
-],
+done],
[_AC_MSG_LOG_CONFTEST
AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)])
+ac_exeext=$ac_cv_exeext
AC_MSG_RESULT([$ac_file])
-_AC_COMPILER_EXEEXT_WORKS
-# Clean up; list also $ac_file, in case it matched a wildcard entry.
-rm -f $ac_outfiles $ac_file
])# _AC_COMPILER_EXEEXT_DEFAULT
# _AC_COMPILER_EXEEXT_WORKS
# -------------------------
-# Called from _AC_COMPILER_EXEEXT_DEFAULT.
m4_define([_AC_COMPILER_EXEEXT_WORKS],
-[# Check that the compiler produces executables we can run. If not, either
+[# Check the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
AC_MSG_CHECKING([whether the _AC_LANG compiler works])
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
@@ -523,53 +553,40 @@
# _AC_COMPILER_EXEEXT_CROSS
# -------------------------
m4_define([_AC_COMPILER_EXEEXT_CROSS],
-[AC_MSG_CHECKING([whether we are cross compiling])
+[# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+AC_MSG_CHECKING([whether we are cross compiling])
AC_MSG_RESULT([$cross_compiling])
])# _AC_COMPILER_EXEEXT_CROSS
# _AC_COMPILER_EXEEXT_O
# ---------------------
-# Check for the extension used when `-o foo'. Compute ac_cv_exeext.
-#
+# Check for the extension used when `-o foo'. Try to see if ac_cv_exeext,
+# as computed by _AC_COMPILER_EXEEXT_DEFAULT is OK.
m4_define([_AC_COMPILER_EXEEXT_O],
-[AC_CACHE_CHECK([for suffix of executables], ac_cv_exeext,
- [AS_IF([AC_TRY_EVAL(ac_link)],
- [# If both `conftest.exe' and `conftest' are `present' (well, observable),
- # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
- # work properly (i.e., refer to `conftest.exe'), while it won't with `rm'.
- for ac_file in conftest.exe conftest conftest.* NO; do
- test -f "$ac_file" || continue
- case $ac_file in
- _AC_COMPILER_EXEEXT_REJECT ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
- break;;
- * ) break;;
- esac
- done
- AS_IF([test "$ac_file" = NO],
- [AC_MSG_FAILURE([cannot compute suffix of executables: no output file
found])])
- # Clean up; list also $ac_file, in case it matched conftest.*.
- rm -f $ac_outfiles $ac_file
- ],
- [AC_MSG_FAILURE([cannot compute suffix of executables: cannot compile and
link])
- ])
- ])
-AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
-ac_exeext=$EXEEXT
+[AC_MSG_CHECKING([for suffix of executables])
+AS_IF([AC_TRY_EVAL(ac_link)],
+[# If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ _AC_COMPILER_EXEEXT_REJECT ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done],
+ [AC_MSG_FAILURE([cannot compute suffix of executables: cannot
compile and link])])
+rm -f conftest$ac_cv_exeext
+AC_MSG_RESULT([$ac_cv_exeext])
])# _AC_COMPILER_EXEEXT_O
-# _AC_COMPILER_EXEEXT_TESTS
-# -------------------------
-# Calls all of the above _AC_COMPILER_EXEEXT_* tests.
-# This macro is modified by the AC_NO_EXECUTABLES hack.
-m4_define([_AC_COMPILER_EXEEXT_TESTS],
-[_AC_COMPILER_EXEEXT_DEFAULT
-_AC_COMPILER_EXEEXT_CROSS
-_AC_COMPILER_EXEEXT_O])
-
-
# _AC_COMPILER_EXEEXT
# -------------------
# Check for the extension used for executables. It compiles a test
@@ -583,33 +600,18 @@
# Must be run before _AC_COMPILER_OBJEXT because _AC_COMPILER_EXEEXT_DEFAULT
# checks whether the compiler works.
m4_define([_AC_COMPILER_EXEEXT],
-[
-# List of possible output files. We want to start from the most likely,
-# but we have to check foo.exe before foo, because Cygwin `test -f' looks
-# also for foo.exe. b.out is created by i960 compilers.
-# As a last resort, we also try wildcards: `conftest.*' and `a.*'.
-# But we are not allowed to rm a.*, and we do not want always remove
-# conftest.*, so we will list them literally, when appropriate.
-ac_outfiles="a_out.exe a.out conftest.exe conftest a.exe b.out"
-
-# The IRIX 6 linker writes into existing files which may not be
-# executable, retaining their permissions. Remove them first so a
-# subsequent execution test works.
-rm -f $ac_outfiles conftest.*
-
-AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
-
+[AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $ac_outfiles"
-
-# The following tests should remove their output except files matching
conftest.*.
-_AC_COMPILER_EXEEXT_TESTS
-
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+_AC_COMPILER_EXEEXT_DEFAULT
+_AC_COMPILER_EXEEXT_WORKS
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
-
-_AC_COMPILER_OBJEXT
-
-rm -f conftest.*
+_AC_COMPILER_EXEEXT_CROSS
+_AC_COMPILER_EXEEXT_O
+rm -f conftest.$ac_ext
+AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
+ac_exeext=$EXEEXT
])# _AC_COMPILER_EXEEXT
@@ -625,7 +627,8 @@
# it includes. So do it by hand.
m4_define([_AC_COMPILER_OBJEXT],
[AC_CACHE_CHECK([for suffix of object files], ac_cv_objext,
-[rm -f conftest.o conftest.obj
+[AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
+rm -f conftest.o conftest.obj
AS_IF([AC_TRY_EVAL(ac_compile)],
[for ac_file in conftest.o conftest.obj conftest.*; do
test -f "$ac_file" || continue;
@@ -636,7 +639,8 @@
esac
done],
[_AC_MSG_LOG_CONFTEST
-AC_MSG_FAILURE([cannot compute suffix of object files: cannot compile])])])
+AC_MSG_FAILURE([cannot compute suffix of object files: cannot compile])])
+rm -f conftest.$ac_cv_objext conftest.$ac_ext])
AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
ac_objext=$OBJEXT
])# _AC_COMPILER_OBJEXT
2006-05-22 Stepan Kasal <[EMAIL PROTECTED]>
and Ralf Wildenhues <[EMAIL PROTECTED]>
* lib/autoconf/lang.m4 (_AC_COMPILER_EXEEXT_DEFAULT): Drop the
initialization of `ac_cv_exeext', do not override it if it was
already set. Add comment about this potential backward
incompatibility. Do not export `ac_cv_exeext', Libtool hasn't
needed this for years.
(_AC_COMPILER_EXEEXT_DEFAULT): Likewise, do not export it.
(_AC_COMPILER_EXEEXT_WORKS, _AC_COMPILER_EXEEXT_CROSS): Typos.
* doc/autoconf.texi (Compilers and Preprocessors) <EXEEXT>:
Document that this test may be overridden by setting
`ac_cv_exeext'.
--- lib/autoconf/lang.m4 2006-05-22 18:35:15.000000000 +0200
+++ lib/autoconf/lang.m4 2006-05-22 18:43:36.000000000 +0200
@@ -495,9 +495,12 @@
rm -f $ac_rmfiles
AS_IF([AC_TRY_EVAL(ac_link_default)],
-[# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
+[# At one point in the past, the ac_cv_exeext variable could contain
+# the value `no'. This would lead to `EXEEXT = no' in a Makefile.
+# If you still have a cache file around with this value, please remove
+# the setting. Because we should not override ac_cv_exeext if it
+# was cached, so that the user can short-circuit this test for
+# compilers unknown to Autoconf.
for ac_file in $ac_files
do
test -f "$ac_file" || continue
@@ -509,11 +512,13 @@
# certainly right.
break;;
*.* )
- ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
- # FIXME: I believe we export ac_cv_exeext for Libtool,
- # but it would be cool to find out if it's true. Does anybody
- # maintain Libtool? --akim.
- export ac_cv_exeext
+ test "${ac_cv_exeext+set}" = set ||
+ ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
break;;
* )
break;;
@@ -529,7 +534,7 @@
# _AC_COMPILER_EXEEXT_WORKS
# -------------------------
m4_define([_AC_COMPILER_EXEEXT_WORKS],
-[# Check the compiler produces executables we can run. If not, either
+[# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
AC_MSG_CHECKING([whether the _AC_LANG compiler works])
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
@@ -553,7 +558,7 @@
# _AC_COMPILER_EXEEXT_CROSS
# -------------------------
m4_define([_AC_COMPILER_EXEEXT_CROSS],
-[# Check the compiler produces executables we can run. If not, either
+[# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
AC_MSG_CHECKING([whether we are cross compiling])
AC_MSG_RESULT([$cross_compiling])
@@ -576,7 +581,6 @@
case $ac_file in
_AC_COMPILER_EXEEXT_REJECT ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
- export ac_cv_exeext
break;;
* ) break;;
esac
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1021
diff -u -r1.1021 autoconf.texi
--- doc/autoconf.texi 22 May 2006 17:27:50 -0000 1.1021
+++ doc/autoconf.texi 22 May 2006 18:41:58 -0000
@@ -5911,7 +5911,9 @@
All the tests for compilers (@code{AC_PROG_CC}, @code{AC_PROG_CXX},
@code{AC_PROG_F77}) define the output variable @code{EXEEXT} based on
the output of the compiler, typically to the empty string if
-Posix and @samp{.exe} if a @acronym{DOS} variant.
+Posix and @samp{.exe} if a @acronym{DOS} variant. It can be overridden
+by passing the argument @[EMAIL PROTECTED] to
[EMAIL PROTECTED]
@ovindex OBJEXT
They also define the output variable @code{OBJEXT} based on the