libbacktrace: don't run --build-id tests if it is not supported

PR libbacktrace/108297
	* configure.ac: Test whether linker supports --build-id.
	* Makefile.am: Only run --build-id tests if supported.
	* configure, Makefile.in: Regenerate.
This commit is contained in:
Ian Lance Taylor 2023-01-06 09:39:49 -08:00
parent f7bd48c6bb
commit f3707a55ac
4 changed files with 78 additions and 21 deletions

View File

@ -248,6 +248,7 @@ check_DATA += allocfail.dSYM
endif USE_DSYMUTIL
if HAVE_ELF
if HAVE_BUILDID
if HAVE_OBJCOPY_DEBUGLINK
b2test_SOURCES = $(btest_SOURCES)
@ -271,6 +272,7 @@ MAKETESTS += b3test_dwz_buildid
endif HAVE_DWZ
endif HAVE_OBJCOPY_DEBUGLINK
endif HAVE_BUILDID
endif HAVE_ELF
btest_SOURCES = btest.c testlib.c

View File

@ -133,10 +133,10 @@ TESTS = $(am__append_4) $(MAKETESTS) $(am__EXEEXT_16)
@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ btest.dSYM btest_alloc.dSYM \
@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ stest.dSYM stest_alloc.dSYM \
@NATIVE_TRUE@@USE_DSYMUTIL_TRUE@ edtest.dSYM edtest_alloc.dSYM
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b2test_buildid
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = b3test
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = b3test_dwz_buildid
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_6 = b2test
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_7 = b2test_buildid
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = b3test
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = b3test_dwz_buildid
@HAVE_ELF_TRUE@@NATIVE_TRUE@am__append_10 = btest_lto
@NATIVE_TRUE@am__append_11 = btest_alloc stest stest_alloc
@HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_12 = btest_dwz
@ -222,8 +222,8 @@ libbacktrace_noformat_la_OBJECTS = \
$(am_libbacktrace_noformat_la_OBJECTS)
@NATIVE_TRUE@am_libbacktrace_noformat_la_rpath =
@NATIVE_TRUE@am__EXEEXT_1 = allocfail$(EXEEXT)
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = b2test$(EXEEXT)
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = b3test$(EXEEXT)
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = b2test$(EXEEXT)
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = b3test$(EXEEXT)
@NATIVE_TRUE@am__EXEEXT_4 = test_elf_32$(EXEEXT) test_elf_64$(EXEEXT) \
@NATIVE_TRUE@ test_macho$(EXEEXT) test_xcoff_32$(EXEEXT) \
@NATIVE_TRUE@ test_xcoff_64$(EXEEXT) test_pecoff$(EXEEXT) \
@ -263,17 +263,17 @@ allocfail_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@NATIVE_TRUE@am__objects_2 = b2test-btest.$(OBJEXT) \
@NATIVE_TRUE@ b2test-testlib.$(OBJEXT)
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b2test_OBJECTS = $(am__objects_2)
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b2test_OBJECTS = $(am__objects_2)
b2test_OBJECTS = $(am_b2test_OBJECTS)
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_DEPENDENCIES = libbacktrace_elf_for_test.la
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_DEPENDENCIES = libbacktrace_elf_for_test.la
b2test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(b2test_CFLAGS) $(CFLAGS) \
$(b2test_LDFLAGS) $(LDFLAGS) -o $@
@NATIVE_TRUE@am__objects_3 = b3test-btest.$(OBJEXT) \
@NATIVE_TRUE@ b3test-testlib.$(OBJEXT)
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b3test_OBJECTS = $(am__objects_3)
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am_b3test_OBJECTS = $(am__objects_3)
b3test_OBJECTS = $(am_b3test_OBJECTS)
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_DEPENDENCIES = libbacktrace_elf_for_test.la
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_DEPENDENCIES = libbacktrace_elf_for_test.la
b3test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(b3test_CFLAGS) $(CFLAGS) \
$(b3test_LDFLAGS) $(LDFLAGS) -o $@
@ -1093,14 +1093,14 @@ libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
@NATIVE_TRUE@allocfail_SOURCES = allocfail.c testlib.c
@NATIVE_TRUE@allocfail_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@NATIVE_TRUE@allocfail_LDADD = libbacktrace_instrumented_alloc.la
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_SOURCES = $(btest_SOURCES)
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDFLAGS = -Wl,--build-id
@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDADD = libbacktrace_elf_for_test.la
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_SOURCES = $(btest_SOURCES)
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDFLAGS = -Wl,--build-id
@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDADD = libbacktrace_elf_for_test.la
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_SOURCES = $(btest_SOURCES)
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDFLAGS = -Wl,--build-id
@HAVE_BUILDID_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b2test_LDADD = libbacktrace_elf_for_test.la
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_SOURCES = $(btest_SOURCES)
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDFLAGS = -Wl,--build-id
@HAVE_BUILDID_TRUE@@HAVE_DWZ_TRUE@@HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@b3test_LDADD = libbacktrace_elf_for_test.la
@NATIVE_TRUE@btest_SOURCES = btest.c testlib.c
@NATIVE_TRUE@btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
@NATIVE_TRUE@btest_LDADD = libbacktrace.la

View File

@ -657,6 +657,8 @@ HAVE_ZSTD_FALSE
HAVE_ZSTD_TRUE
HAVE_COMPRESSED_DEBUG_FALSE
HAVE_COMPRESSED_DEBUG_TRUE
HAVE_BUILDID_FALSE
HAVE_BUILDID_TRUE
HAVE_ZLIB_FALSE
HAVE_ZLIB_TRUE
HAVE_DWARF5_FALSE
@ -11539,7 +11541,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11542 "configure"
#line 11544 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11645,7 +11647,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11648 "configure"
#line 11650 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -13742,6 +13744,44 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether --build-id is supported" >&5
$as_echo_n "checking whether --build-id is supported... " >&6; }
if ${libbacktrace_cv_ld_buildid+:} false; then :
$as_echo_n "(cached) " >&6
else
LDFLAGS_hold=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--build-id"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
libbacktrace_cv_ld_buildid=yes
else
libbacktrace_cv_ld_buildid=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LDFLAGS=$LDFLAGS_hold
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libbacktrace_cv_ld_buildid" >&5
$as_echo "$libbacktrace_cv_ld_buildid" >&6; }
if test "$libbacktrace_cv_ld_buildid" = yes; then
HAVE_BUILDID_TRUE=
HAVE_BUILDID_FALSE='#'
else
HAVE_BUILDID_TRUE='#'
HAVE_BUILDID_FALSE=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether --compress-debug-sections is supported" >&5
$as_echo_n "checking whether --compress-debug-sections is supported... " >&6; }
if ${libgo_cv_ld_compress+:} false; then :
@ -14411,6 +14451,10 @@ if test -z "${HAVE_ZLIB_TRUE}" && test -z "${HAVE_ZLIB_FALSE}"; then
as_fn_error $? "conditional \"HAVE_ZLIB\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_BUILDID_TRUE}" && test -z "${HAVE_BUILDID_FALSE}"; then
as_fn_error $? "conditional \"HAVE_BUILDID\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_COMPRESSED_DEBUG_TRUE}" && test -z "${HAVE_COMPRESSED_DEBUG_FALSE}"; then
as_fn_error $? "conditional \"HAVE_COMPRESSED_DEBUG\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -484,7 +484,18 @@ AC_CHECK_LIB([z], [compress],
[AC_DEFINE(HAVE_ZLIB, 1, [Define if -lz is available.])])
AM_CONDITIONAL(HAVE_ZLIB, test "$ac_cv_lib_z_compress" = yes)
dnl Test whether the linker supports the --compress_debug_sections option.
dnl Test whether the linker supports the --build-id option.
AC_CACHE_CHECK([whether --build-id is supported],
[libbacktrace_cv_ld_buildid],
[LDFLAGS_hold=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--build-id"
AC_LINK_IFELSE([AC_LANG_PROGRAM(,)],
[libbacktrace_cv_ld_buildid=yes],
[libbacktrace_cv_ld_buildid=no])
LDFLAGS=$LDFLAGS_hold])
AM_CONDITIONAL(HAVE_BUILDID, test "$libbacktrace_cv_ld_buildid" = yes)
dnl Test whether the linker supports the --compress-debug-sections option.
AC_CACHE_CHECK([whether --compress-debug-sections is supported],
[libgo_cv_ld_compress],
[LDFLAGS_hold=$LDFLAGS