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

Use Thermite to build extension #6

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aergonaut
Copy link

Hello maintainers!

I am very interested in trying out this gem for some projects. One major obstacle to this is that installing the gem currently requires a working installation of cargo. This means I can't use this gem on a remote server where I may not be able to install cargo.

In this PR, I propose to add Thermite to manage building, compiling, and installing the gem's extension code.

Info about Thermite

Thermite is a Rake-based helper for building and distributing Rust-based Ruby extensions.

Thermite's biggest advantage is that it provides a way to automatically check for and download precompiled libraries when a user tries to install the gem. When a user runs gem install wasmer, Thermite will check for a precompiled library on GitHub Releases that matches the version of wasmer requested, the user's platform, and the user's architecture. If a precompiled library exists, that is downloaded and unpacked; if one does not exist, then regular cargo build --release is used.

For an example of a Rust-based Ruby extension using Thermite, check out rusty_blank.

Need a CI platform

The advantage of Thermite is that it can download precompiled libraries, but that means this project will need some way to generate those libraries. I do not see any common CI config files in the project, so I think a first step would be to choose a CI provider.

I would personally recommend Azure Pipelines because Pipelines gives access to Linux, macOS, and Windows build nodes, all in one platform. This would mean that the project could run tests on all 3 platforms and also compile libraries on all 3 platforms.

Maybe this PR should wait until a CI platform is chosen. I can revisit this PR to update the CI scripts to add the necessary steps to publish releases after.

This commit adds Thermite to build and compile the gem extension. Using
Thermite, users of the gem do not need to have a working Rust compiler
in order to install the gem. Instead, Thermite will check for a compiled
library matching the user's environment on GitHub Releases and download
that instead. If there is no matching compiled library available, then
Thermite falls back to compiling the extension locally.

This makes this gem more accessible as users do not need to understand
how to install and manage Rust in order to use the gem.
@Hywan
Copy link
Contributor

Hywan commented May 8, 2019

Hello,

Thanks for the interesting proposal. I know Thermite but I didn't know it was able to use pre-compiled binaries. That's interesting.

The project has a CI: https://github.com/wasmerio/ruby-ext-wasm/blob/master/.circleci/config.yml.

I plan to move to Azure so that we have Windows support too. Let's start with CircleCI as it is now.

What do you need to continue your PR?

@Hywan Hywan self-assigned this May 8, 2019
@Hywan Hywan added the 🎉 enhancement New feature or request label May 8, 2019
@@ -0,0 +1,5 @@
require "thermite/tasks"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a Rakefile file at the root of this project. It is used by the gemspec file. I reckon we can merge the two Rakefile files.

@Hywan
Copy link
Contributor

Hywan commented May 11, 2019

Related news rubygems/rubygems#2726!

@aergonaut
Copy link
Author

That's very exciting. I may hold off on this depending on how the Rubygems integration goes. Hopefully they will offer a way to use precompiled libraries, as I don't think the Rust compiler is as common as GCC.

Another trouble I ran into while testing this is that Rutie requires Ruby to be compiled with --enable-shared. My local Ruby was not compiled with that option, so I don't know how common it is for anyone to pass that option when installing Ruby locally.

@Hywan
Copy link
Contributor

Hywan commented May 13, 2019

I don't know whether we should wait on Rubygems. There is no deadline, and it will probably take months before being released.

Do you have time, or motivation, to continue this PR?

Another trouble I ran into while testing this is that Rutie requires Ruby to be compiled with --enable-shared. My local Ruby was not compiled with that option, so I don't know how common it is for anyone to pass that option when installing Ruby locally.

That's true. I guess it's the case for every Ruby extension written in Rust though.

@aergonaut
Copy link
Author

I guess it's the case for every Ruby extension written in Rust though.

I believe some of the other Rust extension crates statically link to Ruby so they don't require the presence of the shared library on the user's system. It looks like Rutie is trying to solve a few remaining issues to enable static builds.

@aergonaut
Copy link
Author

I would still like to continue this PR. I will take a look at the CircleCI configuration and do some more research.

@Hywan
Copy link
Contributor

Hywan commented May 11, 2021

Hello,

I think it's time to try it out again :-). We have a new CI pipeline based on Github Actions. The project has been rewritten from scratch. Everything looks good!

I see that https://github.com/malept/thermite didn't receive any commits since 2018. Do you believe the project is still maintained?

@aergonaut
Copy link
Author

I don't think it is anymore. I'm not sure what the current best practice is for maintaining/distributing Rust-based Ruby extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants