Hi! On Mon, 02 Oct 2017 14:00:36 +0200, I wrote: > On Thu, 28 Sep 2017 17:30:53 -0700, Ian Lance Taylor <i...@golang.org> wrote: > > This patch to libbacktrace adds support for compressed debug sections. > > [...] > > > --- ztest.c (revision 0) > > +++ ztest.c (working copy) > > @@ -0,0 +1,446 @@ > > +/* ztest.c -- Test for libbacktrace inflate code. > > +[...] > > + cid = CLOCK_REALTIME; > > +#ifdef CLOCK_PROCESS_CPUTIME_ID > > + cid = CLOCK_PROCESS_CPUTIME_ID; > > +#endif > > + if (clock_gettime (cid, &ts1) < 0) > > +[...] > > On an elderly system, I ran into that not linking [...]
> {+ztest-ztest.o: In function `test_large':+} > {+[...]/source-gcc/libbacktrace/ztest.c:350: undefined reference to > `clock_gettime'+} That's because the version of glibc used still provided clock_gettime in librt only. Committed to trunk r253345, as obvious: commit 0b986d3d7a36d3b3f84a0221f8a48af55e9aa08a Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Mon Oct 2 11:56:39 2017 +0000 libbacktrace: Support the case that clock_gettime is in librt libbacktrace/ PR other/67165 * Makefile.am: Append the content of clock_gettime_link to ztest_LDADD. * configure.ac: Test for the case that clock_gettime is in librt. * Makefile.in: Regenerate. * configure: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253345 138bc75d-0d04-0410-961f-82ee72b054a4 --- libbacktrace/ChangeLog | 7 ++++++ libbacktrace/Makefile.am | 1 + libbacktrace/Makefile.in | 6 +++-- libbacktrace/configure | 56 +++++++++++++++++++++++++++++++++++++++++++++-- libbacktrace/configure.ac | 12 ++++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) diff --git libbacktrace/ChangeLog libbacktrace/ChangeLog index 0e4cfd2..fde5a1b 100644 --- libbacktrace/ChangeLog +++ libbacktrace/ChangeLog @@ -1,6 +1,13 @@ 2017-10-02 Thomas Schwinge <tho...@codesourcery.com> PR other/67165 + * Makefile.am: Append the content of clock_gettime_link to + ztest_LDADD. + * configure.ac: Test for the case that clock_gettime is in librt. + * Makefile.in: Regenerate. + * configure: Likewise. + + PR other/67165 * configure.ac: Check for clock_gettime. * config.h.in: Regenerate. * configure: Likewise. diff --git libbacktrace/Makefile.am libbacktrace/Makefile.am index 11d94eb..b4f4df4 100644 --- libbacktrace/Makefile.am +++ libbacktrace/Makefile.am @@ -108,6 +108,7 @@ ztest_LDADD = libbacktrace.la if HAVE_ZLIB ztest_LDADD += -lz endif +ztest_LDADD += $(clock_gettime_link) check_PROGRAMS += ztest diff --git libbacktrace/Makefile.in libbacktrace/Makefile.in index ceb769d..30a1442 100644 --- libbacktrace/Makefile.in +++ libbacktrace/Makefile.in @@ -165,7 +165,7 @@ ttest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @NATIVE_TRUE@ ztest-testlib.$(OBJEXT) ztest_OBJECTS = $(am_ztest_OBJECTS) @NATIVE_TRUE@ztest_DEPENDENCIES = libbacktrace.la \ -@NATIVE_TRUE@ $(am__DEPENDENCIES_1) +@NATIVE_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) ztest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(ztest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ @@ -287,6 +287,7 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ +clock_gettime_link = @clock_gettime_link@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ @@ -383,7 +384,8 @@ TESTS = $(check_PROGRAMS) $(am__append_4) @NATIVE_TRUE@stest_LDADD = libbacktrace.la @NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c @NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\" -@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2) +@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2) \ +@NATIVE_TRUE@ $(clock_gettime_link) @NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c @NATIVE_TRUE@edtest_LDADD = libbacktrace.la @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c diff --git libbacktrace/configure libbacktrace/configure index 062dc77..57ca5eb 100755 --- libbacktrace/configure +++ libbacktrace/configure @@ -614,6 +614,7 @@ HAVE_ZLIB_TRUE HAVE_PTHREAD_FALSE HAVE_PTHREAD_TRUE PTHREAD_CFLAGS +clock_gettime_link BACKTRACE_USES_MALLOC ALLOC_FILE VIEW_FILE @@ -11145,7 +11146,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11148 "configure" +#line 11149 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11251,7 +11252,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11254 "configure" +#line 11255 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12759,6 +12760,57 @@ _ACEOF 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 test "${ac_cv_lib_rt_clock_gettime+set}" = set; 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" = x""yes; then : + clock_gettime_link=-lrt + +$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h + +fi + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5 $as_echo_n "checking whether -pthread is supported... " >&6; } diff --git libbacktrace/configure.ac libbacktrace/configure.ac index 75ec9f5..ad5368a 100644 --- libbacktrace/configure.ac +++ libbacktrace/configure.ac @@ -390,6 +390,18 @@ fi # Check for the clock_gettime function. AC_CHECK_FUNCS(clock_gettime) +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) dnl Test whether the compiler supports the -pthread option. AC_CACHE_CHECK([whether -pthread is supported], Grüße Thomas