-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add --target-rbconfig
option to gem install
and gem update
commands
#7628
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
Add --target-rbconfig
option to gem install
and gem update
commands
#7628
Conversation
57df8bd
to
97fa3ff
Compare
394788b
to
7868c67
Compare
86a8474
to
132178c
Compare
require "tempfile" | ||
require "fileutils" | ||
|
||
if target_rbconfig.path | ||
warn "--target-rbconfig is not yet supported for Rust extensions. Ignoring" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would it take to implement this for rust?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, it should be done by replacing RbConfig
reference with the corresponding value of target_rbconfig
in cargo_builder.rb
. Maybe we need some change in rb-sys side, but wouldn't be big.
bundler/lib/bundler/cli/install.rb
Outdated
@@ -19,6 +19,10 @@ def run | |||
# Disable color in deployment mode | |||
Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment] | |||
|
|||
if target_rbconfig_path = options["target-rbconfig"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if target_rbconfig_path = options["target-rbconfig"] | |
if target_rbconfig_path = options[:target-rbconfig] |
After resolving https://github.com/rubygems/rubygems/pull/7628/files#r1642315631, Let's merge this. |
…ands This patch adds `--target-rbconfig` option to specify the rbconfig.rb file for the deployment target platform. This is useful when cross-compiling gems. At the moment, this option is only available for `extconf.rb`-based extensions.
132178c
to
07a5fae
Compare
@@ -19,6 +19,10 @@ def run | |||
# Disable color in deployment mode | |||
Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment] | |||
|
|||
if target_rbconfig_path = options[:"target-rbconfig"] | |||
Bundler.rubygems.set_target_rbconfig(target_rbconfig_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably fail more gracefully when the underlying RubyGems method is not available?
What was the end-user or developer problem that led to this PR?
Today, CRuby runs on many platforms. But not all platforms are capable of running build tools (e.g. WebAssembly/WASI), so cross-target compilation against extensions libraries is essential for those platforms.
Currently, there is no way to cross-compile extension libraries in gems at install-time.
What is your fix for the problem, implemented in this PR?
This patch adds
--target-rbconfig
option to specify the rbconfig.rb file for the deployment target platform. It basically pass through it to mkmf. The underlying--target-rbconfig
support in mkmf has been introduced recently https://bugs.ruby-lang.org/issues/20345At the moment, this option is only available when the following requirements are met:
extconf.rb
-based extensionsBut we can relax the first requirement for Cargo builder by adding a support in rb-sys later.
$ GEM_HOME=/tmp/gems-wasm32-wasi gem install nokogiri --target-rbconfig path/to/wasm32-wasi/rbconfig.rb
Make sure the following tasks are checked