Use Thermite to build extension
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.
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?
Related news https://github.com/rubygems/rubygems/issues/2726!
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.
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.
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.
I would still like to continue this PR. I will take a look at the CircleCI configuration and do some more research.
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?
I don't think it is anymore. I'm not sure what the current best practice is for maintaining/distributing Rust-based Ruby extensions.