ffi: Failed to build gem native extension on macOS High Sierra

Getting this error when installing jekyll

  • ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin16]
  • Bundler version 1.16.6 (2018-10-05 commit f66c33467)
  • xcode-select --install is already updated
  • gcc -v :
Configured with: --prefix=/Users/me/Downloads/Xcode 10.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/me/Downloads/Xcode 10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
➜ website git:(master) gem install jekyll
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

    current directory: /Users/me/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ffi-1.9.25/ext/ffi_c
/Users/me/.rbenv/versions/2.4.2/bin/ruby -r ./siteconf20181022-70130-1j1h50c.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... yes
checking for ffi_call() in -lffi... yes
checking for ffi_closure_alloc()... no
checking for ffi_raw_call()... no
checking for shlwapi.h... no
checking for ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile

current directory: /Users/me/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ffi-1.9.25/ext/ffi_c
make "DESTDIR=" clean

current directory: /Users/me/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ffi-1.9.25/ext/ffi_c
make "DESTDIR="
Configuring libffi
clang: error: unsupported option '-print-multi-os-directory'
clang: error: no input files
cd "/Users/me/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ffi-1.9.25/ext/ffi_c/libffi-x86_64-darwin16" && /Users/me/Downloads/Xcode 10.app/Contents/Developer/usr/bin/make
/bin/sh: /Users/me/Downloads/Xcode: No such file or directory
make: *** ["/Users/me/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ffi-1.9.25/ext/ffi_c/libffi-x86_64-darwin16"/.libs/libffi_convenience.a] Error 127

make failed, exit code 2

Gem files will remain installed in /Users/me/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/ffi-1.9.25 for inspection.
Results logged to /Users/me/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/ffi-1.9.25/gem_make.out

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 26
  • Comments: 43

Most upvoted comments

The following worked for me:

brew reinstall libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
gem install jekyll

this worked for me on Mac

gem install ffi -v '1.13.1' -- --with-cflags="-Wno-error=implicit-function-declaration"

I spent many hours trying to install Jekyll on Mac OS 10.13.4 (High Sierra), I got this error :

Successfully installed bundler-2.0.1 Parsing documentation for bundler-2.0.1 Done installing documentation for bundler after 7 seconds Building native extensions. This could take a while… ERROR: Error installing jekyll: ERROR: Failed to build gem native extension. … Configuring libffi clang: error: unsupported option ‘-print-multi-os-directory’ clang: error: no input files … compiling AbstractMemory.c AbstractMemory.c:483:20: error: use of unknown builtin ‘__builtin_alloca_with_align’ [-Wimplicit-function-declaration] VALUE* rargv = ALLOCA_N(VALUE, argc + 1); … 8 warnings and 1 error generated. make: *** [AbstractMemory.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/perrotj/.gem/ruby/2.6.0/gems/ffi-1.10.0 for inspection. Results logged to /Users/perrotj/.gem/ruby/2.6.0/extensions/x86_64-darwin-17/2.6.0/ffi-1.10.0/gem_make.out 1 gem installed

The main cause of the build crash is the error below :

AbstractMemory.c:483:20: error: use of unknown builtin ‘__builtin_alloca_with_align’.

After a lot of google searches and a lot of tries nothing solves the issue (trying to install another version of ffi, etc…). Finally I realised that I had a version of Xcode that was not updated because High Sierra is too older to support the lastest version (Thank you Apple…). So I tried to enter the command gcc -v and I saw this line :

Apple LLVM version 8.0.0 (clang-800.0.38).

That was the problem ! Even If I installed the latest Xcode Command Line Developer Tools, the old gcc provided with Xcode was still used. I entered the command xcode-select -s /Library/Developer/CommandLineTools/ and the command gcc -v displayed the new version :

Apple LLVM version 10.0.0 (clang-1000.10.44.4)

With this version of gcc I could install Jekyll :

Successfully installed jekyll-3.8.5

I hope this thread could help someone 😉

Try to switch ruby to homebrew version.

brew install ruby brew link --overwrite ruby

If you need to have ruby first in your PATH run: echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

For compilers to find ruby you may need to set: export LDFLAGS="-L/usr/local/opt/ruby/lib" export CPPFLAGS="-I/usr/local/opt/ruby/include"

For pkg-config to find ruby you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

Thanks, @sujaysudheenda! This worked for me on MacOS Catalina:gem install ffi -v '1.9.18' -- --with-cflags="-Wno-error=implicit-function-declaration"

I was having this same issue where I could not install native extensions which would fail when trying to include “ruby/config.h”.

I believe it was because I was using the ruby version installed with Homebrew. After upgrading to a new version of Ruby with Homebrew, I saw the following helpful message from Homebrew

ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have ruby first in your PATH run:
  echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

For compilers to find ruby you may need to set:
  export LDFLAGS="-L/usr/local/opt/ruby/lib"
  export CPPFLAGS="-I/usr/local/opt/ruby/include"

For pkg-config to find ruby you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

Adding the following lines to my ~/.bash_profile fixed the issue for me:

export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include" 

Has anyone been able to get this to work on an Apple Developer Kit (Silicon) Mac running Big Sur? I’ve tried all of the things above and none of them have worked for me.

Same. It says it builds native extensions just fine, though. For instance (although I have tried all the flags above):

$ sudo gem install ffi -v '1.13.1'                                                       
Building native extensions. This could take a while...
Successfully installed ffi-1.13.1
Parsing documentation for ffi-1.13.1
Done installing documentation for ffi after 1 seconds
1 gem installed

FWIW, I’m getting an architecture error, which seems odd if it builds native extensions properly:

### Error


LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:6:in `rescue in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi.rb:3:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/ethon-0.12.0/lib/ethon.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:74:in `cdn_url?'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:36:in `create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/sources_manager.rb:21:in `find_or_create_source_with_url'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `map'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:177:in `sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1073:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:414:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.0/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

Same problem on Apple M1 while installing cocoapods.

I have tried all of the above solutions but none of them worked for me , please can anyone tell me what’s the real issue…

Building native extensions.  This could take a while...
ERROR:  Error installing cocoapods:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200331-53901-1d25i80.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_call_without_gvl()... yes
checking for ruby_native_thread_p()... yes
checking for ruby_thread_has_gvl_p()... yes
creating extconf.h
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/mkmf.log

current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
make "DESTDIR="
Configuring libffi
configure: error: in `/Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c/libffi-universal-darwin18':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
make: *** ["/Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c/libffi-universal-darwin18"/.libs/libffi_convenience.a] Error 1

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out

Here is the mkmf.log file pkg-config --exists libffi" package configuration for libffi is not found have_header: checking for ffi.h… -------------------- no

"xcrun clang -o conftest -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc " checked program was: /* begin */ 1: #include “ruby.h” 2: 3: int main(int argc, char *argv) 4: { 5: return 0; 6: } / end */

“xcrun clang -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -c conftest.c” conftest.c:3:10: fatal error: ‘ffi.h’ file not found #include <ffi.h> ^~~~~~~ 1 error generated. checked program was: /* begin / 1: #include “ruby.h” 2: 3: #include <ffi.h> / end */


find_header: checking for ffi.h in /usr/local/include,/usr/include/ffi… -------------------- no

“xcrun clang -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -c conftest.c” conftest.c:3:10: fatal error: ‘ffi.h’ file not found #include <ffi.h> ^~~~~~~ 1 error generated. checked program was: /* begin / 1: #include “ruby.h” 2: 3: #include <ffi.h> / end */

“xcrun clang -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -I/usr/local/include -c conftest.c” conftest.c:3:10: fatal error: ‘ffi.h’ file not found #include <ffi.h> ^~~~~~~ 1 error generated. checked program was: /* begin / 1: #include “ruby.h” 2: 3: #include <ffi.h> / end */

“xcrun clang -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -I/usr/include/ffi -c conftest.c” conftest.c:3:10: fatal error: ‘ffi.h’ file not found #include <ffi.h> ^~~~~~~ 1 error generated. checked program was: /* begin / 1: #include “ruby.h” 2: 3: #include <ffi.h> / end */


have_header: checking for shlwapi.h… -------------------- no

“xcrun clang -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -c conftest.c” conftest.c:3:10: fatal error: ‘shlwapi.h’ file not found #include <shlwapi.h> ^~~~~~~~~~~ 1 error generated. checked program was: /* begin / 1: #include “ruby.h” 2: 3: #include <shlwapi.h> / end */


have_func: checking for rb_thread_call_without_gvl()… -------------------- yes

"xcrun clang -o conftest -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc " conftest.c:13:57: error: use of undeclared identifier ‘rb_thread_call_without_gvl’ int t(void) { void ((volatile p)()); p = (void (()()))rb_thread_call_without_gvl; return !p; } ^ 1 error generated. checked program was: /* begin */ 1: #include “ruby.h” 2: 3: /top/ 4: extern int t(void); 5: int main(int argc, char *argv) 6: { 7: if (argc > 1000000) { 8: printf(“%p”, &t); 9: } 10: 11: return 0; 12: } 13: int t(void) { void ((volatile p)()); p = (void (()()))rb_thread_call_without_gvl; return !p; } / end */

"xcrun clang -o conftest -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc " checked program was: /* begin */ 1: #include “ruby.h” 2: 3: /top/ 4: extern int t(void); 5: int main(int argc, char *argv) 6: { 7: if (argc > 1000000) { 8: printf(“%p”, &t); 9: } 10: 11: return 0; 12: } 13: extern void rb_thread_call_without_gvl(); 14: int t(void) { rb_thread_call_without_gvl(); return 0; } / end */


have_func: checking for ruby_native_thread_p()… -------------------- yes

"xcrun clang -o conftest -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc " checked program was: /* begin */ 1: #include “ruby.h” 2: 3: /top/ 4: extern int t(void); 5: int main(int argc, char *argv) 6: { 7: if (argc > 1000000) { 8: printf(“%p”, &t); 9: } 10: 11: return 0; 12: } 13: int t(void) { void ((volatile p)()); p = (void (()()))ruby_native_thread_p; return !p; } / end */


have_func: checking for ruby_thread_has_gvl_p()… -------------------- yes

"xcrun clang -o conftest -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc " conftest.c:13:57: error: use of undeclared identifier ‘ruby_thread_has_gvl_p’ int t(void) { void ((volatile p)()); p = (void (()()))ruby_thread_has_gvl_p; return !p; } ^ 1 error generated. checked program was: /* begin */ 1: #include “ruby.h” 2: 3: /top/ 4: extern int t(void); 5: int main(int argc, char *argv) 6: { 7: if (argc > 1000000) { 8: printf(“%p”, &t); 9: } 10: 11: return 0; 12: } 13: int t(void) { void ((volatile p)()); p = (void (()()))ruby_thread_has_gvl_p; return !p; } / end */

"xcrun clang -o conftest -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Users/eapple/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc " checked program was: /* begin */ 1: #include “ruby.h” 2: 3: /top/ 4: extern int t(void); 5: int main(int argc, char *argv) 6: { 7: if (argc > 1000000) { 8: printf(“%p”, &t); 9: } 10: 11: return 0; 12: } 13: extern void ruby_thread_has_gvl_p(); 14: int t(void) { ruby_thread_has_gvl_p(); return 0; } / end */


extconf.h is: /* begin / 1: #ifndef EXTCONF_H 2: #define EXTCONF_H 3: #define HAVE_RB_THREAD_CALL_WITHOUT_GVL 1 4: #define HAVE_RUBY_NATIVE_THREAD_P 1 5: #define HAVE_RUBY_THREAD_HAS_GVL_P 1 6: #define HAVE_FFI_PREP_CIF_VAR 1 7: #define USE_INTERNAL_LIBFFI 1 8: #endif / end */

The following worked for me:

brew reinstall libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
gem install jekyll

@ffleming I am seeing all this success using your steps above however I am not one of them 😦

Admittedly I am new to working with Ruby etc and I am hoping that someone here might be able to help me. I am trying to install Jekyll on Catalina (ver 10.15.4) and have Ruby 2.7.0 installed.

When I run “gem install Jekyll” or “gem install --user-install bundler jekyll” (as per the Jekyll site, I get the following:

`gem install jekyll

Building native extensions. This could take a while… ERROR: Error installing jekyll: ERROR: Failed to build gem native extension.

current directory: /usr/local/lib/ruby/gems/2.7.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser

/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/2.7.0/lib/ruby/2.7.0 -r ./siteconf20200327-21516-1lv9xo4.rb extconf.rb creating Makefile

current directory: /usr/local/lib/ruby/gems/2.7.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser make “DESTDIR=” clean /Library/Ruby/Gems/2.6.0/gems/make-0.3.1/bin/make:4:in <top (required)>': undefined local variable or method make’ for main:Object (NameError) from /usr/local/bin/make:23:in load' from /usr/local/bin/make:23:in <main>’

current directory: /usr/local/lib/ruby/gems/2.7.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser make “DESTDIR=” /Library/Ruby/Gems/2.6.0/gems/make-0.3.1/bin/make:4:in <top (required)>': undefined local variable or method make’ for main:Object (NameError) from /usr/local/bin/make:23:in load' from /usr/local/bin/make:23:in <main>’

make failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.7.0/gems/http_parser.rb-0.6.0 for inspection. Results logged to /usr/local/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/http_parser.rb-0.6.0/gem_make.out`

Am not sure if I am missing some parameters that I need to enter or dependencies missing. Any help for this newbie would be much appreciated.

Thanks in advance.

I’m on Mojave and @ffleming’s solution fixed the issue for me - thanks!

Thanks, @sujaysudheenda 🙌

This worked for me on MacOS Catalina: gem install ffi -v ‘1.9.23’ – --with-cflags=“-Wno-error=implicit-function-declaration”

In our case we install Ruby 2.7 using rvm and update the PATH

rvm install ruby-2.7.1
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

Remember compilers and pkg-config:

export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

I hope this can help someone 😃

Has anyone been able to get this to work on an Apple Developer Kit (Silicon) Mac running Big Sur? I’ve tried all of the things above and none of them have worked for me.

Try to switch ruby to homebrew version.

brew install ruby brew link --overwrite ruby

If you need to have ruby first in your PATH run: echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

For compilers to find ruby you may need to set: export LDFLAGS="-L/usr/local/opt/ruby/lib" export CPPFLAGS="-I/usr/local/opt/ruby/include"

For pkg-config to find ruby you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

now retrieve your env shell . ~/.zshrc

The following worked for me:

brew reinstall libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
gem install jekyll

Thanks @ffleming ! This worked for me on 10.13.6

@ffleming Likewise works for me on Catalina - thanks a lot, saved me having to downgrade after a couple of hours of searching.

cannot install not ffi nor jekyll on my mac

sudo gem install jekyll
Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c
/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0 -r ./siteconf20190511-41280-u67z6u.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c
make "DESTDIR="
Configuring libffi
clang: error: unsupported option '-print-multi-os-directory'
clang: error: no input files
cd "/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi-x86_64-darwin18" && /Library/Developer/CommandLineTools/usr/bin/make
/Library/Developer/CommandLineTools/usr/bin/make 'AR_FLAGS=' 'CC_FOR_BUILD=' 'CFLAGS=-Wall -fexceptions' 'CXXFLAGS=-g -O2' 'CFLAGS_FOR_BUILD=' 'CFLAGS_FOR_TARGET=' 'INSTALL=/usr/local/bin/ginstall -c' 'INSTALL_DATA=/usr/local/bin/ginstall -c -m 644' 'INSTALL_PROGRAM=/usr/local/bin/ginstall -c' 'INSTALL_SCRIPT=/usr/local/bin/ginstall -c' 'JC1FLAGS=' 'LDFLAGS=' 'LIBCFLAGS=' 'LIBCFLAGS_FOR_TARGET=' 'MAKE=/Library/Developer/CommandLineTools/usr/bin/make' 'MAKEINFO=/bin/sh /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/missing makeinfo ' 'PICFLAG=' 'PICFLAG_FOR_TARGET=' 'RUNTESTFLAGS=' 'SHELL=/bin/sh' 'exec_prefix=/usr/local' 'infodir=/usr/local/share/info' 'libdir=/usr/local/lib' 'mandir=/usr/local/share/man' 'prefix=/usr/local' 'AR=ar' 'AS=as' 'CC=clang' 'CXX=g++' 'LD=ld' 'NM=/usr/bin/nm -B' 'RANLIB=ranlib' 'DESTDIR=' all-recursive
Making all in include
make[3]: Nothing to be done for `all'.
Making all in testsuite
make[3]: Nothing to be done for `all'.
Making all in man
make[3]: Nothing to be done for `all'.
/bin/sh ./libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src   -Wall -fexceptions -c -o src/prep_cif.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/prep_cif.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -Wall -fexceptions -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/prep_cif.c  -fno-common -DPIC -o src/.libs/prep_cif.o
/bin/sh ./libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src   -Wall -fexceptions -c -o src/types.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/types.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -Wall -fexceptions -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/types.c  -fno-common -DPIC -o src/.libs/types.o
/bin/sh ./libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src   -Wall -fexceptions -c -o src/raw_api.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/raw_api.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -Wall -fexceptions -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/raw_api.c  -fno-common -DPIC -o src/.libs/raw_api.o
/bin/sh ./libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src   -Wall -fexceptions -c -o src/java_raw_api.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/java_raw_api.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -Wall -fexceptions -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/java_raw_api.c  -fno-common -DPIC -o src/.libs/java_raw_api.o
/bin/sh ./libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src   -Wall -fexceptions -c -o src/closures.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/closures.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -Wall -fexceptions -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/closures.c  -fno-common -DPIC -o src/.libs/closures.o
/bin/sh ./libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src   -Wall -fexceptions -c -o src/x86/ffi64.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/ffi64.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -Wall -fexceptions -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/ffi64.c  -fno-common -DPIC -o src/x86/.libs/ffi64.o
/bin/sh ./libtool    --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src  -c -o src/x86/unix64.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/unix64.S
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/unix64.S  -fno-common -DPIC -o src/x86/.libs/unix64.o
/bin/sh ./libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src   -Wall -fexceptions -c -o src/x86/ffiw64.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/ffiw64.c
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -Wall -fexceptions -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/ffiw64.c  -fno-common -DPIC -o src/x86/.libs/ffiw64.o
/bin/sh ./libtool    --mode=compile clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src  -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src  -c -o src/x86/win64.lo /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/win64.S
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -I. -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/include -Iinclude -I/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src -c /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi/src/x86/win64.S  -fno-common -DPIC -o src/x86/.libs/win64.o
/bin/sh ./libtool  --tag=CC   --mode=link clang  -Wall -fexceptions   -o libffi_convenience.la  src/prep_cif.lo src/types.lo src/raw_api.lo src/java_raw_api.lo src/closures.lo   src/x86/ffi64.lo src/x86/unix64.lo src/x86/ffiw64.lo src/x86/win64.lo
libtool: link: ar cru .libs/libffi_convenience.a src/.libs/prep_cif.o src/.libs/types.o src/.libs/raw_api.o src/.libs/java_raw_api.o src/.libs/closures.o src/x86/.libs/ffi64.o src/x86/.libs/unix64.o src/x86/.libs/ffiw64.o src/x86/.libs/win64.o
/usr/local/Cellar/cctools/855/bin/ranlib: object: .libs/libffi_convenience.a(prep_cif.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make[3]: *** [libffi_convenience.la] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** ["/usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/ext/ffi_c/libffi-x86_64-darwin18"/.libs/libffi_convenience.a] Error 2

make failed, exit code 2

Gem files will remain installed in /usr/local/lib/ruby/gems/2.6.0/gems/ffi-1.10.0 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/ffi-1.10.0/gem_make.out

gem_make.out.txt

I am having a similar ffi gem compile error. Has anyone found a solution?

Fetching ffi 1.9.23
Installing ffi 1.9.23 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.                                                                                                         

    current directory: /Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c
/Users/nroose/.rvm/rubies/ruby-2.4.3/bin/ruby -r ./siteconf20190128-53696-1yryoe1.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile

current directory: /Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c
make "DESTDIR=" clean

current directory: /Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c
make "DESTDIR="
mkdir -p "/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c"/libffi-i386; (if [ ! -f
"/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c/libffi"/configure ]; then echo "Running autoreconf for libffi"; cd
"/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c/libffi" && /bin/sh /Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c/libffi/autogen.sh >
/dev/null; fi); (if [ ! -f "/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c"/libffi-i386/Makefile ]; then echo "Configuring libffi for i386"; cd
"/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c"/libffi-i386 && env CC=" gcc" CFLAGS="-arch i386 " LDFLAGS="-arch i386"
"/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c/libffi"/configure --disable-static --with-pic=yes --disable-dependency-tracking --disable-docs
--host=i386-apple-darwin > /dev/null; fi); env MACOSX_DEPLOYMENT_TARGET=10.4 /Applications/Xcode.app/Contents/Developer/usr/bin/make -C
"/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c"/libffi-i386
Configuring libffi for i386
configure: error: in `/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c/libffi-i386':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[1]: *** No targets specified and no makefile found.  Stop.
make: *** ["/Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23/ext/ffi_c"/libffi-i386/.libs/libffi_convenience.a] Error 2

make failed, exit code 2

Gem files will remain installed in /Users/nroose/.rvm/gems/ruby-2.4.3/gems/ffi-1.9.23 for inspection.
Results logged to /Users/nroose/.rvm/gems/ruby-2.4.3/extensions/x86_64-darwin-18/2.4.0/ffi-1.9.23/gem_make.out

An error occurred while installing ffi (1.9.23), and Bundler cannot continue.                                                                                              
Make sure that `gem install ffi -v '1.9.23' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  selenium-webdriver was resolved to 3.6.0, which depends on
    childprocess was resolved to 0.9.0, which depends on
      ffi

Same error here, though I’m on macOS 10.14.1 Mojave. Trying to bundle install a jekyll theme, and I get:


current directory:
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
/Users/foobar/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20181118-49440-k8mjki.rb
extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile

current directory:
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR=" clean

current directory:
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR="
Running autoreconf for libffi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4 --output=aclocal.m4t
Can't exec "aclocal": No such file or directory at
/usr/local/Cellar/autoconf/2.69/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
make: ***
["/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-darwin18"/.libs/libffi_convenience.a]
Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21 for inspection.
Results logged to
/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/ffi-1.9.21/gem_make.out

An error occurred while installing ffi (1.9.21), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.21' --source 'https://rubygems.org/'` succeeds
before bundling.

In Gemfile:
  html-proofer was resolved to 3.8.0, which depends on
    typhoeus was resolved to 1.3.0, which depends on
      ethon was resolved to 0.11.0, which depends on
        ffi

So, I run: gem install ffi -v '1.9.21' --source 'https://rubygems.org/' which leads to:

Building native extensions. This could take a while...
ERROR:  Error installing ffi:
	ERROR: Failed to build gem native extension.

    current directory: /Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
/Users/foobar/.rbenv/versions/2.5.1/bin/ruby -r ./siteconf20181118-49855-1qr40it.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile

current directory: /Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR=" clean

current directory: /Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR="
Running autoreconf for libffi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4 --output=aclocal.m4t
Can't exec "aclocal": No such file or directory at /usr/local/Cellar/autoconf/2.69/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
make: *** ["/Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-darwin18"/.libs/libffi_convenience.a] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/ffi-1.9.21 for inspection.
Results logged to /Users/foobar/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/ffi-1.9.21/gem_make.out```