From b05e20c9685ca8168681d360720c7c94a4fd6f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 27 Apr 2022 16:41:27 +0200 Subject: [PATCH] Add -Wl,--export-dynamic to standard LDFLAGS if supported From the ld man page: When creating a dynamically linked executable, using the -E option or the --export-dynamic option causes the linker to add all symbols to the dynamic symbol table. The dynamic symbol table is the set of symbols which are visible from dynamic objects at run time. This should allow the backtrace(3) to fully resolve the symbols when creating backtrace on an assertion failure. --- Makefile.top | 3 ++- configure.ac | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile.top b/Makefile.top index 68bbc1242d..62c5293c2c 100644 --- a/Makefile.top +++ b/Makefile.top @@ -11,7 +11,8 @@ AM_CPPFLAGS = \ -include $(top_builddir)/config.h \ -I$(srcdir)/include -AM_LDFLAGS = +AM_LDFLAGS = \ + $(STD_LDFLAGS) LDADD = if HOST_MACOS diff --git a/configure.ac b/configure.ac index 9b29cb4901..db46a9f83f 100644 --- a/configure.ac +++ b/configure.ac @@ -112,13 +112,15 @@ AS_IF([test "$enable_static" != "no" && test "$enable_developer" != "yes"], [AC_MSG_ERROR([Static linking is not supported as it disables dlopen() and certain security features (e.g. RELRO, ASLR)])]) # -# Set the default CFLAGS and CPPFLAGS +# Set the default CFLAGS, CPPFLAGS, and LDFLAGS # STD_CFLAGS="-Wall -Wextra -Wwrite-strings -Wpointer-arith -Wno-missing-field-initializers -Wformat -Wshadow" # These should be always errors STD_CFLAGS="$STD_CFLAGS -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=format-security -Werror=parentheses -Werror=implicit -Werror=strict-prototypes -Werror=vla" +STD_LDFLAGS="" + # ... except in test code TEST_CFLAGS="-Wno-vla" @@ -136,6 +138,9 @@ AX_CHECK_COMPILE_FLAG([-Werror -fno-delete-null-pointer-checks], AX_CHECK_COMPILE_FLAG([-fdiagnostics-show-option], [STD_CFLAGS="$STD_CFLAGS -fdiagnostics-show-option"]) +AX_CHECK_LINK_FLAG([-Wl,--export-dynamic], + [STD_LDFLAGS="$STD_LDFLAGS -Wl,--export-dynamic"]) + host_macos=no AS_CASE([$host],[*-darwin*],[host_macos=yes]) AM_CONDITIONAL([HOST_MACOS], [test "$host_macos" = "yes"]) @@ -162,6 +167,7 @@ AS_IF([test "$enable_developer" = "yes"], AC_SUBST([DEVELOPER_MODE]) AC_SUBST([STD_CFLAGS]) AC_SUBST([STD_CPPFLAGS]) +AC_SUBST([STD_LDFLAGS]) AC_SUBST([TEST_CFLAGS]) # [pairwise: --enable-warn-error, --disable-warn-error]