Well, that's an unexpected bit of pleasant news.

Thanks for letting me know, and for the tips on gettimeofday.

> -----Original Message-----
> From: Rainer Orth <r...@cebitec.uni-bielefeld.de>
> Sent: Thursday, June 12, 2025 08:48
> To: Robert Dubner <rdub...@symas.com>
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [committed] cobol: Eliminate unguarded clock_gettime
> dependencies. [PR119975]
>
> Hi Robert,
>
> > Subject: [PATCH] cobol: Eliminate unguarded clock_gettime dependencies.
> >  [PR119975]
> >
> > These changes are help make it possible to compile on MacOS.  In
>
> it's not macOS in general, just older versions: clock_gettime is
> available in macOS 11 and up (maybe earlier), but missing in (at least)
> 10.7 and 10.11.
>
> > addition to guarding clock_settime() calls, it removes the use
> > of structures and constants needed for clock_settime().
>
> I've just run a COBOL-only bootstrap on Darwin 15 (Mac OS X 10.11) which
> lacks clock_gettime.  The build went fine and cobol results are
> reasonable:
>
>                 === cobol Summary ===
>
> # of expected passes            5271
> # of unexpected failures        92
> # of expected failures          54
> # of unresolved testcases       91
>
> All remaining failures are like
>
> FAIL: cobol.dg/group1/declarative_1.cob   -O0  (test for excess errors)
> Excess errors:
> /vol/gcc/src/hg/master/darwin/gcc/testsuite/cobol.dg/group1/declarative_1.
> cob:51:22: sorry, unimplemented: SECTION segment '�~Oúíþ^G' is not ISO
> syntax
>
> UNRESOLVED: cobol.dg/group1/declarative_1.cob   -O0  compilation failed to
> produce executable
>
> My builds are run with LANG=C LC_CTYPE=en_US.UTF-8; that may be related.
>
> > diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc
> > index f8697afd59c..81b5b7af812 100644
> > --- a/libgcobol/libgcobol.cc
> > +++ b/libgcobol/libgcobol.cc
> [...]
> > -uint64_t
> > -get_time_nanoseconds()
> > +// For testing purposes, this undef causes the use of gettimeofday().
> > +// #undef HAVE_CLOCK_GETTIME
>
> No need to do this in the sources proper: if you want to test such a
> configuration, you can adjust .../libgcobol/config.h after
> configuration.
>
> > +static uint64_t
> > +get_time_nanoseconds_local()
> >  {
> >    // This code was unabashedly stolen from gcc/timevar.cc.
> >    // It returns the Unix epoch with nine decimal places.
> >
> > +  /*  Note:  I am perplexed.  I have been examining the gcc Makefiles
> and
> > +      configure.ac files, and I am unable to locate where
> > HAVE_GETTIMEOFDAY
> > +      is established.  There have been issues compiling on MacOS, where
> > +      apparently clock_gettime() is not available.  But I don't see
> > exactly
> > +      how gettimeofday() gets used, instead.  But without the ability
> to
> > +      compile on a MacOS system, I am fumbling along as best I can.
> > +
> > +      I decided to simply replace clock_gettime() with getttimeofday()
> > when
> > +      clock_gettime() isn't available, even though gcc/timevar.cc
> handles
> > +      the situation differently.
> > +
> > +           -- Bob Dubner, 2025-06-11*/
>
> The issue is that gettimeofday availability is never tested for.  You
> need something like
>
> AC_CHECK_FUNCS_ONCE(gettimeofday)
>
> in libgcobol/configure.ac, then run autoconf; autoheader to regenerate
> configure and config.h.in.
>
> gcc/configure.ac has this as
>
> AC_CHECK_FUNCS(...
>       gettimeofday
>         ...)
>
> After that, you can use
>
> #ifdef HAVE_CLOCK_GETTIME
>   <use clock_gettime>
> #elif HAVE_GETTIMEOFDAY
>   <use gettimeofday>
> #else
> #error ...
> #endif
>
>       Rainer
>
> --
> --------------------------------------------------------------------------
> ---
> Rainer Orth, Center for Biotechnology, Bielefeld University

Reply via email to