-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: auto-select no-YJIT Ruby on older glibc systems #8069
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -466,31 +466,66 @@ impl RubyPlugin { | |
| .replace("{arch}", arch) | ||
| } | ||
|
|
||
| /// Find precompiled asset from a GitHub repo's releases | ||
| /// Check if the system needs the no-YJIT variant (glibc < 2.35 on Linux). | ||
| /// YJIT builds from jdx/ruby require glibc 2.35+. | ||
| fn needs_no_yjit() -> bool { | ||
| match *crate::env::LINUX_GLIBC_VERSION { | ||
| Some((major, minor)) => major < 2 || (major == 2 && minor < 35), | ||
| None => false, // non-Linux or can't detect, assume modern system | ||
| } | ||
| } | ||
|
|
||
| /// Find precompiled asset from a GitHub repo's releases. | ||
| /// On Linux with glibc < 2.35, prefers the no-YJIT variant (.no_yjit.) which | ||
| /// targets glibc 2.17. Falls back to the standard build if no variant is found. | ||
| async fn find_precompiled_asset_in_repo( | ||
| &self, | ||
| repo: &str, | ||
| version: &str, | ||
| platform: &str, | ||
| prefer_no_yjit: bool, | ||
| ) -> Result<Option<(String, Option<String>)>> { | ||
| let releases = github::list_releases(repo).await?; | ||
| let expected_name = format!("ruby-{}.{}.tar.gz", version, platform); | ||
| let standard_name = format!("ruby-{}.{}.tar.gz", version, platform); | ||
| let no_yjit_name = format!("ruby-{}.{}.no_yjit.tar.gz", version, platform); | ||
|
|
||
| for release in releases { | ||
| for asset in release.assets { | ||
| if asset.name == expected_name { | ||
| return Ok(Some((asset.browser_download_url, asset.digest))); | ||
| if prefer_no_yjit { | ||
| debug!("glibc < 2.35 detected, preferring no-YJIT Ruby variant"); | ||
| } | ||
|
|
||
| let mut standard_asset = None; | ||
| let mut no_yjit_asset = None; | ||
|
|
||
| for release in &releases { | ||
| for asset in &release.assets { | ||
| if no_yjit_asset.is_none() && asset.name == no_yjit_name { | ||
| no_yjit_asset = | ||
| Some((asset.browser_download_url.clone(), asset.digest.clone())); | ||
| } else if standard_asset.is_none() && asset.name == standard_name { | ||
| standard_asset = | ||
| Some((asset.browser_download_url.clone(), asset.digest.clone())); | ||
| } | ||
| } | ||
| if no_yjit_asset.is_some() && standard_asset.is_some() { | ||
| break; | ||
| } | ||
| } | ||
|
Comment on lines
+499
to
512
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This loop can be slightly optimized. By using for release in &releases {
for asset in &release.assets {
if no_yjit_asset.is_none() && asset.name == no_yjit_name {
no_yjit_asset =
Some((asset.browser_download_url.clone(), asset.digest.clone()));
} else if standard_asset.is_none() && asset.name == standard_name {
standard_asset =
Some((asset.browser_download_url.clone(), asset.digest.clone()));
}
}
if no_yjit_asset.is_some() && standard_asset.is_some() {
break;
}
} |
||
| Ok(None) | ||
|
|
||
| if prefer_no_yjit { | ||
| if no_yjit_asset.is_some() { | ||
| return Ok(no_yjit_asset); | ||
| } | ||
| debug!("no-YJIT variant not found, falling back to standard build"); | ||
| } | ||
| Ok(standard_asset) | ||
| } | ||
|
|
||
| /// Resolve precompiled binary URL and checksum for a given version and platform | ||
| async fn resolve_precompiled_url( | ||
| &self, | ||
| version: &str, | ||
| platform: &str, | ||
| prefer_no_yjit: bool, | ||
| ) -> Result<Option<(String, Option<String>)>> { | ||
| let settings = Settings::get(); | ||
| let source = &settings.ruby.precompiled_url; | ||
|
|
@@ -503,7 +538,7 @@ impl RubyPlugin { | |
| ))) | ||
| } else { | ||
| // GitHub repo shorthand (default: "jdx/ruby") | ||
| self.find_precompiled_asset_in_repo(source, version, platform) | ||
| self.find_precompiled_asset_in_repo(source, version, platform, prefer_no_yjit) | ||
| .await | ||
| } | ||
| } | ||
|
|
@@ -557,12 +592,17 @@ impl RubyPlugin { | |
| return Ok(None); | ||
| }; | ||
|
|
||
| let Some((url, checksum)) = self.resolve_precompiled_url(&tv.version, &platform).await? | ||
| let Some((url, checksum)) = self | ||
| .resolve_precompiled_url(&tv.version, &platform, Self::needs_no_yjit()) | ||
| .await? | ||
| else { | ||
| return Ok(None); | ||
| }; | ||
|
|
||
| let filename = format!("ruby-{}.{}.tar.gz", tv.version, platform); | ||
| let filename = match url.rsplit('/').next() { | ||
| Some(name) if !name.is_empty() => name.to_string(), | ||
| _ => format!("ruby-{}.{}.tar.gz", tv.version, platform), | ||
| }; | ||
| let tarball_path = tv.download_path().join(&filename); | ||
|
|
||
| ctx.pr.set_message(format!("download {}", filename)); | ||
|
|
@@ -845,8 +885,9 @@ impl Backend for RubyPlugin { | |
| // Precompiled binary info if enabled | ||
| if self.should_try_precompiled() | ||
| && let Some(platform) = self.precompiled_platform_for_target(target) | ||
| && let Some((url, checksum)) = | ||
| self.resolve_precompiled_url(&tv.version, &platform).await? | ||
| && let Some((url, checksum)) = self | ||
| .resolve_precompiled_url(&tv.version, &platform, false) | ||
| .await? | ||
| { | ||
| return Ok(PlatformInfo { | ||
| url: Some(url), | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.