autoconf-patches
[Top][All Lists]
Advanced

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

Fix AC_FUNC_ERROR_AT_LINE and others (was: megatest fallout)


From: Ralf Wildenhues
Subject: Fix AC_FUNC_ERROR_AT_LINE and others (was: megatest fallout)
Date: Tue, 26 Sep 2006 20:42:52 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Hello,

* quoting myself on bug-gnulib:
> 
> (a) comparing (0) and (1):
> error.o in LIBOBJS only in (0); will be fixed in Autoconf's
> AC_FUNC_ERROR_AT_LINE.

Without error.h, `gcc -Wall -Werror -fno-builtin' dislikes the missing
declaration of error_at_line; with it, it dislikes the empty format
string in the 6th argument.  The first part of the patch below fixes
both.

The only thing that makes me worry is the conflicting declaration of a
function pointer error_at_line in /usr/include/gettext-po.h.

I went and checked all of the Autoconf testsuite for more problematic
macros:

- AC_FUNC_WAIT3 fails to include sys/wait.h on my system; do we need a
  test for this header, should this macro rather not be fixed at all, or
  ok as below?

- strnlen is declared on my system only with _GNU_SOURCE, should this
  use AC_USE_SYSTEM_EXTENSIONS rather than AC_GNU_SOURCE as below?

- I admit that the fseeko patch is pretty weak, but I don't know much
  better; it will probably break again with the next GCC version.


Remaining issues not fixed with the patch below:

- AC_C_CONST suffers from issues, but I'm too afraid to break the old
  tests, even if they do invoke undefined behavior:

| conftest.c: In function 'main':
| conftest.c:37: warning: 't' is used uninitialized in this function
| conftest.c:53: warning: 'b' is used uninitialized in this function
| conftest.c:59: warning: 'cs[0]' is used uninitialized in this function

- as does AC_FUNC_OBSTACK (on my system obstack_alloc is a macro that
  may invoke obstack_chunk_alloc; the latter is not declared anywhere):

| configure:2653: checking for obstacks
| configure:2681: gcc-4.1 -Wall -Werror -fno-builtin -o conftest -g -O2   
conftest.c  >&5
| conftest.c: In function 'main':
| conftest.c:13: error: 'obstack_chunk_alloc' undeclared (first use in this 
function)
| conftest.c:13: error: (Each undeclared identifier is reported only once
| conftest.c:13: error: for each function it appears in.)
| conftest.c:13: error: 'obstack_chunk_free' undeclared (first use in this 
function)
| configure:2687: $? = 1


OK to apply?

Cheers,
Ralf
        * lib/autoconf/functions.m4 (AC_FUNC_ERROR_AT_LINE): Check for
        `error.h', and include it, for a `error_at_line' prototype.
        Use a nonempty format string in the link test.
        (AC_FUNC_FSEEKO): Avoid gcc -Wall warnings about constant
        expressions.
        (AC_FUNC_STRNLEN): Require AC_GNU_SOURCE.
        (AC_FUNC_WAIT3): Include <sys/wait.h>, for a declaration of
        wait3.

Index: lib/autoconf/functions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.110
diff -u -r1.110 functions.m4
--- lib/autoconf/functions.m4   25 Sep 2006 17:50:06 -0000      1.110
+++ lib/autoconf/functions.m4   26 Sep 2006 18:39:33 -0000
@@ -470,10 +470,14 @@
 AN_FUNCTION([error],         [AC_FUNC_ERROR_AT_LINE])
 AN_FUNCTION([error_at_line], [AC_FUNC_ERROR_AT_LINE])
 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
-[AC_LIBSOURCES([error.h, error.c])dnl
+[AC_CHECK_HEADERS_ONCE(error.h)
+AC_LIBSOURCES([error.h, error.c])dnl
 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
-                                [error_at_line (0, 0, "", 0, "");])],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
+                                 #ifdef HAVE_ERROR_H
+                                 # include <error.h>
+                                 #endif],
+                                [error_at_line (0, 0, "", 0, "an error 
occurred");])],
                [ac_cv_lib_error_at_line=yes],
                [ac_cv_lib_error_at_line=no])])
 if test $ac_cv_lib_error_at_line = no; then
@@ -589,14 +593,16 @@
 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
    [ac_cv_sys_largefile_source],
    [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
-   address@hidden:@include <stdio.h>], [return !fseeko;])
+   address@hidden:@include <stdio.h>], [typedef int (*fp) ();
+                            fp p = (fp) fseeko;
+                            return !p;])
 
 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
 # in glibc 2.1.3, but that breaks too many other things.
 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
 AC_CACHE_CHECK([for fseeko], [ac_cv_func_fseeko],
 [AC_LINK_IFELSE([AC_LANG_PROGRAM(address@hidden:@include <stdio.h>],
-                                [[return fseeko && fseeko (stdin, 0, 0);]])],
+                                [[return fseeko (stdin, 0, 0);]])],
                [ac_cv_func_fseeko=yes],
                [ac_cv_func_fseeko=no])])
 if test $ac_cv_func_fseeko = yes; then
@@ -1653,7 +1659,8 @@
 # ---------------
 AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
 AC_DEFUN([AC_FUNC_STRNLEN],
-[AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
+[AC_REQUIRE([AC_GNU_SOURCE])dnl
+AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
 #define S "foobar"
 #define S_LEN (sizeof S - 1)
@@ -1998,6 +2005,7 @@
 [AC_INCLUDES_DEFAULT[
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <sys/wait.h>
 /* HP-UX has wait3 but does not fill in rusage at all.  */
 int
 main ()




reply via email to

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