https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119975
--- Comment #7 from Robert Dubner <rdubner at gcc dot gnu.org> --- (In reply to [email protected] from comment #6) > > commit r16-1193-g2e334900f4ddcd804e3b324402544a572d306ab6 > > Author: Robert Dubner <[email protected]> > > Date: Thu Jun 5 10:53:02 2025 -0400 > > > > cobol: Guard clock_gettime(). [PR119975] > > > > This attempts to eliminate "'clock_gettime' not declared..." when > > building on x86_64-apple-darwin15.6.0. Calls to clock_gettime have been > > reduced to two locations. Both have been guarded with > > This patch allowed cobol1 to build on Darwin 15 now, thanks. > > However, libgcobol still doesn't build: > > In file included from /vol/gcc/src/hg/master/darwin/libgcobol/gfileio.cc:53: > /vol/gcc/src/hg/master/darwin/libgcobol/libgcobol.h:115:17: error: variable > or field '__gg__clock_gettime' declared void > 115 | extern "C" void __gg__clock_gettime(clockid_t clk_id, struct > cbl_timespec *tp); > | ^~~~~~~~~~~~~~~~~~~ > /vol/gcc/src/hg/master/darwin/libgcobol/libgcobol.h:115:37: error: > 'clockid_t' was not declared in this scope; did you mean 'clock_t'? > 115 | extern "C" void __gg__clock_gettime(clockid_t clk_id, struct > cbl_timespec *tp); > | ^~~~~~~~~ > | clock_t > Since I have no way of trying to compile this code on that machine, this is a little like trying to repair a clock in the dark while wearing oven mitts. It grows frustrating. I did try to do a test for the existence of clock_gettime in libgcobol/configure.ac. That test is # Copied from gcc/configure.ac. 2025-06-05 R.J.Dubner # At least for glibc, clock_gettime is in librt. But don't pull that # in if it still doesn't give us the function we want. ac_cv_func_clock_gettime=no if test $ac_cv_func_clock_gettime = no; then AC_CHECK_LIB(rt, clock_gettime, [LIBS="-lrt $LIBS" AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define to 1 if you have the `clock_gettime' function.])]) fi and it apparently is coming back with HAVE_CLOCK_GETTIME=1, because of the errors you are seeing. But, equally apparently, it *shouldn't* be. I need help. Or somebody who knows what they are doing needs to make the change. For the MacOS environment, I need to know what function I should be calling (gettimeofday()?), and I need to know a valid way to figure out that clock_gettime is actually not available when it isn't. > There's no clockid_t without clock_gettime. Besides, there are several > instances of > > /vol/gcc/src/hg/master/darwin/libgcobol/intrinsic.cc: In function 'void > __gg__current_date(cblc_field_t*)': > /vol/gcc/src/hg/master/darwin/libgcobol/intrinsic.cc:1222:23: error: > 'CLOCK_REALTIME' was not declared in this scope > 1222 | __gg__clock_gettime(CLOCK_REALTIME, &tp); // time_t tv_sec; long > tv_nsec > | ^~~~~~~~~~~~~~ > > which cannot work either. And there's also an unguarded call to > clock_gettime in __gg__clock_gettime. Well, that's just embarrassing. If you look at the code in __gg__clock_gettime, you'll see that I remove the need to call clock_gettime, but I neglected to delete the call.
