Skip to content

Commit

Permalink
libbacktrace: don't run --build-id tests if it is not supported
Browse files Browse the repository at this point in the history
	PR libbacktrace/108297
	* configure.ac: Test whether linker supports --build-id.
	* Makefile.am: Only run --build-id tests if supported.
	* configure, Makefile.in: Regenerate.
  • Loading branch information
ianlancetaylor committed Jan 6, 2023
1 parent da7eff2 commit ad106d5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ check_DATA += allocfail.dSYM
endif USE_DSYMUTIL

if HAVE_ELF
if HAVE_BUILDID
if HAVE_OBJCOPY_DEBUGLINK

b2test_SOURCES = $(btest_SOURCES)
Expand All @@ -272,6 +273,7 @@ MAKETESTS += b3test_dwz_buildid
endif HAVE_DWZ

endif HAVE_OBJCOPY_DEBUGLINK
endif HAVE_BUILDID
endif HAVE_ELF

btest_SOURCES = btest.c testlib.c
Expand Down
36 changes: 18 additions & 18 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,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
Expand Down Expand Up @@ -249,8 +249,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) \
Expand Down Expand Up @@ -290,17 +290,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 $@
Expand Down Expand Up @@ -1092,14 +1092,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
Expand Down
48 changes: 46 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -11276,7 +11278,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11279 "configure"
#line 11281 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
Expand Down Expand Up @@ -11382,7 +11384,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11385 "configure"
#line 11387 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
Expand Down Expand Up @@ -12774,6 +12776,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 :
Expand Down Expand Up @@ -13443,6 +13483,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
Expand Down
13 changes: 12 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,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
Expand Down

0 comments on commit ad106d5

Please sign in to comment.