ruby-changes:73824
From: Nobuyoshi <ko1@a...>
Date: Sat, 1 Oct 2022 15:59:05 +0900 (JST)
Subject: [ruby-changes:73824] 99735a8b29 (ruby_2_7): [Bug #19005] dynamic_lookup linker option in external libraries
https://git.ruby-lang.org/ruby.git/commit/?id=99735a8b29 From 99735a8b296cfda272f8dce6bd07af50cd97034e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 17 Sep 2022 12:09:34 +0900 Subject: [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. --- configure.ac | 22 +++++++++++++++++----- lib/mkmf.rb | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 2dde902653..4395a2b156 100644 --- a/configure.ac +++ b/configure.ac @@ -2773,14 +2773,26 @@ AS_IF([test "$with_dln_a_out" != yes], [ https://github.com/ruby/ruby/blob/trunk/configure.ac#L2773 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 ]) ]) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index bb2bdc01e9..27bc9e5986 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2557,6 +2557,7 @@ site-install-rb: install-rb https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L2557 $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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/