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

RFC: Provide easy access to the cross-rubies from the build process #149

Closed
flavorjones opened this issue Jan 20, 2025 · 7 comments · Fixed by #150
Closed

RFC: Provide easy access to the cross-rubies from the build process #149

flavorjones opened this issue Jan 20, 2025 · 7 comments · Fixed by #150

Comments

@flavorjones
Copy link
Collaborator

Context

Currently, any gem maintainer who wishes to limit the precompiled extensions to only a few recent rubies must set RUBY_CC_VERSION to a specific set of Ruby versions to inform rake-compiler.

Practically, this means that every gem's build process somewhere is hard-coding ruby versions. Some examples:

Previously, this was not a big deal because we generally settled on the .0 release for the cross-rubies. However, starting with v1.6.0 we've started upgrading the cross-rubies' patch levels for various reasons. This makes upgrading rake-compiler-dock annoying because now everyone has to update these hard-coded values.

Proposal

I'm proposing that the rake-compiler-dock gem make these cross-ruby versions available to gem maintainers for use at build time.

Specifically I'm proposing (and would like feedback on) a method RakeCompilerDock.cross_rubies which returns a Hash<minor ⇒ patch>, e.g.:

{
  "3.4" => "3.4.1",
  "3.3" => "3.3.7",
  ...
  "2.4" => "2.4.10"
}

Then gems could assemble a correct/valid value for RUBY_CC_VERSIONS using only the minor versions that will be packaged.

I'd love to get a 👍 or 👎 and a comment from folks.

/cc @mudge @stanhu @larskanis

@flavorjones
Copy link
Collaborator Author

flavorjones commented Jan 20, 2025

Or, I guess, an alternative or additional method might construct the RUBY_CC_VERSION based on minors:

RakeCompilerDock.ruby_cc_version("3.4", "3.3", "3.2", "3.1")
# => "3.4.1:3.3.5:3.2.6:3.1.6"

and potentially even accept Gem::Requirement

RakeCompilerDock.ruby_cc_version(Gem::Requirement.new("~> 3.0"))
# => "3.4.1:3.3.5:3.2.6:3.1.6:3.0.7"

Overkill?

@mudge
Copy link

mudge commented Jan 20, 2025

Introducing some sort of higher-level API that either sets RUBY_CC_VERSION or returns the necessary string for it would be useful and make the diff smaller between rake-compiler-dock upgrades.

Given that Ruby version support will always end up being a Requirement in the resulting gems maybe using that API isn't a bad idea but could be an implementation detail, e.g.

RakeCompilerDock.set_ruby_cc_version("~> 3.0")
# internally uses `Gem::Requirement.create` to handle input and filters the supported list of Ruby versions for rake-compiler

@flavorjones
Copy link
Collaborator Author

See #150 for a concrete proposal.

@flavorjones
Copy link
Collaborator Author

@stanhu
Copy link

stanhu commented Jan 20, 2025

This is great, thanks.

@stanhu
Copy link

stanhu commented Jan 20, 2025

@flavorjones I should note that for Rust extensions, we also need to match the patch releases here:

The first pull request uses RUBY_CC_VERSION inside a Dockerfile. I suppose we could find a way to inject this dynamically or template it.

With the addition of -gnu and -musl suffixes, we also need to publish aliases for the rbsys Docker images:

@stanhu
Copy link

stanhu commented Jan 20, 2025

Actually, we can simplify the Dockerfile to omit the patch release and use RakeCompilerDock.cross_rubies in the Ruby script. Let me do that.

stanhu added a commit to stanhu/rb-sys that referenced this issue Jan 20, 2025
`RakeCompilerDock.cross_rubies` supplies the exact patch release
needed. This is available in rack-compiler-dock v1.9.1:

* rake-compiler/rake-compiler-dock#149
* https://github.com/rake-compiler/rake-compiler-dock/releases/tag/v1.9.1

This simplifies the `Dockerfile`, but it does mean we have to keep the
rake-compiler-dock version in the `Gemfile` in sync with all the
images in `docker/Dockerfile.*`.
stanhu added a commit to stanhu/rb-sys that referenced this issue Jan 21, 2025
`RakeCompilerDock.cross_rubies` supplies the exact patch release
needed. This is available in rack-compiler-dock v1.9.1:

* rake-compiler/rake-compiler-dock#149
* https://github.com/rake-compiler/rake-compiler-dock/releases/tag/v1.9.1

This simplifies the `Dockerfile`, but it does mean we have to keep the
rake-compiler-dock version in the `Gemfile` in sync with all the
images in `docker/Dockerfile.*`.
stanhu added a commit to stanhu/rb-sys that referenced this issue Jan 21, 2025
`RakeCompilerDock.cross_rubies` supplies the exact patch release
needed. This is available in rack-compiler-dock v1.9.1:

* rake-compiler/rake-compiler-dock#149
* https://github.com/rake-compiler/rake-compiler-dock/releases/tag/v1.9.1

This simplifies the `Dockerfile`, but it does mean we have to keep the
rake-compiler-dock version in the `Gemfile` in sync with all the
images in `docker/Dockerfile.*`.
ianks pushed a commit to oxidize-rb/rb-sys that referenced this issue Jan 21, 2025
`RakeCompilerDock.cross_rubies` supplies the exact patch release
needed. This is available in rack-compiler-dock v1.9.1:

* rake-compiler/rake-compiler-dock#149
* https://github.com/rake-compiler/rake-compiler-dock/releases/tag/v1.9.1

This simplifies the `Dockerfile`, but it does mean we have to keep the
rake-compiler-dock version in the `Gemfile` in sync with all the
images in `docker/Dockerfile.*`.
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

Successfully merging a pull request may close this issue.

3 participants