public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Build issues due to patch "gprofng: a new GNU profiler" – CLOCK_MONOTONIC_RAW not defined
@ 2022-03-14 10:57 Tobias Burnus
  2022-03-14 18:16 ` Vladimir Mezentsev
  2022-03-14 20:53 ` Joseph Myers
  0 siblings, 2 replies; 14+ messages in thread
From: Tobias Burnus @ 2022-03-14 10:57 UTC (permalink / raw)
  To: Binutils, Vladimir Mezentsev, Nick Clifton

Hi Vladimir, hi Nick,

Friday's commit "gprofng: a new GNU profiler",
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bb368aad297fe3ad40cf397e6fc85aa471429a28

broke the build here (build server using on purpose an older Linux/glibc):

gprofng/libcollector/gethrtime.c:35:26: error: 'CLOCK_MONOTONIC_RAW' undeclared (first use in this function); did you mean 'CLOCK_MONOTONIC'?
    int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp);
                           ^~~~~~~~~~~~~~~~~~~
                           CLOCK_MONOTONIC

According to https://linux.die.net/man/2/clock_gettime:

   CLOCK_MONOTONIC_RAW (since Linux 2.6.28; Linux-specific)
     Similar to CLOCK_MONOTONIC, but provides access to a raw hardware-based
     time that is not subject to NTP adjustments or the incremental
     adjustments performed by adjtime(3).

Thus, it seems as if either a config check or a much
simpler patch as the following is needed:

--- a/gprofng/libcollector/gethrtime.c
+++ b/gprofng/libcollector/gethrtime.c
@@ -34,3 +34,7 @@ linux_gethrtime ()
    hrtime_t rc = 0;
+#ifdef CLOCK_MONOTONIC_RAW
    int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp);
+#else
+  int r = clock_gettime (CLOCK_MONOTONIC, &tp);
+#endif
    if (r == 0)

--- a/gprofng/src/gethrtime.c
+++ b/gprofng/src/gethrtime.c
@@ -161,3 +161,7 @@ gethrtime (void)
     */
+#ifdef CLOCK_MONOTONIC_RAW
    int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp);
+#else
+  int r = clock_gettime (CLOCK_MONOTONIC, &tp);
+#endif
    if (r == 0)

  * * *

Additionally, the build fails with the link error:
    gprofng/src/gethrtime.c:131: undefined reference to `clock_gettime'

The problem seems to be what the 'clock_gettime(3)' man page states:
        Link with -lrt (only for glibc versions before 2.17).

Please consider as fix to copy the following check from libbacktrace/configure.ac:

# Check for the clock_gettime function.
AC_CHECK_FUNCS(clock_gettime)
...
AC_SUBST(CLOCK_GETTIME_LINK)


Thanks,

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-03-18 15:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 10:57 Build issues due to patch "gprofng: a new GNU profiler" – CLOCK_MONOTONIC_RAW not defined Tobias Burnus
2022-03-14 18:16 ` Vladimir Mezentsev
2022-03-15 15:24   ` Nick Clifton
2022-03-15 16:24     ` Tobias Burnus
2022-03-16 12:29       ` Nick Clifton
2022-03-16 14:55         ` Tobias Burnus
2022-03-18 15:25           ` Tobias Burnus
2022-03-18 15:47             ` Nick Clifton
2022-03-15 16:54     ` Vladimir Mezentsev
2022-03-15 16:59       ` Vladimir Mezentsev
2022-03-16  7:56       ` Tobias Burnus
2022-03-14 20:53 ` Joseph Myers
2022-03-14 21:52   ` Vladimir Mezentsev
2022-03-16 11:30   ` Nick Alcock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).