Note
This tool is currently in active development. We are very much looking for your feedback.
A major bottleneck for every Ruby developers when running bundle install is the compilation of native gem extensions. To illustrate this issue, running bundle install on a new Rails application takes around 25 seconds on a MacBook Pro M4, and 80% of that time is spent compiling the couple dozens of gems having native extensions. It would take only 5 seconds if it wasn't for the compilation.
The Python community had exactly the same issue and came up with the amazing cibuildwheel solution to provide a CI based compilation approach to help maintainers ship their libraries will precompiled binaries for various platforms.
This tool modestly tries to follow the same approach by helping ruby maintainers ship their gems with precompiled binaries.
Precompilation isn't new in the Ruby ecosystem and some maintainers have been releasing their gems with precompiled binaries to speedup the installation process since a while (e.g. nokogiri, grpc, karafka-rdkafka). One of the most popular tool that enables to precompile binaries for different platform is the great rake-compiler-dock toolchain. It uses a cross compilation approach by periodically building docker images for various platforms and spinning up containers to compile the binaries.
As noted by @flavorjones, this toolchain works great but it's complex and brittle compared to the more simple process of compiling on the target platform.
Head to the documentation Wiki to setup and configure cibuildgem for your gem.
Here are some working examples on gem that have setup cibuildgem
| Name | Example Run | Published Gem |
|---|---|---|
| Rubydex | CI Run | Gem |
| Heap Profiler | CI Run | Gem |
| djb2 | CI Run | Gem |
| Blake3 | CI Run | Gem |
| Raindrops (fork) | CI Run | Gem |
| Stack Frames | CI Run | Gem |
| MacOS Intel | MacOS ARM | Windows x64 UCRT | Linux GNU x86_64 | Linux AARCH64 | |
|---|---|---|---|---|---|
| Ruby 3.1 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| Ruby 3.2 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| Ruby 3.3 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| Ruby 3.4 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| Ruby 4.0 | 🟢 | 🟢 | 🟠 (not tested) | 🟢 | 🟢 |