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

(PA-5640) Fix up Solaris' ffi gem #700

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion configs/components/_base-rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{settings[:ruby_bindir]}):$(shell cygpath -u #{settings[:bindir]}):/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:$(PATH)"
end

if name =~ /ffi/ && settings[:ruby_version].to_f >= 3.2 && platform.is_solaris?
extra_install_settings = ' -- --enable-system-libffi'
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The libffi thing has confused me for awhile, but I think I'm starting to understand.

Since libffi is a runtime component (as of Ruby 3.2), then we're building and installing it as part of the runtime build. So when components that depend on libffi, like ruby, etc, we should (in general) build against the same version built.

For example, on Solaris 11 Intel, we're installing libffi-dev from OpenCSW, currently version 3.2.1 and we compile against that. But we ship libffi version 3.4.3. Those differences could introduce runtime failures.

Ideally, I think we want to specify the libffi dependency, something like:

gem install ffi-1.15.5.gem --local -- --with-libffi-dir=/opt/puppetlabs/puppet

I think a better option is to tell the gem to use pkg-config to resolve dependencies, something like:

PKG_CONFIG_PATH=/opt/puppetlabs/puppet/lib/pkgconfig:$PKG_CONFIG_PATH gem install ffi-1.15.5.gem --local

Similar to what's being done in https://github.com/ffi/ffi/blob/a480ff6db209713fc73a3dbbb4f1c31a376d6e6a/.github/workflows/ci.yml#L34

I think this might solve the issue @AriaXLi was seeing with the ffi gem on macOS 12 ARM as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying out the PKG_CONFIG_PATH suggestion, if that builds and completes I'll close this and put up a new PR with that work.

# When cross-compiling, we can't use the rubygems we just built.
# Instead we use the host gem installation and override GEM_HOME. Yay?
pkg.environment "GEM_HOME", settings[:gem_home]
Expand All @@ -38,5 +41,5 @@
pkg.mirror("#{settings[:buildsources_url]}/#{name}-#{version}.gem")

pkg.install do
"#{settings[:gem_install]} #{name}-#{version}.gem"
"#{settings[:gem_install]} #{name}-#{version}.gem#{extra_install_settings}"
end
3 changes: 2 additions & 1 deletion configs/components/rubygem-ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
end
end

if platform.name =~ /solaris-11-i386/
# With Ruby 3.2 on Solaris-11 we install OpenSCW's libffi, no need to copy over the system libffi
if platform.name =~ /solaris-11-i386/ && rb_major_minor_version < 3.2
pkg.install_file "/usr/lib/libffi.so.5.0.10", "#{settings[:libdir]}/libffi.so"
elsif platform.name =~ /solaris-10-i386/
pkg.install_file "/opt/csw/lib/libffi.so.6", "#{settings[:libdir]}/libffi.so.6"
Expand Down
Loading