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

Integration with rb-sys #163

Open
ianks opened this issue Sep 28, 2022 · 7 comments
Open

Integration with rb-sys #163

ianks opened this issue Sep 28, 2022 · 7 comments

Comments

@ianks
Copy link

ianks commented Sep 28, 2022

Hi there!

I’ve been working on rb-sys. The main goal of the project is to make building native extensions in Rust easier than C.

Traditionally, most Ruby/Rust gems have packaged their own Ruby bindings. As you know, there are many edge cases and supporting these bindings across multiple platforms can be a total pain. With rb-sys, the goal is remove that burden. Some features are:

  • Rust bindings for the Ruby C API
  • Support for Ruby 2.4+
  • Cross compilation of gems
  • Integration with rake-compiler
  • Support for the Rubygems official cargo builder
  • Production battle tested at shopify

I would love to add support for rb-sys to Rutie if you are interested. I recently made the switch this for magnus and things went smoothly. For Rutie, I imagine it will solve a lot of build issues (particularly with libruby-static, and upcoming changes with Ruby 3.2). On top of this, it will make it easier for Rutie users to cross compile gems.

Let me know if this sounds like something you would accept. Happy to start working on it!

@danielpclark
Copy link
Owner

danielpclark commented Nov 12, 2022

Hi @ianks, Rutie allows for builds to work in both directions. So yes it allows Ruby to integrate Rust into Ruby, but it also allows Rust to integrate Ruby into Rust. I get the benefit of a standardized way setup as the foundation on which Rutie can be used to help Rust integrate into Ruby. But have you done an initial survey of this project to see how good of a fit it would be and how feasible it is to do without detracting from the Rust integrating Ruby into Rust side of things?

We currently have some Windows developers working on seeing how we can have Rutie better supported on that platform, which is exiting, so I'd like to know the impact of what changes need to come. Depending on the answer I may be in favor of moving forward with this. But I'm not going to give the full go ahead without much more serious consideration given to it.

Thanks!

@ianks
Copy link
Author

ianks commented Nov 13, 2022

Hey @danielpclark,

But have you done an initial survey of this project to see how good of a fit it would be and how feasible it is to do without detracting from the Rust integrating Ruby into Rust side of things?

rb-sys does indeed support the embedded use case, and it's a first-class concern. We've been supporting this on magnus for awhile with the embed feature, and the entire test suite uses it.

We currently have some Windows developers working on seeing how we can have Rutie better supported on that platform, which is exiting, so I'd like to know the impact of what changes need to come.

For window, [rb-sys] is with every every Windows target supported by [rake-compiler-dock], and probably more. I even recently added mswin support for the msvc toolchain, which is an upcoming feature of Ruby 3.2. You can see the list of fully supported platforms here. If you want to dive deeper, you can take a look at the CI test matrix as well.

Enjoy your weekend!
Ian

@danielpclark
Copy link
Owner

I'd like you to move forward with this if you have the time. I expect not everything will work initially but we'll cross that bridge when we get there.

@ianks
Copy link
Author

ianks commented Feb 16, 2023

FYI @goyox86 has stepped up and volunteered to do this 🙏🏻

@goyox86
Copy link
Contributor

goyox86 commented Feb 17, 2023

Managed to send a PR moving to rb-sys still needs work but its a start, please take a look whenever you can @ianks @danielpclark I was waiting to have some time to clean and create the PR.

I also experimented a branch to have both implementations with Cargo features, not sure if I like it xD

@danielpclark
Copy link
Owner

danielpclark commented Mar 17, 2023

@goyox86 Great work! I love seeing progress made on this and it looks like you're making good headway.

Is the rampant use of .into() due to the changes to ruby value type? Would it be feasible to have .into() refactored back out without removing the progress on types you've made?

Also I prefer having the named CallbackPtr naming convention over the raw type details as this provides clarity and context for developers when using such references. I suppose it doesn't need to be truncated; perhaps CallbackPointer would be better.

@goyox86
Copy link
Contributor

goyox86 commented Apr 19, 2023

Hello there @danielpclark !

Sorry for the radio silence, I have been a bit busy with work.

Regarding your comment, I think I am using into() right now just because what was allowed me to progress, but TBH I did not give to much thought to that part of the changes. I noticed it seemed pervasive, but my objective is to have things running, cargo test --doc passing on all platforms.

Currently I am focused on making rb-sys "just work" with the standard Ruby Installer 2 on windows and then I will come back here. I expect to have some time this weekend to come here and rebase stuff. I saw you have been working on the CI for the current implementation of rutie. Looks great!

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

No branches or pull requests

3 participants