Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fail on MacOS M1, ruby 3.1.0 #115

Closed
aurmartin opened this issue Dec 6, 2022 · 9 comments
Closed

Build fail on MacOS M1, ruby 3.1.0 #115

aurmartin opened this issue Dec 6, 2022 · 9 comments
Assignees

Comments

@aurmartin
Copy link

Version:

  • chef: 18.0.194
  • ffi-yajl: 2.4.0

Environment:

  • OS: MacOS M1 12.6.1
  • Ruby: 3.1.0
  • Bundle: 2.3.17

Scenario:

I'm trying to build chef which depend on ffi-yajl.

I tried installing it directly with gem install chef, or bundle install, or gem install ffi-yajl

Steps to Reproduce:

gem install ffi-yajl

Expected Result:

Install the gem ffi-yajl.

Actual Result:

Build error:

ERROR: Failed to build gem native extension.

    current directory: /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/ffi-yajl-2.4.0/ext/ffi_yajl/ext/encoder
/Users/aurelien/.rvm/rubies/ruby-3.1.0/bin/ruby -I /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0 -r ./siteconf20221206-12086-a3wnsh.rb extconf.rb
-I/Users/aurelien/.rvm/gems/ruby-3.1.0/gems/libyajl2-2.1.0/lib/libyajl2/vendored-libyajl2/include -O3 -I/opt/homebrew/opt/libyaml/include
-I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include $(cflags)
-fno-common -pipe
-L/Users/aurelien/.rvm/gems/ruby-3.1.0/gems/libyajl2-2.1.0/lib/libyajl2/vendored-libyajl2/lib -L. -L/opt/homebrew/opt/libyaml/lib
-L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -fstack-protector-strong
checking for yajl/yajl_tree.h... yes
creating Makefile

current directory: /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/ffi-yajl-2.4.0/ext/ffi_yajl/ext/encoder
make DESTDIR\= clean

current directory: /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/ffi-yajl-2.4.0/ext/ffi_yajl/ext/encoder
make DESTDIR\=
compiling encoder.c
encoder.c:94:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/Users/aurelien/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
encoder.c:110:13: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  int len = RSTRING_LEN(str);
      ~~~   ^~~~~~~~~~~~~~~~
/Users/aurelien/.rvm/rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
encoder.c:262:30: warning: passing 'const char[1]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    gen_cstring(rb_yajl_gen, "", sizeof("")-1);
                             ^~
encoder.c:79:44: note: passing argument to parameter 'cptr' here
VALUE gen_cstring(VALUE rb_yajl_gen, char *cptr, int len) {
                                           ^
encoder.c:272:30: warning: passing 'const char[5]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    gen_cstring(rb_yajl_gen, "true", sizeof("true")-1);
                             ^~~~~~
encoder.c:79:44: note: passing argument to parameter 'cptr' here
VALUE gen_cstring(VALUE rb_yajl_gen, char *cptr, int len) {
                                           ^
encoder.c:282:30: warning: passing 'const char[6]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    gen_cstring(rb_yajl_gen, "false", sizeof("false")-1);
                             ^~~~~~~
encoder.c:79:44: note: passing argument to parameter 'cptr' here
VALUE gen_cstring(VALUE rb_yajl_gen, char *cptr, int len) {
                                           ^
encoder.c:307:14: warning: unused function 'rb_cBignum_ffi_yajl' [-Wunused-function]
static VALUE rb_cBignum_ffi_yajl(VALUE self, VALUE rb_yajl_gen, VALUE state) {
             ^
6 warnings generated.
linking shared-object ffi_yajl/ext/encoder.bundle
Undefined symbols for architecture arm64:
  "_yajl_gen_alloc", referenced from:
      _mEncoder_do_yajl_encode in encoder.o
  "_yajl_gen_array_close", referenced from:
      _gen_array_close in encoder.o
  "_yajl_gen_array_open", referenced from:
      _gen_array_open in encoder.o
  "_yajl_gen_bool", referenced from:
      _gen_true in encoder.o
      _gen_false in encoder.o
  "_yajl_gen_config", referenced from:
      _mEncoder_do_yajl_encode in encoder.o
  "_yajl_gen_free", referenced from:
      _mEncoder_do_yajl_encode in encoder.o
  "_yajl_gen_get_buf", referenced from:
      _mEncoder_do_yajl_encode in encoder.o
  "_yajl_gen_map_close", referenced from:
      _gen_map_close in encoder.o
  "_yajl_gen_map_open", referenced from:
      _gen_map_open in encoder.o
  "_yajl_gen_null", referenced from:
      _gen_null in encoder.o
  "_yajl_gen_number", referenced from:
      _gen_number in encoder.o
  "_yajl_gen_string", referenced from:
      _gen_cstring in encoder.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [encoder.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/ffi-yajl-2.4.0 for inspection.
Results logged to /Users/aurelien/.rvm/gems/ruby-3.1.0/extensions/arm64-darwin-21/3.1.0/ffi-yajl-2.4.0/gem_make.out

  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:44:in `block in make'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in `each'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in `make'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/tempfile.rb:317:in `open'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in build_extensions'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
  /Users/aurelien/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/rubygems/installer.rb:847:in `build_extensions'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/source/rubygems.rb:209:in `install'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/installer/gem_installer.rb:54:in `install'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:62:in `apply_func'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:57:in `block in process_queue'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:54:in `loop'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:54:in `process_queue'
  /Users/aurelien/.rvm/gems/ruby-3.1.0/gems/bundler-2.3.17/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing ffi-yajl (2.4.0), and Bundler cannot continue.

In Gemfile:
  chef-bin was resolved to 18.0.194, which depends on
    chef was resolved to 18.0.194, which depends on
      chef-zero was resolved to 15.0.11, which depends on
        ffi-yajl
@aurmartin aurmartin added the Status: Untriaged An issue that has yet to be triaged. label Dec 6, 2022
@maschiltz
Copy link

I'm having this same issue, anyone been able to figure this one out?

@maschiltz
Copy link

using Mac M1, I was able to get it to install by doing:

gem install ffi-yajl -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

@bdwyertech
Copy link

Same on a regular Intel MBP running Ventura

using Mac M1, I was able to get it to install by doing:

gem install ffi-yajl -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

@aurmartin
Copy link
Author

using Mac M1, I was able to get it to install by doing:

gem install ffi-yajl -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

Thanks, this worked for me !

This was referenced Jan 27, 2023
@skull-squadron
Copy link

skull-squadron commented Jan 27, 2023

cc @aurmartin @maschiltz

Can't test it with specific_install due to monkeypatching gemspecs, but I'll submit another PR for that.

@skull-squadron
Copy link

(I didn't mean to close #117 while cleaning up my gh.)

@jacquelin-doran
Copy link

For those getting the fail on a bundle install,

bundle.config build.fyi-yajl --with-ldflags="-Wl,-undefined,dynamic_lookup"

works for a successful 'bundle complete' and updated gemfile.lock.

@tpowell-progress
Copy link
Contributor

#114 is merged to deal with this, but it breaks on Windows pipelines for Chef, so if you're looking for inclusion there, it's still TBD

@tpowell-progress
Copy link
Contributor

ffi-yajl 2.6 has been [re-]released and this should be resolved now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants