grpc: Undefined symbol `_ruby_abi_version` regression with Xcode 13 -> 14

What version of gRPC and what language are you using?

grpc: 1.48.0 language: ruby 2.7.6

What operating system (Linux, Windows,…) and version?

MacOS 12.6 Apple M1 chip

What runtime / compiler are you using (e.g. python version or version of gcc)

Xcode 14

What did you do?

gem install grpc -v 1.48.0

What did you expect to see?

Successfully install

What did you see instead?

Undefined symbols for architecture arm64:
  "_ruby_abi_version", referenced from:
     -exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [grpc_c.bundle] Error 1

Anything else we should know about your project / environment?

Worked correctly a few days ago with Xcode 13

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 30
  • Comments: 22 (5 by maintainers)

Commits related to this issue

Most upvoted comments

As mentioned in the Ruby issue, there are several possible workarounds until Ruby releases the patched versions for this (or gRPC fixes the underlying symbol issue):

  1. Recompile Ruby with DLDFLAGS="-Wl,-undefined,dynamic_lookup" set in the environment. Note that I don’t believe that setting the environment and run gem install grpc alone works because gRPC will default to using the Ruby DLDFLAGS. RbConfig::CONFIG['DLDFLAGS'] should show these flags:
irb(main):001:0> RbConfig::CONFIG['DLDFLAGS']
=> "-L/Users/stanhu/.asdf/installs/ruby/3.0.2/lib -L/opt/homebrew/opt/openssl@1.1/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress"
  1. With gem install:
gem install grpc -v 1.48.0 -- --with-ldflags="-Wl,-undefined,dynamic_lookup"
  1. Set bundle config:
bundle config build.grpc --with-ldflags="-Wl,-undefined,dynamic_lookup"

Explanation

As I mentioned in the Ruby bug report, XCode 14.0 now warns with the message when -Wl,undefined,dynamic_lookup is used:

% gcc -o test -Wl,-undefined,dynamic_lookup test.c
ld: warning: -undefined dynamic_lookup may not work with chained fixups

This warning was enough to make the Ruby configure script believe that those flags were no longer available on the system. -Wl,undefined,dynamic_lookup has long been the default everywhere, and most gems were not tested without those flags.

I believe the patches in https://github.com/ruby/ruby/pull/6441/files fix the configure script in Ruby to enable this linker option despite this warning message, which is why the latest 3.2.0 preview release works fine. The patches have been backported to 2.7 and up, but there is no official released version yet.

I’m still getting the same make error after running:

export DLDFLAGS=-Wl,-undefined,dynamic_lookup
gem install grpc -v 1.48.0

Just to follow up, the workaround didn’t work for us and we ended up downgrading grpc to 1.470

Downgrading grpc to 1.470 was the fix for me too! Thanks

Just to follow up, the workaround didn’t work for us and we ended up downgrading grpc to 1.470

I’m still getting the same make error after running:

export DLDFLAGS=-Wl,-undefined,dynamic_lookup
gem install grpc -v 1.48.0

I have been trying this workaround and it helped, I just needed to run it in the following sequence, so the grpc installation runs on clean environment I guess.

rbenv uninstall 3.0.4
rbenv install 3.0.4
export DLDFLAGS=-Wl,-undefined,dynamic_lookup
gem install grpc -v 1.50.0
bundle install

Yeah, 3.1.3, 3.2.0, and other versions still need the flags. Apparently the fix accidentally worked in 2.7.7 and 3.0.5. See my note in https://bugs.ruby-lang.org/issues/19005#note-25.

I proposed an upstream fix in https://github.com/ruby/ruby/pull/7086.

https://github.com/grpc/grpc/pull/31151 fixes this (not merged yet).

Same issue with M1 Pro Apple Silicon (arm64) but on ruby 3.1.0 . Uninstalling and installing again didnt solve

I had the same issue but with Ruby 3.0.4. After trying everything else, I fixed it by reinstalling Ruby:

rbenv uninstall 3.0.4
rbenv install 3.0.4

It’s also worth noting that I got the error while I was migrating from an older MacBook Pro with Intel arch to the new M1 Pro Apple Silicon (arm64).

@ethankhall found a workaround for this:

export DLDFLAGS=-Wl,-undefined,dynamic_lookup
# however you are installing... gem directly
gem install grpc
# or ...
bundle install

cc @ngan @noizwaves

3.1.3 still threw the error for me without the flags.