Skip to content

Commit cfe4573

Browse files
committed
doc: update README with GNU/Musl description.
1 parent 1baaf03 commit cfe4573

File tree

1 file changed

+47
-7
lines changed

1 file changed

+47
-7
lines changed

README.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,43 @@ This is kind of successor of [rake-compiler-dev-box](https://github.com/tjschuck
1010
It is wrapped as a gem for easier setup, usage and integration and is based on lightweight Docker containers.
1111
It is also more reliable, since the underlying docker images are versioned and immutable.
1212

13+
## Supported platforms
14+
15+
The following platforms are supported for cross-compilation by rake-compiler-dock:
16+
17+
- `aarch64-linux` and `aarch64-linux-gnu`
18+
- `aarch64-linux-musl`
19+
- `arm-linux` and `arm-linux-gnu`
20+
- `arm-linux-musl`
21+
- `arm64-darwin`
22+
- `jruby`
23+
- `x64-mingw-ucrt`
24+
- `x64-mingw32`
25+
- `x86-linux` and `x86-linux-gnu`
26+
- `x86-linux-musl`
27+
- `x86-mingw32`
28+
- `x86_64-darwin`
29+
- `x86_64-linux` and `x86_64-linux-gnu`
30+
- `x86_64-linux-musl`
31+
32+
### Windows
33+
34+
`x64-mingw-ucrt` should be used for Ruby 3.1 and later on windows. `x64-mingw32` should be used for Ruby 3.0 and earlier. This is to match the [changed platform of RubyInstaller-3.1](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html).
35+
36+
### GNU and Musl
37+
38+
Platform names with a `*-linux` suffix are aliases for `*-linux-gnu`, since the Rubygems default is to assume `gnu` if no libc is specified.
39+
40+
Some C extensions may not require separate GNU and Musl builds, in which case it's acceptable to ship a single `*-linux` gem to cover both platforms.
41+
42+
The `*-linux-gnu` and `*-linux-musl` platform name suffixes require Rubygems 3.3.22 or later (or Bundler 2.3.21 or later) at installation time. Ruby version 3.0 and later ship with a sufficient Rubygems version, but versions compatible with earlier Rubies are:
43+
44+
- ruby: "2.7", rubygems: "3.4.22"
45+
- ruby: "2.6", rubygems: "3.4.22"
46+
- ruby: "2.5", rubygems: "3.3.26"
47+
- ruby: "2.4", rubygems: "3.3.26"
48+
49+
1350
## Installation
1451

1552
Install docker [following the instructions on the docker website](https://docs.docker.com/engine/install/) ... or install [docker-toolbox for Windows and OSX](https://github.com/docker/toolbox/releases) or boot2docker on [Windows](https://github.com/boot2docker/windows-installer/releases) or [OS X](https://github.com/boot2docker/osx-installer/releases) .
@@ -33,20 +70,19 @@ Your Rakefile should enable cross compilation like so:
3370
```ruby
3471
exttask = Rake::ExtensionTask.new('my_extension', my_gem_spec) do |ext|
3572
ext.cross_compile = true
36-
ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux-gnu x86_64-linux-gnu x86_64-darwin arm64-darwin]
73+
ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux x86_64-darwin arm64-darwin]
3774
end
3875
```
3976

77+
where you should choose your platforms from the list in the "Supported platforms" section.
78+
4079
See below, how to invoke cross builds in your Rakefile.
4180

4281
Additionally it may also be used to build ffi based binary gems like [libusb](https://github.com/larskanis/libusb), but currently doesn't provide any additional build helpers for this use case, beyond docker invocation and cross compilers.
4382

4483
### Interactive Usage
4584

4685
Rake-compiler-dock offers the shell command `rake-compiler-dock` and a [ruby API](http://www.rubydoc.info/gems/rake-compiler-dock/RakeCompilerDock) for issuing commands within the docker image, described below.
47-
There are dedicated images for targets: `aarch64-linux-gnu`, `arm-linux-gnu`, `arm64-darwin`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux-gnu`, `x86-mingw32`, `x86_64-darwin`, `x86_64-linux-gnu`, and `jruby`.
48-
The images contain all supported cross ruby versions, with the exception of `x64-mingw32`, which has versions before 3.1 only, and `x64-mingw-ucrt`, which has only ruby-3.1+.
49-
This is to match the [changed platform of RubyInstaller-3.1](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html).
5086

5187
`rake-compiler-dock` without arguments starts an interactive shell session.
5288
This is best suited to try out and debug a build.
@@ -68,7 +104,7 @@ To build x86 Windows and x86_64 Linux binary gems interactively, it can be calle
68104
user@host:$ ls pkg/*.gem
69105
your-gem-1.0.0.gem your-gem-1.0.0-x86-mingw32.gem
70106

71-
user@host:$ RCD_PLATFORM=x86_64-linux-gnu rake-compiler-dock # this enters a container for amd64 Linux target
107+
user@host:$ RCD_PLATFORM=x86_64-linux-gnu rake-compiler-dock # this enters a container for amd64 Linux GNU target
72108
user@adc55b2b92a9:$ bundle
73109
user@adc55b2b92a9:$ rake cross native gem
74110
user@adc55b2b92a9:$ exit
@@ -120,14 +156,18 @@ This can be done like this:
120156
```ruby
121157
PLATFORMS = %w[
122158
aarch64-linux-gnu
159+
aarch64-linux-musl
123160
arm-linux-gnu
161+
arm-linux-musl
124162
arm64-darwin
125163
x64-mingw-ucrt
126164
x64-mingw32
127165
x86-linux-gnu
166+
x86-linux-musl
128167
x86-mingw32
129168
x86_64-darwin
130169
x86_64-linux-gnu
170+
x86_64-linux-musl
131171
]
132172
task 'gem:native' do
133173
require 'rake_compiler_dock'
@@ -212,7 +252,7 @@ jobs:
212252
Where the referenced rake task might be defined by something like:
213253
214254
``` ruby
215-
cross_platforms = ["x64-mingw32", "x86_64-linux-gnu", "x86_64-darwin", "arm64-darwin"]
255+
cross_platforms = ["x64-mingw32", "x86_64-linux", "x86_64-darwin", "arm64-darwin"]
216256

217257
namespace "gem" do
218258
cross_platforms.each do |platform|
@@ -248,7 +288,7 @@ The following variables are recognized by rake-compiler-dock:
248288
* `RCD_RUBYVM` - The ruby VM and toolchain to be used.
249289
Must be one of `mri`, `jruby`.
250290
* `RCD_PLATFORM` - The target rubygems platform.
251-
Must be a space separated list out of `aarch64-linux-gnu`, `arm-linux-gnu`, `arm64-darwin`, `x64-mingw-ucrt`, `x64-mingw32`, `x86-linux-gnu`, `x86-mingw32`, `x86_64-darwin`, `x86_64-linux-gnu`.
291+
Must be a space separated list out of the platforms listed under "Supported platforms" above.
252292
It is ignored when `rubyvm` is set to `:jruby`.
253293
* `RCD_IMAGE` - The docker image that is downloaded and started.
254294
Defaults to "ghcr.io/rake-compiler/rake-compiler-dock-image:IMAGE_VERSION-PLATFORM" with an image version that is determined by the gem version.

0 commit comments

Comments
 (0)