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

undefined symbol: ffi_prep_cif_machdep on Raspbian 11 #1016

Open
rgaufman opened this issue Mar 22, 2023 · 4 comments
Open

undefined symbol: ffi_prep_cif_machdep on Raspbian 11 #1016

rgaufman opened this issue Mar 22, 2023 · 4 comments

Comments

@rgaufman
Copy link

rgaufman commented Mar 22, 2023

I did bundle package --all on my Mac 13.2.1 Apple Silicon, this worked correctly.

When I run bundle install on the Raspberry Pi however, using the local vendor cache, I get this:

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

    current directory: /usr/local/lib/ruby/gems/3.1.0/gems/libusb-0.6.4/ext
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.1.0 -r ./siteconf20230322-10162-mu22sz.rb extconf.rb
Ignoring libusb-0.6.4 because its extensions are not built. Try: gem pristine libusb --version 0.6.4
/usr/local/bin/ruby: symbol lookup error: /usr/local/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.so: undefined symbol: ffi_prep_cif_machdep

extconf failed, exit code 127

Gem files will remain installed in /usr/local/lib/ruby/gems/3.1.0/gems/libusb-0.6.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.1.0/extensions/armv7l-linux-eabihf/3.1.0-static/libusb-0.6.4/gem_make.out

This used to work fine previously, but I loaded a few units now with the latest image of Raspbian OS 11 and I am suddenly getting this error and tearing my hair out trying to figure it out.

Strangely, if I reinstall ffi, it works:

$ gem install ffi
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Parsing documentation for ffi-1.15.5
Done installing documentation for ffi after 5 seconds
1 gem installed
$ gem install libusb
Building native extensions. This could take a while...
Successfully installed libusb-0.6.4
Parsing documentation for libusb-0.6.4
Done installing documentation for libusb after 1 seconds
1 gem installed

So there seems to be a specific problem with ffi when doing bundle package? Any ideas?

@rgaufman rgaufman changed the title undefined symbol: ffi_prep_cif_machdep running bundle on Raspbian 11 undefined symbol: ffi_prep_cif_machdep on Raspbian 11 Mar 22, 2023
@larskanis
Copy link
Member

undefined symbol: ffi_prep_cif_machdep looks like the file /usr/local/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.so was compiled on Macos, where you bundled your package. I can not say why this happens, but I know from experience that cross platform usage of bundle package often fails.

You should run the bundle package on the target platform; the Raspberry Pi.

@rgaufman
Copy link
Author

rgaufman commented Mar 22, 2023

I've been using bundle package for years now with so far good success - this is on my M1 Macbook to build gems for x86_64 and armv7.

I wonder what changed for this to suddenly cause problems. Do you have any rough idea what this could be to point me in the right direction?

@rgaufman
Copy link
Author

I now have another Raspberry Pi where re-installing ffi does not help:

$ rm -R /usr/local/lib/ruby/gems/3.1.0/gems/ffi-1.15.5
$ gem install libusb
Fetching ffi-1.15.5.gem
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Building native extensions. This could take a while...
ERROR:  Error installing libusb:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/3.1.0/gems/libusb-0.6.4/ext
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.1.0 -r ./siteconf20230327-26079-gt026i.rb extconf.rb
/usr/local/bin/ruby: symbol lookup error: /usr/local/lib/ruby/gems/3.1.0/gems/ffi-1.15.5/lib/ffi_c.so: undefined symbol: ffi_prep_cif_machdep

extconf failed, exit code 127

Gem files will remain installed in /usr/local/lib/ruby/gems/3.1.0/gems/libusb-0.6.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.1.0/extensions/armv7l-linux-eabihf/3.1.0-static/libusb-0.6.4/gem_make.out
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [armv7l-linux-eabihf]
$ gem -v
3.3.7
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

Any ideas?

@rgaufman
Copy link
Author

Not sure why this is happening, but this appears to work as a workaround:

gem install ffi -- --enable-system-libffi

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

2 participants