-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[rust gem] Major improvements for gem scaffolding #7608
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
Conversation
5537262 to
f483e2c
Compare
f483e2c to
b090e96
Compare
|
@ianks this looks amazing. I did some local testing and I have faced following problem. $ ~/code/work/oss/rubygems/bundler/exe/bundle gem --ext=rust ryba
...
$ cd ryba
$ cargo test
...
Compiling rb-sys-build v0.9.97
Compiling rb-sys v0.9.97
Finished test [unoptimized + debuginfo] target(s) in 27.65s
Running unittests src/lib.rs (target/debug/deps/ryba-715184ccf66f2799)
running 1 test
/tmp/ryba/target/debug/deps/ryba-715184ccf66f2799: symbol lookup error: /home/retro/.rubies/ruby-3.3.1/lib/ruby/3.3.0/x86_64-linux/enc/encdb.so: undefined symbol: rb_encdb_declare
error: test failed, to rerun pass `--lib`
Caused by:
process didn't exit successfully: `/tmp/ryba/target/debug/deps/ryba-715184ccf66f2799` (exit status: 127)Is that anything related to my setup? 🤔 Similar error seems to fail CI (https://github.com/rubygems/rubygems/actions/runs/9014478174/job/24767239926?pr=7608). |
|
hmm that's strange @simi, are you on linux? |
| # Fall back to loading the non-versioned extension if version-specific loading fails. | ||
| begin | ||
| RUBY_VERSION =~ /(\d+\.\d+)/ | ||
| require "#{Regexp.last_match(1)}/<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>" |
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 is something users frequently stumble on when trying to precompile gems, so let's just use the recommended pattern by rake-compiler as a default: https://github.com/rake-compiler/rake-compiler?tab=readme-ov-file#cross-compilation---the-future-is-now
| <%- end -%> | ||
| <%- if config[:ext] == 'rust' -%> | ||
| spec.extensions = ["ext/<%= config[:underscored_name] %>/Cargo.toml"] | ||
| spec.add_dependency "rb_sys", "~> 0.9" |
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.
The CargoBuilder was a good first start, but it's much less flexible and not the best default IMO. rb-sys + create_rust_makefile is much more robust these days, so let's use it
| [dependencies] | ||
| magnus = { version = "0.6.2" } | ||
| magnus = { version = "0.6.3" } | ||
| rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] } |
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.
With this, we support ruby-head out of the box. This allows users to run development/unstable rubies in production without friction
8c4d73d to
37a8c8b
Compare
37a8c8b to
ac358f4
Compare
d6d7443 to
bea50ba
Compare
Yes! $ uname -a
Linux retro 6.8.10-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Fri May 17 21:20:54 UTC 2024 x86_64 GNU/Linux |
|
Confirmed that cross-compilation works out of the box: https://github.com/ianks/testingbun/actions/runs/9312563096 |
|
@ianks Are you still interested in moving this PR forward? |
|
bandwidth is running low atm, but i reached out in slack to some folks to see if anyone can take it over for me. let's see if anyone volunteers in the next couple of days? |
|
I cherry picked these commits into #8455. |
|
Closing in favor of #8455. |
bundle gem --ext=rustresults in a project that doesn't supportcargo testby default. This causes unnecessary toil for developers who expect cargo test to work out of the box. This PR fixes that by usingrb-sys-envto configure the proper linker arguments for libruby.