Skip to content

Commit

Permalink
autotools: Add --no-undefined linker option
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Jun 28, 2024
1 parent 1abae91 commit 7f37668
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ endif
libsecp256k1_la_SOURCES = src/secp256k1.c
libsecp256k1_la_CPPFLAGS = $(SECP_CONFIG_DEFINES)
libsecp256k1_la_LIBADD = $(COMMON_LIB) $(PRECOMPUTED_LIB)
libsecp256k1_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_CURRENT):$(LIB_VERSION_REVISION):$(LIB_VERSION_AGE)
libsecp256k1_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_CURRENT):$(LIB_VERSION_REVISION):$(LIB_VERSION_AGE) $(SECP_LIB_LDFLAGS)

noinst_PROGRAMS =
if USE_BENCHMARK
Expand Down
16 changes: 16 additions & 0 deletions build-aux/m4/bitcoin_secp.m4
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ AC_DEFUN([SECP_TRY_APPEND_CFLAGS], [
AC_SUBST($2)
])

dnl SECP_TRY_APPEND_LDFLAGS(flags, VAR)
dnl Append flags to VAR if a linker accepts them.
AC_DEFUN([SECP_TRY_APPEND_LDFLAGS], [
AC_MSG_CHECKING([if linker supports $1])
SECP_TRY_APPEND_LDFLAGS_saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$1 $LDFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM()], [flag_works=yes], [flag_works=no])
AC_MSG_RESULT($flag_works)
LDFLAGS="$SECP_TRY_APPEND_LDFLAGS_saved_LDFLAGS"
if test x"$flag_works" = x"yes"; then
$2="$$2 $1"
fi
unset flag_works
AC_SUBST($2)
])

dnl SECP_SET_DEFAULT(VAR, default, default-dev-mode)
dnl Set VAR to default or default-dev-mode, depending on whether dev mode is enabled
AC_DEFUN([SECP_SET_DEFAULT], [
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ AC_DEFUN([SECP_TRY_APPEND_DEFAULT_CFLAGS], [
])
SECP_TRY_APPEND_DEFAULT_CFLAGS(SECP_CFLAGS)

SECP_TRY_APPEND_LDFLAGS([-Wl,--no-undefined], [SECP_LIB_LDFLAGS])

###
### Define config arguments
###
Expand Down Expand Up @@ -486,6 +488,7 @@ echo " CC = $CC"
echo " CPPFLAGS = $CPPFLAGS"
echo " SECP_CFLAGS = $SECP_CFLAGS"
echo " CFLAGS = $CFLAGS"
echo " SECP_LIB_LDFLAGS = $SECP_LIB_LDFLAGS"
echo " LDFLAGS = $LDFLAGS"

if test x"$print_msan_notice" = x"yes"; then
Expand Down

0 comments on commit 7f37668

Please sign in to comment.