Bug 12100 - [3.4 Regression] time.h:402: error: previous declaration of `clock'evious declaration of `clock'
Summary: [3.4 Regression] time.h:402: error: previous declaration of `clock'evious dec...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 3.4.0
: P2 critical
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2003-08-29 00:44 UTC by John David Anglin
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host: hppa2.0w-hp-hpux11.11
Target: hppa2.0w-hp-hpux11.11
Build: hppa2.0w-hp-hpux11.11
Known to work:
Known to fail:
Last reconfirmed: 2003-08-29 13:20:11


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2003-08-29 00:44:20 UTC
The following bootstrap error occurs building libiberty:

if [ x"-fPIC" != x ]; then \
  gcc -c -DHAVE_CONFIG_H -g -O2 -I. -I../../gcc/libiberty/../include  -W -Wall -
Wtraditional -pedantic -fPIC ../../gcc/libiberty/clock.c -o pic/clock.o; \
else true; fi
../../gcc/libiberty/clock.c:71: error: conflicting types for `clock'
/opt/gnu/lib/gcc-lib/hppa2.0w-hp-hpux11.11/3.3/include/sys/time.h:402: error: pr
evious declaration of `clock'

We didn't used to compile clock.o under hpux.  We are knwo trying to build it
because the configure test fails:

configure:4628: checking for clock
configure:4683: gcc -o conftest -g -O2   conftest.c  >&5
configure:4701: error: conflicting types for `clock'
/opt/gnu/lib/gcc-lib/hppa2.0w-hp-hpux11.11/3.3/include/sys/time.h:402: error: 
previous declaration of `clock'
configure:4686: $? = 1
configure: failed program was:
| #line 4638 "configure"
| /* confdefs.h.  */
|
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define WORDS_BIGENDIAN 1
| #define HOST_WORDS_BIG_ENDIAN 1
| #define BYTEORDER 4321
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYS_FILE_H 1
| #define HAVE_SYS_PARAM_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_MALLOC_H 1
| #define HAVE_STRING_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_TIME_H 1
| #define HAVE_SYS_RESOURCE_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_MMAN_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_ALLOCA_H 1
| #define HAVE_SYS_PSTAT_H 1
| #define HAVE_SYS_SYSINFO_H 1
| #define HAVE_SYS_WAIT_H 1
| #define TIME_WITH_SYS_TIME 1
| #define HAVE_UINTPTR_T 1
| #define HAVE_ATEXIT 1
| #define HAVE_BASENAME 1
| #define HAVE_BCMP 1
| #define HAVE_BCOPY 1
| #define HAVE_BSEARCH 1
| #define HAVE_BZERO 1
| #define HAVE_CALLOC 1
| /* end confdefs.h.  */
| /* System header to define __stub macros and hopefully few prototypes,
|     which can conflict with char clock (); 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"
| {
| #endif
| /* We use char because int might match the return type of a gcc2
|    builtin and then its argument prototype would still apply.  */
| char clock ();
| /* The GNU C library defines this for functions which it implements
|     to always fail with ENOSYS.  Some functions are actually named
|     something starting with __ and the normal name is an alias.  */
| #if defined (__stub_clock) || defined (__stub___clock)
| choke me
| #else
| char (*f) () = clock;
| #endif
| #ifdef __cplusplus
| }
| #endif
|
| int
| main ()
| {
| return f != clock;
|   ;
|   return 0;
| }

sys/time.h is included by limits.h when _HPUX_SOURCE is defined.

I believe that this problem was introduced by the following change:

2003-08-27  Daniel Jacobowitz  <drow@mvista.com>

        * aclocal.m4: Include acx.m4 and no-executables.m4.
        (libiberty_AC_FUNC_STRNCMP): Use AC_LIBOBJ.
        (LIB_AC_PROG_CC): Remove.
        * configure.in: Update AC_PREREQ to 2.57.  Use GCC_NO_EXECUTABLES.
        Use AC_PROG_CC and set ac_libiberty_warn_cflags instead of using
        LIB_AC_PROG_CC.  Use AC_LIBOBJ.  Call AC_ISC_POSIX later, only if
        performing link tests.
        * configure: Regenerated.
Comment 1 Daniel Jacobowitz 2003-08-29 00:55:46 UTC
Subject: Re:  New: time.h:402: error: previous declaration of `clock'evious declaration of `clock'

On Fri, Aug 29, 2003 at 12:44:25AM -0000, danglin at gcc dot gnu dot org wrote:
> | /* System header to define __stub macros and hopefully few prototypes,
> |     which can conflict with char clock (); 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

> sys/time.h is included by limits.h when _HPUX_SOURCE is defined.

Blast.  I guess this is a bug in autoconf; you may wish to report it to
the autoconf developers.

In the meantime, it should be possible to avoid this by writing our own
test for clock (and any other affected functions) which does not
include <limits.h> if _HPUX_SOURCE is defined.  It looks like that's
only for the __stub macros, which are a glibcism anyway.  Or you could
copy/paste the definition of AC_LANG_FUNC_LINK_TRY(C) from c.m4 into
libiberty/aclocal.m4 and fix it there.  I just verified that that will
generate appropriate checks.

Comment 2 Andrew Pinski 2003-08-29 13:20:10 UTC
Most likely an autoconf bug.
Comment 3 GCC Commits 2003-09-02 23:29:12 UTC
Subject: Bug 12100

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dj@gcc.gnu.org	2003-09-02 23:29:10

Modified files:
	libiberty      : ChangeLog aclocal.m4 configure 

Log message:
	2003-08-29  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
	PR bootstrap/12100
	* aclocal.m4 (AC_LANG_FUNC_LINK_TRY): Define.
	* configure: Rebuilt.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libiberty/ChangeLog.diff?cvsroot=gcc&r1=1.455&r2=1.456
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libiberty/aclocal.m4.diff?cvsroot=gcc&r1=1.8&r2=1.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libiberty/configure.diff?cvsroot=gcc&r1=1.71&r2=1.72

Comment 4 Nathanael C. Nerode 2003-11-01 00:04:53 UTC
Dave, you appear to have committed a patch which should have fixed this; did it
in fact fix it?  (If so, this bug can be closed, although pushing the fix upstream
is always nice.)
Comment 5 Daniel Jacobowitz 2003-11-01 00:56:48 UTC
Subject: Re:  [3.4 Regression] time.h:402: error: previous declaration of `clock'evious declaration of `clock'

I believe that Dave's patch did fix it; also, autoconf 2.57a and later
include a fix.  2.57g was just released; I intend to test GCC with it
"sometime soon" (whatever that means).
Comment 6 John David Anglin 2003-11-01 00:58:08 UTC
I thought that I pushed this upstream but I'm not entirely sure.  The problem
occurred when the system that I normally use for email was down due to a power
supply failure.