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 6dc4dae91a..d4c0fbe658 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]