[Bug #19005] dynamic_lookup linker option in external libraries

The warning against `-undefined dynamic_lookup` is just a warning yet,
and many gems seem to pay no attention to warnings.  Until it fails
actually, keep it as a migration path, except for standard extension
libraries and bundled extension gems.
This commit is contained in:
Nobuyoshi Nakada 2022-09-17 12:09:34 +09:00 committed by usa
parent 9188c5dd6d
commit 99735a8b29
2 changed files with 18 additions and 5 deletions

View file

@ -2773,14 +2773,26 @@ AS_IF([test "$with_dln_a_out" != yes], [
AS_IF([test "$rb_cv_dlopen" = yes], [ AS_IF([test "$rb_cv_dlopen" = yes], [
AS_CASE(["$target_os"], AS_CASE(["$target_os"],
[darwin*], [ [darwin*], [
AC_SUBST(ADDITIONAL_DLDFLAGS, "")
for flag in \ for flag in \
"-multiply_defined suppress" \ "-multiply_defined suppress" \
"-undefined dynamic_lookup" \
; do ; do
test "x${linker_flag}" = x || flag="${linker_flag}`echo ${flag} | tr ' ' ,`" test "x${linker_flag}" = x || flag="${linker_flag}`echo ${flag} | tr ' ' ,`"
RUBY_TRY_LDFLAGS([$flag], [], [flag=]) RUBY_TRY_LDFLAGS([$flag], [], [$flag=])
AS_IF([test "x$flag" != x], [ AS_IF([test x"$flag" = x], [continue])
RUBY_APPEND_OPTIONS(DLDFLAGS, [$flag])
]) AC_MSG_CHECKING([whether $flag is accepted for bundle])
: > conftest.c
AS_IF([${LDSHARED/'$(CC)'/$CC} -o conftest.bundle $flag conftest.c >/dev/null 2>conftest.err &&
test ! -s conftest.err], [
AC_MSG_RESULT([yes])
RUBY_APPEND_OPTIONS(DLDFLAGS, [$flag])
], [
AC_MSG_RESULT([no])
RUBY_APPEND_OPTIONS(ADDITIONAL_DLDFLAGS, [$flag])
])
rm -fr conftest.*
done done
]) ])
]) ])

View file

@ -2557,6 +2557,7 @@ site-install-rb: install-rb
$INCFLAGS << " -I$(hdrdir)/ruby/backward" unless $extmk $INCFLAGS << " -I$(hdrdir)/ruby/backward" unless $extmk
$INCFLAGS << " -I$(hdrdir) -I$(srcdir)" $INCFLAGS << " -I$(hdrdir) -I$(srcdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup $DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
config_string("ADDITIONAL_DLDFLAGS") {|flags| $DLDFLAGS << " " << flags} unless $extmk
$LIBEXT = config['LIBEXT'].dup $LIBEXT = config['LIBEXT'].dup
$OBJEXT = config["OBJEXT"].dup $OBJEXT = config["OBJEXT"].dup
$EXEEXT = config["EXEEXT"].dup $EXEEXT = config["EXEEXT"].dup