https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118050
Bug ID: 118050
Summary: [15 Regression] timevar.cc:163:18: error:
'CLOCK_MONOTONIC' was not declared in this scope
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: danglin at gcc dot gnu.org
Target Milestone: ---
Host: hppa64-hp-hpux11.11
Target: hppa64-hp-hpux11.11
Build: hppa64-hp-hpux11.11
g++ -std=c++14 -fno-PIE -c -g -DIN_GCC -fno-exceptions -fno-rtti
-fasynchr
onous-unwind-tables -W -Wall -Wno-error=narrowing -Wwrite-strings -Wcast-qual
-W
no-format -Wmissing-format-attribute -Wconditionally-supported
-Woverloaded-virt
ual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-DHAV
E_CONFIG_H -fno-PIE -I. -I. -I../../gcc/gcc -I../../gcc/gcc/.
-I../../gcc/gcc/..
/include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody
-I/opt/gn
u64/gcc/gmp/include -I../../gcc/gcc/../libdecnumber
-I../../gcc/gcc/../libdecnu
mber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace
-I/opt/gnu64/gcc/gmp/
include -o timevar.o -MT timevar.o -MMD -MP -MF ./.deps/timevar.TPo
../../gcc/g
cc/timevar.cc
../../gcc/gcc/timevar.cc: In function 'void get_time(timevar_time_def*)':
../../gcc/gcc/timevar.cc:163:18: error: 'CLOCK_MONOTONIC' was not declared in
this scope
163 | clock_gettime (CLOCK_MONOTONIC, &ts);
| ^~~~~~~~~~~~~~~
make[3]: *** [Makefile:1208: timevar.o] Error 1
CLOCK_MONOTONIC is not supported. Only CLOCK_REALTIME is supported on
hpux11.11.
This occurs in following code:
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
clock_gettime (CLOCK_MONOTONIC, &ts);
now->wall = ts.tv_sec * 1000000000 + ts.tv_nsec;
return;
#define HAVE_WALL_TIME 1
#endif
I proposed the following:
diff --git a/gcc/timevar.cc b/gcc/timevar.cc
index 48d0c72cbdf..21fd65d2f89 100644
--- a/gcc/timevar.cc
+++ b/gcc/timevar.cc
@@ -160,7 +160,11 @@ get_time (struct timevar_time_def *now)
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
+#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
clock_gettime (CLOCK_MONOTONIC, &ts);
+#else
+ clock_gettime (CLOCK_REALTIME, &ts);
+#endif
now->wall = ts.tv_sec * 1000000000 + ts.tv_nsec;
return;
#define HAVE_WALL_TIME 1
Another possibility is a configure check.