autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_CHECK_FUNCS always succeeds on AIX with Autoconf 2.56


From: Paul Eggert
Subject: Re: AC_CHECK_FUNCS always succeeds on AIX with Autoconf 2.56
Date: Mon, 2 Dec 2002 23:07:58 -0800 (PST)

Quoted from <http://mail.gnu.org/pipermail/autoconf/2002-November/014508.html>:

> From: Martin Frydl <address@hidden>
> Date: Tue, 19 Nov 2002 13:36:20 +0100
> 
>    I've looked into this problem and created patch. In fact I've only 
> put back the original code while maintaining the current one, i.e. `f' 
> is assigned both in global initialization and also in main().

That seems to be the right approach, but I think it would be better
for 'main' to also use both instances of the function to affect the
exit status, as that will make it less likely for them to be optimized
away.  Also, I'd like to fix the problem with <assert.h> noted by
Momchil Velikov in
<http://mail.gnu.org/pipermail/autoconf/2002-November/014490.html>
So I installed the following patch.

2002-12-02  Paul Eggert  <address@hidden>

        * lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C)): Use the function f
        nontrivially in main's body, so that f's external declaration is
        not optimized away in AIX.  This should fix the bug reported by
        Martin Frydl in
        <http://mail.gnu.org/pipermail/autoconf/2002-November/014508.html>.

        * lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C),
        _AC_PROG_PREPROC_WORKS_IFELSE): Use <limits.h> if __STDC__ is
        defined, to support freestanding compilers.  This should fix the
        bug reported by Momchil Velkov in
        <http://mail.gnu.org/pipermail/autoconf/2002-November/014490.html>.

Index: c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.172
retrieving revision 1.173
diff -p -u -r1.172 -r1.173
--- c.m4        13 Nov 2002 23:34:07 -0000      1.172
+++ c.m4        3 Dec 2002 07:00:37 -0000       1.173
@@ -166,15 +166,25 @@ char $2 ();])], [$2 ();])])
 # <sys/types.h> which includes <sys/select.h> which contains a
 # prototype for select.  Similarly for bzero.
 #
-# This test used to assign f=$1 in main(), but that was optimized away by HP
-# unbundled cc A.05.36 for ia64 under +O3, presumably on the basis that
-# there's no need to do that store if the program is about to exit.
+# This test used to merely assign f=$1 in main(), but that was
+# optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
+# presumably on the basis that there's no need to do that store if the
+# program is about to exit.  Conversely, the AIX linker optimizes an
+# unused external declaration that initializes f=$1.  So this test
+# program has both an external initialization of f, and a use of f in
+# main that affects the exit status.
 #
 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
 [AC_LANG_PROGRAM(
 [/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $1 (); below.  */
-#include <assert.h>
+    which can conflict with char $1 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
 extern "C"
@@ -194,7 +204,7 @@ char (*f) () = $1;
 #ifdef __cplusplus
 }
 #endif
-])])
+], [return f != $1;])])
 
 
 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
@@ -323,9 +333,15 @@ for ac_[]_AC_LANG_ABBREV[]_preproc_warn_
 do
   # Use a header file that comes with gcc, so configuring glibc
   # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
-  _AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@include <assert.h>
+  _AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden:@ifdef __STDC__
address@hidden:@ include <limits.h>
address@hidden:@else
address@hidden:@ include <assert.h>
address@hidden:@endif
                      Syntax error]])],
                      [],
                      [# Broken: fails on valid input.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]