public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>,
	Tobias Burnus <tobias@codesourcery.com>,
	Binutils <binutils@sourceware.org>
Subject: Re: Build issues due to patch "gprofng: a new GNU profiler" – CLOCK_MONOTONIC_RAW not defined
Date: Tue, 15 Mar 2022 15:24:31 +0000	[thread overview]
Message-ID: <14359283-a893-7208-c87d-c42aad214c67@redhat.com> (raw)
In-Reply-To: <b438a8a5-d849-c292-921d-de76b109182e@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

Hi Vladimir, Hi Tobias,

   To save time I have gone ahead and applied a patch myself (attached).
   Please let me know if I missed anything or made a mistake...

Cheers
   Nick

[-- Attachment #2: gprofng.configure-tweaks.patch --]
[-- Type: text/x-patch, Size: 7682 bytes --]

diff --git a/gprofng/common/config.h.in b/gprofng/common/config.h.in
index e46e64f39e3..8409ce74a57 100644
--- a/gprofng/common/config.h.in
+++ b/gprofng/common/config.h.in
@@ -6,6 +6,9 @@
 /* Enable java profiling */
 #undef GPROFNG_JAVA_PROFILING
 
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
 /* Define to 1 if you have the declaration of `basename', and to 0 if you
    don't. */
 #undef HAVE_DECL_BASENAME
diff --git a/gprofng/configure b/gprofng/configure
index 3cf4dc768ce..9a4a334854b 100755
--- a/gprofng/configure
+++ b/gprofng/configure
@@ -16523,12 +16523,13 @@ cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_BASENAME $ac_have_decl
 _ACEOF
 
-for ac_func in strsignal
+for ac_func in clock_gettime strsignal
 do :
-  ac_fn_c_check_func "$LINENO" "strsignal" "ac_cv_func_strsignal"
-if test "x$ac_cv_func_strsignal" = xyes; then :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_STRSIGNAL 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index 8977e8bd4bb..fa924dcee62 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -178,7 +178,7 @@ AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
 AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
 
 AC_CHECK_DECLS([basename])
-AC_CHECK_FUNCS([strsignal])
+AC_CHECK_FUNCS(clock_gettime strsignal)
 
 AC_SUBST(BUILD_SUBDIRS)
 
diff --git a/gprofng/libcollector/Makefile.am b/gprofng/libcollector/Makefile.am
index bd86e97753d..a41b92030e0 100644
--- a/gprofng/libcollector/Makefile.am
+++ b/gprofng/libcollector/Makefile.am
@@ -63,7 +63,7 @@ libgp_collector_la_CPPFLAGS = $(AM_CPPFLAGS) $(jdk_inc) \
 # Prevent libtool from reordering -Wl,--no-as-needed after -lrt by
 # disguising -lrt as a linker flag.
 libgp_collector_la_LDFLAGS = $(AM_LDFLAGS)
-libgp_collector_la_LIBADD =
+libgp_collector_la_LIBADD = $(CLOCK_GETTIME_LINK)
 
 libgp_heap_la_SOURCES = heaptrace.c
 libgp_heap_la_LDFLAGS = $(AM_LDFLAGS)
diff --git a/gprofng/libcollector/Makefile.in b/gprofng/libcollector/Makefile.in
index 920c7a7ad11..f9ed2d95db5 100644
--- a/gprofng/libcollector/Makefile.in
+++ b/gprofng/libcollector/Makefile.in
@@ -156,7 +156,8 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(myincludedir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
-libgp_collector_la_DEPENDENCIES =
+am__DEPENDENCIES_1 =
+libgp_collector_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
 am__objects_1 = libgp_collector_la-gethrtime.lo \
 	libgp_collector_la-dispatcher.lo libgp_collector_la-iolib.lo \
 	libgp_collector_la-mmaptrace.lo libgp_collector_la-memmgr.lo \
@@ -305,6 +306,7 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
+CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CXX = @CXX@
@@ -459,7 +461,7 @@ libgp_collector_la_CPPFLAGS = $(AM_CPPFLAGS) $(jdk_inc) \
 # Prevent libtool from reordering -Wl,--no-as-needed after -lrt by
 # disguising -lrt as a linker flag.
 libgp_collector_la_LDFLAGS = $(AM_LDFLAGS)
-libgp_collector_la_LIBADD = 
+libgp_collector_la_LIBADD = $(CLOCK_GETTIME_LINK)
 libgp_heap_la_SOURCES = heaptrace.c
 libgp_heap_la_LDFLAGS = $(AM_LDFLAGS)
 libgp_sync_la_SOURCES = synctrace.c
diff --git a/gprofng/libcollector/configure b/gprofng/libcollector/configure
index ed23350d7b6..887d2719910 100755
--- a/gprofng/libcollector/configure
+++ b/gprofng/libcollector/configure
@@ -633,6 +633,7 @@ ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+CLOCK_GETTIME_LINK
 GPROFNG_VARIANT
 CXXCPP
 OTOOL64
@@ -12013,7 +12014,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12016 "configure"
+#line 12017 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12119,7 +12120,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12122 "configure"
+#line 12123 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15437,6 +15438,58 @@ case "${target}" in
 esac
 
 
+clock_gettime_link=
+# 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.  This
+# test is copied from libgomp, and modified to not link in -lrt as
+# we're using this for test timing only.
+if test "$ac_cv_func_clock_gettime" = no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
+$as_echo_n "checking for clock_gettime in -lrt... " >&6; }
+if ${ac_cv_lib_rt_clock_gettime+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lrt  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_rt_clock_gettime=yes
+else
+  ac_cv_lib_rt_clock_gettime=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
+$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
+if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then :
+  CLOCK_GETTIME_LINK=-lrt
+
+$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
+
+fi
+
+fi
+
+
 ac_config_files="$ac_config_files Makefile"
 
 ac_config_headers="$ac_config_headers lib-config.h:../common/config.h.in"
diff --git a/gprofng/libcollector/configure.ac b/gprofng/libcollector/configure.ac
index 8acd66f6977..bc8c3f1e144 100644
--- a/gprofng/libcollector/configure.ac
+++ b/gprofng/libcollector/configure.ac
@@ -54,6 +54,19 @@ case "${target}" in
 esac
 AC_SUBST(GPROFNG_VARIANT)
 
+clock_gettime_link=
+# 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.  This
+# test is copied from libgomp, and modified to not link in -lrt as
+# we're using this for test timing only.
+if test "$ac_cv_func_clock_gettime" = no; then
+  AC_CHECK_LIB(rt, clock_gettime,
+    [CLOCK_GETTIME_LINK=-lrt
+     AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+	       [Define to 1 if you have the `clock_gettime' function.])])
+fi
+AC_SUBST(CLOCK_GETTIME_LINK)
+
 AC_CONFIG_FILES([Makefile])
 AC_CONFIG_HEADERS([lib-config.h:../common/config.h.in])
 AC_OUTPUT
diff --git a/gprofng/libcollector/gethrtime.c b/gprofng/libcollector/gethrtime.c
index f369cdc8ee1..002de7c77ba 100644
--- a/gprofng/libcollector/gethrtime.c
+++ b/gprofng/libcollector/gethrtime.c
@@ -22,17 +22,22 @@
 #include <time.h>
 #include "gp-time.h"
 
-/*
- *  CLOCK_MONOTONIC
- *  Clock that cannot be set and represents monotonic time since some
- *           unspecified starting point.
- */
+/*  CLOCK_MONOTONIC
+    Clock that cannot be set and represents monotonic time since some
+             unspecified starting point.  */
+
 static hrtime_t
-linux_gethrtime ()
+linux_gethrtime (void)
 {
   struct timespec tp;
   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)
     rc = ((hrtime_t) tp.tv_sec)*1000000000 + (hrtime_t) tp.tv_nsec;
   return rc;

  reply	other threads:[~2022-03-15 15:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 10:57 Tobias Burnus
2022-03-14 18:16 ` Vladimir Mezentsev
2022-03-15 15:24   ` Nick Clifton [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14359283-a893-7208-c87d-c42aad214c67@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=tobias@codesourcery.com \
    --cc=vladimir.mezentsev@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).