Hi!

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, and thus *all*
libbacktrace testing disappearing:

    [...]
    {+ztest-ztest.o: In function `test_large':+}
    {+[...]/source-gcc/libbacktrace/ztest.c:350: undefined reference to 
`clock_gettime'+}
    {+[...]/source-gcc/libbacktrace/ztest.c:368: undefined reference to 
`clock_gettime'+}
    {+[...]/source-gcc/libbacktrace/ztest.c:378: undefined reference to 
`clock_gettime'+}
    {+[...]/source-gcc/libbacktrace/ztest.c:387: undefined reference to 
`clock_gettime'+}
    {+collect2: error: ld returned 1 exit status+}
    {+make[3]: *** [ztest] Error 1+}
    [...]
    [-make[3]: Leaving directory `[...]/build-gcc/libbacktrace'-]
    [-make  check-TESTS-]
    [-make[3]: Entering directory `[...]/build-gcc/libbacktrace'-]
    [-objcopy --only-keep-debug btest btest.debug-]
    [-objcopy --strip-debug --add-gnu-debuglink=btest.debug btest dtest-]
    [-PASS: backtrace_full noinline-]
    [-PASS: backtrace_full inline-]
    [-PASS: backtrace_simple noinline-]
    [-PASS: backtrace_simple inline-]
    [-PASS: backtrace_syminfo variable-]
    [-PASS: btest-]
    [-PASS: stest-]
    [-PASS: backtrace_full alloc stress-]
    [-PASS: edtest-]
    [-PASS: threaded backtrace_full noinline-]
    [-PASS: ttest-]
    [-PASS: backtrace_full noinline-]
    [-PASS: backtrace_full inline-]
    [-PASS: backtrace_simple noinline-]
    [-PASS: backtrace_simple inline-]
    [-PASS: backtrace_syminfo variable-]
    [-PASS: dtest-]
    [-==[PID]====[PID]====[PID]====[PID]====-]
    [-All 5 tests passed-]
    [-==[PID]====[PID]====[PID]====[PID]====-]
    make[3]: Leaving directory `[...]/build-gcc/libbacktrace'
    {+make[2]: *** [check-am] Error 2+}
    {+make[2]: Target `check' not remade because of errors.+}
    make[2]: Leaving directory `[...]/build-gcc/libbacktrace'
    {+make[1]: *** [check-libbacktrace] Error 2+}
    [...]

Committed to trunk r253344, as obvious:

commit c476d11ef7dbd508067067fbd0b8450d27f1f057
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Oct 2 11:56:25 2017 +0000

    libbacktrace: Conditionalize test timing on clock_gettime availability
    
            libbacktrace/
            PR other/67165
            * configure.ac: Check for clock_gettime.
            * config.h.in: Regenerate.
            * configure: Likewise.
            * ztest.c (average_time, test_large): Conditionalize test timing
            on clock_gettime availability.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253344 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libbacktrace/ChangeLog    |  9 +++++++++
 libbacktrace/config.h.in  |  3 +++
 libbacktrace/configure    | 13 +++++++++++++
 libbacktrace/configure.ac |  3 +++
 libbacktrace/ztest.c      | 12 +++++++++++-
 5 files changed, 39 insertions(+), 1 deletion(-)

diff --git libbacktrace/ChangeLog libbacktrace/ChangeLog
index 9597a68..0e4cfd2 100644
--- libbacktrace/ChangeLog
+++ libbacktrace/ChangeLog
@@ -1,3 +1,12 @@
+2017-10-02  Thomas Schwinge  <tho...@codesourcery.com>
+
+       PR other/67165
+       * configure.ac: Check for clock_gettime.
+       * config.h.in: Regenerate.
+       * configure: Likewise.
+       * ztest.c (average_time, test_large): Conditionalize test timing
+       on clock_gettime availability.
+
 2017-09-29  Tony Reix  <tony.r...@atos.net>
 
        * xcoff.c: Initial support for DWARF debug sections in XCOFF.
diff --git libbacktrace/config.h.in libbacktrace/config.h.in
index a9f70da..c19b6e4 100644
--- libbacktrace/config.h.in
+++ libbacktrace/config.h.in
@@ -9,6 +9,9 @@
 /* Define to 1 if you have the __atomic functions */
 #undef HAVE_ATOMIC_FUNCTIONS
 
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
 /* Define to 1 if you have the declaration of `strnlen', and to 0 if you
    don't. */
 #undef HAVE_DECL_STRNLEN
diff --git libbacktrace/configure libbacktrace/configure
index ece4151..062dc77 100755
--- libbacktrace/configure
+++ libbacktrace/configure
@@ -12747,6 +12747,19 @@ $as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h
 
 fi
 
+# Check for the clock_gettime function.
+for ac_func in clock_gettime
+do :
+  ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
+if test "x$ac_cv_func_clock_gettime" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_CLOCK_GETTIME 1
+_ACEOF
+
+fi
+done
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is 
supported" >&5
 $as_echo_n "checking whether -pthread is supported... " >&6; }
 if test "${libgo_cv_lib_pthread+set}" = set; then :
diff --git libbacktrace/configure.ac libbacktrace/configure.ac
index f389c72..75ec9f5 100644
--- libbacktrace/configure.ac
+++ libbacktrace/configure.ac
@@ -388,6 +388,9 @@ if test "$have_getexecname" = "yes"; then
   AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
 fi
 
+# Check for the clock_gettime function.
+AC_CHECK_FUNCS(clock_gettime)
+
 dnl Test whether the compiler supports the -pthread option.
 AC_CACHE_CHECK([whether -pthread is supported],
 [libgo_cv_lib_pthread],
diff --git libbacktrace/ztest.c libbacktrace/ztest.c
index 103ad65..0b1cbc3 100644
--- libbacktrace/ztest.c
+++ libbacktrace/ztest.c
@@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include <zlib.h>
 #endif
 
+#ifdef HAVE_CLOCK_GETTIME
+# define TEST_TIMING
+#endif
+
 #include "backtrace.h"
 #include "backtrace-supported.h"
 
@@ -157,7 +161,7 @@ test_samples (struct backtrace_state *state)
     }
 }
 
-#ifdef HAVE_ZLIB
+#if defined HAVE_ZLIB && defined TEST_TIMING
 
 /* Given a set of TRIALS timings, discard the lowest and highest
    values and return the mean average of the rest.  */
@@ -216,6 +220,7 @@ test_large (struct backtrace_state *state)
   unsigned char *uncompressed_buf;
   size_t uncompressed_bufsize;
   int r;
+# ifdef TEST_TIMING
   clockid_t cid;
   struct timespec ts1;
   struct timespec ts2;
@@ -224,6 +229,7 @@ test_large (struct backtrace_state *state)
   const size_t trials = 16;
   size_t ctimes[16];
   size_t ztimes[16];
+# endif /* TEST_TIMING */
   static const char * const names[] = {
     "Mark.Twain-Tom.Sawyer.txt",
     "../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt"
@@ -341,6 +347,8 @@ test_large (struct backtrace_state *state)
 
   printf ("PASS: inflate large\n");
 
+# ifdef TEST_TIMING
+
   for (i = 0; i < trials; ++i)
     {
       cid = CLOCK_REALTIME;
@@ -411,6 +419,8 @@ test_large (struct backtrace_state *state)
   printf ("zlib time:    : %zu ns\n", ztime);
   printf ("percentage    : %g\n", (double) ztime / (double) ctime);
 
+# endif /* TEST_TIMING */
+
   return;
 
  fail:


Grüße
 Thomas

Reply via email to