Gary V. Vaughan wrote: > Unfortunately, this compiler and the IBM compiler on aix4.3.3 and aix6.1.0 > (but > strangely, not 5.1, 5.2 or 5.3) have another peculiar behaviour which breaks > on > some headers when include_next.m4 determines that #include_next doesn't work. > > $ echo '#include <stdio.h>' > conftest.c > $ xlc -E conftest.c | grep stdio > #line 73 "/usr/include/stdio.h" > int __stdioid; > #line 259 "/usr/include/stdio.h" > #line 374 "/usr/include/stdio.h" > #line 398 "/usr/include/stdio.h" > #line 434 "/usr/include/stdio.h" > $ echo '#include <dirent.h>' > conftest.c > $ xlc -E conftest.c | grep dirent > struct dirent { > extern struct dirent *readdir(DIR *); > extern int readdir_r(DIR *, struct dirent *, struct dirent **); > extern int scandir(const char *, struct dirent ***, > int (*)(struct dirent *), > > It seems that the compiler sometimes forgets the #line directives.
Thanks for the report. It appears that because the header file <dirent.h> contains only comments and preprocessor directives, and no non-comment tokens of its own, AIX xlc "optimizes" some #line directives. The problem is easy to reproduce, also on AIX 5.1, with a testdir created through ./gnulib-tool --create-testdir dirent signal poll dirfd fchdir The scope of the problem could be quite large, since quite some header files contain only comments and #includes. I found quite a long list below. Fortunately, GCC and the system compilers on HP-UX, IRIX, OSF/1, Solaris don't "optimize" the #line directives like this. So only the system compilers on AIX are affected. The fix that I found is to use "xlc -E -C" instead of "xlc -E". It has the effect of turning the config.status lines S["NEXT_SIGNAL_H"]="\"///usr/include/sys/signal.h\"" S["NEXT_DIRENT_H"]="\"\"" into S["NEXT_SIGNAL_H"]="\"///usr/include/signal.h\"" S["NEXT_DIRENT_H"]="\"///usr/include/dirent.h\"" I'm applying the patch below. Bruno ------------------------------------------------------------------------ aix-4.3.2 <ucontext.h> -> <sys/ucontext.h> <dirent.h> -> <sys/dir.h> <signal.h> -> <sys/signal.h> <limits.h> -> <sys/limits.h> <aio.h> -> <sys/aio.h> <stropts.h> -> <sys/stropts.h> <syslog.h> -> <sys/syslog.h> <poll.h> -> <sys/poll.h> aix-5.1.0 <ucontext.h> -> <sys/ucontext.h> <dirent.h> -> <sys/dir.h> <signal.h> -> <sys/signal.h> <stropts.h> -> <sys/stropts.h> <syslog.h> -> <sys/syslog.h> <poll.h> -> <sys/poll.h> beos <stdarg.h> <strings.h> -> <string.h> <wchar.h> -> <wchar_t.h> cygwin <syslog.h> -> <sys/syslog.h> <poll.h> -> <sys/poll.h> <dirent.h> -> <sys/dir.h> <utime.h> -> <sys/utime.h> <termios.h> -> <sys/termios.h> <unistd.h> -> <sys/unistd.h> <strings.h> -> <sys/strings.h> freebsd-6.0 semaphore.h -> posix4/semaphore.h stdarg.h -> machine/stdarg.h float.h -> machine/float.h sched.h -> posix4/sched.h ucontext.h -> sys/ucontext.h termios.h -> sys/termios.h stdint.h -> sys/stdint.h syslog.h -> sys/syslog.h errno.h -> sys/errno.h fcntl.h -> sys/fcntl.h poll.h -> sys/poll.h aio.h -> sys/aio.h glibc <syslog.h> -> <sys/syslog.h> <poll.h> -> <sys/poll.h> hpux unistd.h dirent.h stdarg.h fcntl.h ucontext.h stropts.h termios.h signal.h poll.h semaphore.h mqueue.h sched.h aio.h pthread.h interix stropts.h irix-6.5 poll.h termios.h wctype.h macosx-10.3 fenv.h math.h semaphore.h setjmp.h ucontext.h termios.h syslog.h errno.h fcntl.h mingw strings.h unistd.h stddef.h stdarg.h utime.h netbsd-3.0 stdarg.h -> machine/stdarg.h float.h -> machine/float.h termios.h -> sys/termios.h stdint.h -> sys/stdint.h syslog.h -> sys/syslog.h fcntl.h -> sys/fcntl.h poll.h -> sys/poll.h openbsd-3.8 poll.h float.h -> machine/float.h termios.h -> sys/termios.h stdarg.h -> sys/stdarg.h syslog.h -> sys/syslog.h errno.h -> sys/errno.h fcntl.h -> sys/fcntl.h osf1 fcntl.h poll.h solaris-2.10 poll.h stdint.h termios.h ----------------------------------------------------------------------- 2008-11-03 Bruno Haible <[EMAIL PROTECTED]> Make determination of absolute name of header file work with AIX xlc. * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Require AC_CANONICAL_HOST. On AIX, use "$CPP -C" rather than "$CPP" for preprocessing. * m4/absolute-header.m4 (gl_ABSOLUTE_HEADER): Likewise. Reported by Gary V. Vaughan <[EMAIL PROTECTED]>. *** m4/include_next.m4.orig 2008-11-04 01:48:26.000000000 +0100 --- m4/include_next.m4 2008-11-04 01:41:45.000000000 +0100 *************** *** 1,4 **** ! # include_next.m4 serial 8 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # include_next.m4 serial 9 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 87,92 **** --- 87,93 ---- AC_DEFUN([gl_CHECK_NEXT_HEADERS], [ AC_REQUIRE([gl_INCLUDE_NEXT]) + AC_REQUIRE([AC_CANONICAL_HOST]) AC_CHECK_HEADERS_ONCE([$1]) m4_foreach_w([gl_HEADER_NAME], [$1], *************** *** 105,115 **** [AC_LANG_SOURCE( [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] )]) ! dnl eval is necessary to expand ac_cpp. dnl Ultrix and Pyramid sh refuse to redirect output of eval, dnl so use subshell. AS_VAR_SET([gl_next_header], ! ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# s#^/[^/]#//&# --- 106,127 ---- [AC_LANG_SOURCE( [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] )]) ! dnl AIX "xlc -E" and "cc -E" omit #line directives for header files ! dnl that contain only a #include of other header files and no ! dnl non-comment tokens of their own. This leads to a failure to ! dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h> ! dnl and others. The workaround is to force preservation of comments ! dnl through option -C. This ensures all necessary #line directives ! dnl are present. GCC supports option -C as well. ! case "$host_os" in ! aix*) gl_absname_cpp="$ac_cpp -C" ;; ! *) gl_absname_cpp="$ac_cpp" ;; ! esac ! dnl eval is necessary to expand gl_absname_cpp. dnl Ultrix and Pyramid sh refuse to redirect output of eval, dnl so use subshell. AS_VAR_SET([gl_next_header], ! ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# s#^/[^/]#//&# *** m4/absolute-header.m4.orig 2008-11-04 01:48:26.000000000 +0100 --- m4/absolute-header.m4 2008-11-04 01:43:05.000000000 +0100 *************** *** 1,4 **** ! # absolute-header.m4 serial 9 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # absolute-header.m4 serial 10 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 20,26 **** # preprocessing, i.e. it does not only define preprocessor macros but also # provides some type/enum definitions or function/variable declarations. AC_DEFUN([gl_ABSOLUTE_HEADER], ! [AC_LANG_PREPROC_REQUIRE()dnl m4_foreach_w([gl_HEADER_NAME], [$1], [AS_VAR_PUSHDEF([gl_absolute_header], [gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl --- 20,27 ---- # preprocessing, i.e. it does not only define preprocessor macros but also # provides some type/enum definitions or function/variable declarations. AC_DEFUN([gl_ABSOLUTE_HEADER], ! [AC_REQUIRE([AC_CANONICAL_HOST]) ! AC_LANG_PREPROC_REQUIRE()dnl m4_foreach_w([gl_HEADER_NAME], [$1], [AS_VAR_PUSHDEF([gl_absolute_header], [gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl *************** *** 31,40 **** AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl if test AS_VAR_GET(ac_header_exists) = yes; then AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])]) ! dnl eval is necessary to expand ac_cpp. ! dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell. AS_VAR_SET(gl_absolute_header, ! [`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# s#^/[^/]#//&# --- 32,53 ---- AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl if test AS_VAR_GET(ac_header_exists) = yes; then AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])]) ! dnl AIX "xlc -E" and "cc -E" omit #line directives for header files ! dnl that contain only a #include of other header files and no ! dnl non-comment tokens of their own. This leads to a failure to ! dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h> ! dnl and others. The workaround is to force preservation of comments ! dnl through option -C. This ensures all necessary #line directives ! dnl are present. GCC supports option -C as well. ! case "$host_os" in ! aix*) gl_absname_cpp="$ac_cpp -C" ;; ! *) gl_absname_cpp="$ac_cpp" ;; ! esac ! dnl eval is necessary to expand gl_absname_cpp. ! dnl Ultrix and Pyramid sh refuse to redirect output of eval, ! dnl so use subshell. AS_VAR_SET(gl_absolute_header, ! [`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# s#^/[^/]#//&#