In order to cross-compile gems with native extensions, like ffi, the top-level RbConfig constant must be modified to pretend to the target ruby architecture. To accomplish this, we patch the host ruby, however, this is fragile because the rubygems code keeps changing how it invokes the gem command. As a result we've shipped gems with unusable native extensions multiple times. I fixed this is https://github.com/puppetlabs/puppet-runtime/commit/58560cc96b67efe3a937b608b38ac35310b78f9c but it doesn't support rubygems > 3.5.10
Describe the Solution You Would Like
Ruby's mkmf introduced a --target-rbconfig option to satisfy this use case, see https://bugs.ruby-lang.org/issues/20345. Also the gem install and gem update commands recently added support for the --target-rbconfig option. In theory, this means we could eliminate patch-hostruby and instead do gem install --target-rbconfig fake.rb nokogiri. However, you'd need to use the latest ruby/rubygems to take advantage of the option.
Use Case
In order to cross-compile gems with native extensions, like
ffi
, the top-levelRbConfig
constant must be modified to pretend to the target ruby architecture. To accomplish this, we patch the host ruby, however, this is fragile because the rubygems code keeps changing how it invokes the gem command. As a result we've shipped gems with unusable native extensions multiple times. I fixed this is https://github.com/puppetlabs/puppet-runtime/commit/58560cc96b67efe3a937b608b38ac35310b78f9c but it doesn't support rubygems > 3.5.10Describe the Solution You Would Like
Ruby's mkmf introduced a
--target-rbconfig
option to satisfy this use case, see https://bugs.ruby-lang.org/issues/20345. Also thegem install
andgem update
commands recently added support for the--target-rbconfig
option. In theory, this means we could eliminatepatch-hostruby
and instead dogem install --target-rbconfig fake.rb nokogiri
. However, you'd need to use the latest ruby/rubygems to take advantage of the option.