Skip to content

Commit

Permalink
[Bug #19005] dynamic_lookup linker option in external libraries
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nobu authored and hsbt committed Sep 26, 2022
1 parent 13691ad commit 0525a1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
22 changes: 17 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2773,14 +2773,26 @@ AS_IF([test "$with_dln_a_out" != yes], [
AS_IF([test "$rb_cv_dlopen" = yes], [
AS_CASE(["$target_os"],
[darwin*], [
AC_SUBST(ADDITIONAL_DLDFLAGS, "")
for flag in \
"-multiply_defined suppress" \
"-undefined dynamic_lookup" \
; do
test "x${linker_flag}" = x || flag="${linker_flag}`echo ${flag} | tr ' ' ,`"
RUBY_TRY_LDFLAGS([$flag], [], [flag=])
AS_IF([test "x$flag" != x], [
RUBY_APPEND_OPTIONS(DLDFLAGS, [$flag])
])
test "x${linker_flag}" = x || flag="${linker_flag}`echo ${flag} | tr ' ' ,`"
RUBY_TRY_LDFLAGS([$flag], [], [$flag=])
AS_IF([test x"$flag" = x], [continue])
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
])
])
Expand Down
1 change: 1 addition & 0 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,7 @@ def init_mkmf(config = CONFIG, rbconfig = RbConfig::CONFIG)
$INCFLAGS << " -I$(hdrdir)/ruby/backward" unless $extmk
$INCFLAGS << " -I$(hdrdir) -I$(srcdir)"
$DLDFLAGS = with_config("dldflags", arg_config("DLDFLAGS", config["DLDFLAGS"])).dup
config_string("ADDITIONAL_DLDFLAGS") {|flags| $DLDFLAGS << " " << flags} unless $extmk
$LIBEXT = config['LIBEXT'].dup
$OBJEXT = config["OBJEXT"].dup
$EXEEXT = config["EXEEXT"].dup
Expand Down

0 comments on commit 0525a1e

Please sign in to comment.