Fix Build issues due to patch "gprofng: a new GNU profiler"

Find and fix more places where clock_gettime() and CLOCK_MONOTONIC_RAW are used.
This commit is contained in:
Nick Clifton 2022-03-18 15:45:34 +00:00
parent f0cf07f341
commit 0a30596cfa
12 changed files with 99 additions and 88 deletions

View File

@ -242,6 +242,7 @@ BUILD_SUBDIRS = @BUILD_SUBDIRS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@

57
gprofng/configure vendored
View File

@ -634,6 +634,7 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
BUILD_SUBDIRS
CLOCK_GETTIME_LINK
GPROFNG_LIBDIR
GPROFNG_CPPFLAGS
GPROFNG_CFLAGS
@ -12136,7 +12137,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12139 "configure"
#line 12140 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -12242,7 +12243,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12245 "configure"
#line 12246 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -16721,6 +16722,58 @@ fi
done
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 src/Makefile gp-display-html/Makefile doc/Makefile"

View File

@ -202,6 +202,19 @@ AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
AC_CHECK_DECLS([basename])
AC_CHECK_FUNCS(clock_gettime strsignal)
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_SUBST(BUILD_SUBDIRS)
AC_CONFIG_FILES([Makefile src/Makefile gp-display-html/Makefile doc/Makefile])

View File

@ -226,6 +226,7 @@ BUILD_SUBDIRS = @BUILD_SUBDIRS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@

View File

@ -190,6 +190,7 @@ BUILD_SUBDIRS = @BUILD_SUBDIRS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@

View File

@ -158,8 +158,7 @@ am__uninstall_files_from_dir = { \
}
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(myincludedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libgp_collector_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
libgp_collector_la_DEPENDENCIES =
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 \
@ -308,7 +307,6 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@

View File

@ -633,7 +633,6 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
CLOCK_GETTIME_LINK
GPROFNG_NO_NONNULL_COMPARE_CFLAGS
GPROFNG_VARIANT
CXXCPP
@ -12059,7 +12058,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12062 "configure"
#line 12061 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -12165,7 +12164,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12168 "configure"
#line 12167 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -15542,58 +15541,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
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"

View File

@ -58,19 +58,6 @@ AC_SUBST(GPROFNG_VARIANT)
ACX_PROG_CC_WARNING_OPTS([-Wno-nonnull-compare], [GPROFNG_NO_NONNULL_COMPARE_CFLAGS])
AC_SUBST(GPROFNG_NO_NONNULL_COMPARE_CFLAGS)
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

View File

@ -133,19 +133,19 @@ dbe_DATA = $(srcdir)/gprofng.rc
bin_PROGRAMS = gp-archive gp-collect-app gprofng gp-display-text gp-display-src
gp_archive_SOURCES = gp-archive.cc ArchiveExp.cc
gp_archive_LDADD = $(LIBGPROFNG)
gp_archive_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gp_collect_app_SOURCES = gp-collect-app.cc checks.cc envsets.cc count.cc
gp_collect_app_LDADD = $(LIBGPROFNG)
gp_collect_app_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gprofng_SOURCES = gprofng.cc
gprofng_LDADD = $(LIBGPROFNG)
gprofng_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gp_display_src_SOURCES = gp-display-src.cc
gp_display_src_LDADD = $(LIBGPROFNG)
gp_display_src_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gp_display_text_SOURCES = gp-display-text.cc ipc.cc ipcio.cc
gp_display_text_LDADD = $(LIBGPROFNG)
gp_display_text_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
if BUILD_MAN

View File

@ -193,21 +193,21 @@ libgprofng_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
PROGRAMS = $(bin_PROGRAMS)
am_gp_archive_OBJECTS = gp-archive.$(OBJEXT) ArchiveExp.$(OBJEXT)
gp_archive_OBJECTS = $(am_gp_archive_OBJECTS)
gp_archive_DEPENDENCIES = $(LIBGPROFNG)
gp_archive_DEPENDENCIES = $(LIBGPROFNG) $(am__DEPENDENCIES_1)
am_gp_collect_app_OBJECTS = gp-collect-app.$(OBJEXT) checks.$(OBJEXT) \
envsets.$(OBJEXT) count.$(OBJEXT)
gp_collect_app_OBJECTS = $(am_gp_collect_app_OBJECTS)
gp_collect_app_DEPENDENCIES = $(LIBGPROFNG)
gp_collect_app_DEPENDENCIES = $(LIBGPROFNG) $(am__DEPENDENCIES_1)
am_gp_display_src_OBJECTS = gp-display-src.$(OBJEXT)
gp_display_src_OBJECTS = $(am_gp_display_src_OBJECTS)
gp_display_src_DEPENDENCIES = $(LIBGPROFNG)
gp_display_src_DEPENDENCIES = $(LIBGPROFNG) $(am__DEPENDENCIES_1)
am_gp_display_text_OBJECTS = gp-display-text.$(OBJEXT) ipc.$(OBJEXT) \
ipcio.$(OBJEXT)
gp_display_text_OBJECTS = $(am_gp_display_text_OBJECTS)
gp_display_text_DEPENDENCIES = $(LIBGPROFNG)
gp_display_text_DEPENDENCIES = $(LIBGPROFNG) $(am__DEPENDENCIES_1)
am_gprofng_OBJECTS = gprofng.$(OBJEXT)
gprofng_OBJECTS = $(am_gprofng_OBJECTS)
gprofng_DEPENDENCIES = $(LIBGPROFNG)
gprofng_DEPENDENCIES = $(LIBGPROFNG) $(am__DEPENDENCIES_1)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@ -309,6 +309,7 @@ BUILD_SUBDIRS = @BUILD_SUBDIRS@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
@ -548,15 +549,15 @@ libgprofng_la_LIBADD = $(top_builddir)/../opcodes/libopcodes.la \
dbedir = $(prefix)/etc
dbe_DATA = $(srcdir)/gprofng.rc
gp_archive_SOURCES = gp-archive.cc ArchiveExp.cc
gp_archive_LDADD = $(LIBGPROFNG)
gp_archive_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gp_collect_app_SOURCES = gp-collect-app.cc checks.cc envsets.cc count.cc
gp_collect_app_LDADD = $(LIBGPROFNG)
gp_collect_app_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gprofng_SOURCES = gprofng.cc
gprofng_LDADD = $(LIBGPROFNG)
gprofng_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gp_display_src_SOURCES = gp-display-src.cc
gp_display_src_LDADD = $(LIBGPROFNG)
gp_display_src_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
gp_display_text_SOURCES = gp-display-text.cc ipc.cc ipcio.cc
gp_display_text_LDADD = $(LIBGPROFNG)
gp_display_text_LDADD = $(LIBGPROFNG) $(CLOCK_GETTIME_LINK)
# The man pages depend on the version number and on a help2man include file.
@BUILD_MAN_TRUE@common_mandeps = $(top_srcdir)/../bfd/version.m4

View File

@ -159,7 +159,11 @@ gethrtime (void)
* There is no issue on Solaris, where gethrtime() is provided by the kernel
* and used by DTrace.
*/
#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;

View File

@ -222,7 +222,12 @@ 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;