[ruby-core:111713] [Ruby master Bug#19005] Ruby interpreter compiled XCode 14 cannot build some native gems on macOS

Issue #19005 has been updated by stanhu (Stan Hu). I think this problem was "accidentally" fixed in Ruby 2.7.7 and 3.0.5, but it's not working in Ruby 3.1.3 and up due to a simple removal of a dollar sign (https://github.com/ruby/ruby/commit/667aa81219ca080c0a4b9f97d29bb3221bd08a33). In Ruby 3.1.3, I'm not seeing the `ADDITIONAL_DLDFLAGS` set with `-Wl,-undefined,dynamic_lookup`: ```ruby irb(main):001:0> RUBY_VERSION => "3.1.3" irb(main):002:0> RbConfig::CONFIG['ADDITIONAL_DLDFLAGS'] => "" ``` Whereas 3.0.5 has this: ```ruby irb(main):001:0> RUBY_VERSION => "3.0.5" irb(main):002:0> RbConfig::CONFIG['ADDITIONAL_DLDFLAGS'] => "-Wl,-undefined,dynamic_lookup" ``` If I look at the `./configure` output in Ruby 3.0.5 or 2.7.7, I see something like this: ``` checking whether -Wl,-undefined,dynamic_lookup is accepted as LDFLAGS... ./configure: line 29806: -Wl,-undefined,dynamic_lookup=: command not found checking whether -Wl,-undefined,dynamic_lookup is accepted for bundle... no ``` But with 3.1.3 and up, the `LDFLAGS` check is a straight no: ``` checking whether -Wl,-undefined,dynamic_lookup is accepted as LDFLAGS... no ``` The `configure` output with Ruby 3.0.5 looks like: ``` if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "${msg_result_yes}yes${msg_reset}" >&6 ; } else $as_nop $flag= { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "${msg_result_no}no${msg_reset}" >&6 ; } fi ``` The failing line in question is `$flag=`. In Ruby 3.1.3 and up, it appears `$flag=` has been replaced with `flag=` due to https://github.com/ruby/ruby/commit/667aa81219ca080c0a4b9f97d29bb3221bd08a33: ``` if ac_fn_c_try_link "$LINENO" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "${msg_result_yes}yes${msg_reset}" >&6 ; } else $as_nop flag= { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "${msg_result_no}no${msg_reset}" >&6 ; } fi ``` ---------------------------------------- Bug #19005: Ruby interpreter compiled XCode 14 cannot build some native gems on macOS https://bugs.ruby-lang.org/issues/19005#change-101110 * Author: stanhu (Stan Hu) * Status: Closed * Priority: Normal * ruby -v: ruby 2.7.6p219 (2022-04-12 revision 44c8bfa984) [arm64-darwin21] * Backport: 2.7: DONE, 3.0: DONE, 3.1: DONE ---------------------------------------- This seems related to https://bugs.ruby-lang.org/issues/18912 and https://bugs.ruby-lang.org/issues/18981 . Steps to reproduce: 1. Upgrade to XCode 14. 2. Compile a new Ruby interpreter. I used the version provided in https://github.com/ruby/ruby/pull/6297 with `./configure --prefix=/tmp/ruby --with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --enable-shared`. 3. Confirm that `-Wl,-undefined,dynamic_lookup` is no longer available: ``` irb(main):001:0> RbConfig::CONFIG['DLDFLAGS'] => "-Wl,-multiply_defined,suppress" ``` 4. Ran `gem install pg_query` (`gem install ffi-yajl` will also fail). Error: ``` linking shared-object pg_query/pg_query.bundle Undefined symbols for architecture arm64: "Init_pg_query", referenced from: -exported_symbol[s_list] command line option (maybe you meant: _Init_pg_query) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` I can workaround the problem by doing: ``` gem install pg_query -- --with-ldflags="-Wl,-undefined,dynamic_lookup" ``` -- https://bugs.ruby-lang.org/
participants (1)
-
stanhu (Stan Hu)