[RFC] libiberty build failure after upgrade to autoconf 2.57

Joel Brobecker brobecker@gnat.com
Wed Sep 3 22:09:00 GMT 2003


Hello,

I noticed that GDB failed trying to build clock.c in libiberty because
the declaration of function "clock" in clock.c was conflicting with
the declaration of "clock" in /usr/include/sys/time.h. Since libiberty
is shared between GDB and GCC, presumably the same failure applies on
GCC as well.

libiberty's idea of clock: long clock ();
HP/UX's idea of clock: clock_t clock();

Since "clock" is provided by the system, it seems that configure has
incorrectly determined that the libiberty version of clock should be
used.

Basically, the sequence of events is the following: 
  - configure tests for "clock"
  - gcc fails to compile the test program because the declaration
    used in the test program conflicts with the one provided by HP/UX.
  - So configure adds clock.c to the list of files to be included
    in libiberty
  - during the libiberty build, we fail while trying to build clock.c
    because of the same definition conflict.

With an older version of autoconf (2.13), the little test application
used to check for each function was slightly different (#included
assert.h instead of now limits.h), and that caused the check for "clock"
to be succesful. This configured libiberty to be built without clock.c.

I'm not really sure how this should be fixed. Should it be fixed in
autoconf for instance? Or should we use a custom test for "clock"
in libiberty/configure.in? Or should we simply use the standard
function check except on HP/UX were we know that "clock" is provided.

I don't know autoconf that much, but it seems that trying to fix this
problem may be a bit hard. So I took the simplest route, which was to
skip the test for "clock" on HP/UX knowing that it's not necessary
there. The downside of this approach is that it slightly increases
the maintenance burden, but I think the increase should remain minimal.
And it doesn't seem that this is the first time we do this sort of
thing.

Does the following patch look correct? Or should the problem be solved
differently?

2003-09-03  J. Brobecker  <brobecker@gnat.com>

        * configure.in: Skip the test for "clock" on HP/UX hosts.
        * configure: Regenerate.

Thanks,
-- 
Joel
-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /cvs/src/src/libiberty/configure.in,v
retrieving revision 1.49
diff -u -p -r1.49 configure.in
--- configure.in	27 Aug 2003 21:15:13 -0000	1.49
+++ configure.in	3 Sep 2003 21:33:36 -0000
@@ -319,6 +319,18 @@ case "${host}" in
     AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
     AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
     ;;
+  hppa*-*-hpux*)
+    # Checking for "clock" with autoconf 2.57 causes autoconf to fail
+    # because the prototype that autoconf uses in its small test program
+    # conflicts with the HP/UX prototype in /usr/inclue/sys/time.h.
+    # So we simply hard-code the fact that "clock" is available on HP/UX.
+    #
+    # The problem did not occur with older versions of autoconf, because
+    # the small program generated by these older versions were using a
+    # different set of includes (autoconf 2.57 prefers limits.h over
+    # assert.h).
+    funcs="`echo $funcs | sed -e 's/clock//'`"
+    ;;
 esac
 
 if test -z "${setobjs}"; then


More information about the Gcc-patches mailing list