Skip to content

Commit e70c126

Browse files
authored
Merge pull request #28 from flavorjones/flavorjones-prefer-linux-gnu
precompiled: switch from `-linux` to `-linux-gnu`
2 parents a5d4d3d + 5cc9b78 commit e70c126

File tree

4 files changed

+85
-26
lines changed

4 files changed

+85
-26
lines changed

.github/workflows/precompiled.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ jobs:
105105
fail-fast: false
106106
matrix:
107107
platform:
108-
- "aarch64-linux"
108+
- "aarch64-linux-gnu"
109109
- "aarch64-linux-musl"
110-
- "arm-linux"
110+
- "arm-linux-gnu"
111111
- "arm-linux-musl"
112112
- "arm64-darwin" # github actions does not support this runtime, but let's build anyway
113113
- "x64-mingw-ucrt"
114114
- "x64-mingw32"
115-
- "x86-linux"
115+
- "x86-linux-gnu"
116116
- "x86-linux-musl"
117117
- "x86_64-darwin"
118-
- "x86_64-linux"
118+
- "x86_64-linux-gnu"
119119
- "x86_64-linux-musl"
120120
runs-on: ubuntu-latest
121121
steps:
@@ -140,13 +140,13 @@ jobs:
140140
fail-fast: false
141141
matrix:
142142
platform:
143-
- "aarch64-linux"
143+
- "aarch64-linux-gnu"
144144
- "aarch64-linux-musl"
145-
- "arm-linux"
145+
- "arm-linux-gnu"
146146
- "arm-linux-musl"
147-
- "x86-linux"
147+
- "x86-linux-gnu"
148148
- "x86-linux-musl"
149-
- "x86_64-linux"
149+
- "x86_64-linux-gnu"
150150
- "x86_64-linux-musl"
151151
ruby: ["3.0", "3.1", "3.2", "3.3"]
152152
include:
@@ -156,11 +156,11 @@ jobs:
156156
- { platform: x86-linux-musl, docker_tag: "-alpine", bootstrap: "apk add bash &&" }
157157
- { platform: x86_64-linux-musl, docker_tag: "-alpine", bootstrap: "apk add bash &&" }
158158
# declare docker platform for each platform
159-
- { platform: aarch64-linux, docker_platform: "--platform=linux/arm64" }
159+
- { platform: aarch64-linux-gnu, docker_platform: "--platform=linux/arm64" }
160160
- { platform: aarch64-linux-musl, docker_platform: "--platform=linux/arm64" }
161-
- { platform: arm-linux, docker_platform: "--platform=linux/arm/v7" }
161+
- { platform: arm-linux-gnu, docker_platform: "--platform=linux/arm/v7" }
162162
- { platform: arm-linux-musl, docker_platform: "--platform=linux/arm/v7" }
163-
- { platform: x86-linux, docker_platform: "--platform=linux/386" }
163+
- { platform: x86-linux-gnu, docker_platform: "--platform=linux/386" }
164164
- { platform: x86-linux-musl, docker_platform: "--platform=linux/386" }
165165
runs-on: ubuntu-latest
166166
steps:
@@ -174,6 +174,7 @@ jobs:
174174
docker run --rm -v $PWD/precompiled:/precompiled -w /precompiled \
175175
${{ matrix.docker_platform }} ruby:${{ matrix.ruby }}${{ matrix.docker_tag }} \
176176
sh -c "
177+
gem update --system &&
177178
${{ matrix.bootstrap }}
178179
./bin/test-gem-install gems
179180
"

CHANGELOG.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,48 @@
11
# Changelog
22

3+
## v0.5.next / unreleased
4+
5+
### `precompiled`
6+
7+
- The `precompiled` gem has switched from building `-linux` platform gems (implicit `gnu`) to explicit `-linux-gnu` platform gems, and now supports these platforms:
8+
- `aarch64-linux-gnu`
9+
- `aarch64-linux-musl`
10+
- `arm-linux-gnu`
11+
- `arm-linux-musl`
12+
- `arm64-darwin`
13+
- `x64-mingw-ucrt`
14+
- `x64-mingw32`
15+
- `x86-linux-gnu`
16+
- `x86-linux-musl`
17+
- `x86_64-darwin`
18+
- `x86_64-linux-gnu`
19+
- `x86_64-linux-musl`
20+
21+
322
## v0.5.0 / 2024-01-27
423

5-
### Added
24+
### Improved
625

7-
- `precompiled` now supports the `arm-linux-musl` platform.
8-
- `precompiled` now supports the `aarch64-linux-musl` platform.
9-
- `precompiled` now supports the `x86-linux-musl` platform.
10-
- `precompiled` now supports the `x86_64-linux-musl` platform.
11-
- `precompiled` gem now supports Ruby 3.2 and 3.3, and drops support for Ruby 2.6 and 2.7
1226
- The `extconf.rb` file in `packaged_tarball` and `precompiled` now use a `ExtConf` module pattern for encapsulation.
1327

28+
### `precompiled`
29+
30+
- The `precompiled` gem now supports Ruby 3.2 and 3.3, and drops support for Ruby 2.6 and 2.7
31+
- The `precompiled` gem has added `musl` support for linux, and now supports these platforms:
32+
- `aarch64-linux`
33+
- `aarch64-linux-musl`
34+
- `arm-linux`
35+
- `arm-linux-musl`
36+
- `arm64-darwin`
37+
- `x64-mingw-ucrt`
38+
- `x64-mingw32`
39+
- `x86-linux`
40+
- `x86-linux-musl`
41+
- `x86_64-darwin`
42+
- `x86_64-linux`
43+
- `x86_64-linux-musl`
44+
45+
1446

1547
## 0.4.0 / 2022-05-19
1648

precompiled/README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ First, we need to add some features to our `Rake::ExtensionTask` in `Rakefile`:
2828
``` ruby
2929
cross_rubies = ["3.3.0", "3.2.0", "3.1.0", "3.0.0"]
3030
cross_platforms = [
31-
"x64-mingw32",
31+
"aarch64-linux-gnu",
32+
"aarch64-linux-musl",
33+
"arm-linux-gnu",
34+
"arm-linux-musl",
35+
"arm64-darwin",
3236
"x64-mingw-ucrt",
33-
"x86-linux",
34-
"x86_64-linux",
35-
"aarch64-linux",
37+
"x64-mingw32",
38+
"x86-linux-gnu",
39+
"x86-linux-musl",
3640
"x86_64-darwin",
37-
"arm64-darwin",
41+
"x86_64-linux-gnu",
42+
"x86_64-linux-musl",
3843
]
3944
ENV["RUBY_CC_VERSION"] = cross_rubies.join(":")
4045

@@ -161,6 +166,22 @@ end
161166
Go ahead and try it! `gem install rcee_precompiled`. If you're on windows, linux, or macos you should get a precompiled version that installs in under a second. Everyone else (hello FreeBSD people!) it'll take a few more seconds to build the vanilla gem's packaged tarball.
162167

163168

169+
### Windows notes
170+
171+
You may have noticed that the gem for `x64-mingw32` only contains `.../3.0/precompiled.so` and not a shared library for 3.1, 3.2, or 3.3. Conversely, the gem for `x64-mingw-ucrt` does *not* contain 3.0 (but contains 3.1..3.3 inclusive).
172+
173+
This is because the Windows installer for Ruby switched from `msvcrt` to `ucrt` for the C standard library. Rubies 3.0 and earlier use `msvcrt` but later Rubies use `ucrt`. So if you're on Ruby 3.0 on Windows, bundler will resolve your platform as `x64-mingw32`; but if you're on Ruby 3.1 or later, bundler will resolve your platform as `x64-mingw-ucrt`. See [the rubyinstaller release notes](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html) for more information.
174+
175+
This is all taken care of for you by `rake-compiler-dock` and there's no additional work necessary to create those specialized native gems. However, you'll see this libc transition in the CI testing matrix in `.github/workflows/precompiled.yml`.
176+
177+
178+
### Linux notes
179+
180+
On Linux, the default C library for a long time was GNU libc, and so when you see native gem platforms like `x86_64-linux` the _implied_ libc is `gnu`. However, in recent years the `musl` libc project has gotten off the ground in distributions like Alpine. Often, `musl` systems are able to run code compiled on (and for) `gnu` systems; but not always. And in those incompatible cases, users had to work around it or avoid Alpine.
181+
182+
As of Rubygems 3.3.22, the `gem` and `bundle` tools are able to distinguish platforms by their libc type (e.g., `x86_64-linux-gnu` versus `x86_64-linux-musl`); and `rake-compiler-dock` started to be able to build `musl` native gems as of v1.5.0.
183+
184+
164185
## Testing
165186

166187
See [.github/workflows/precompiled.yml](../.github/workflows/precompiled.yml)

precompiled/Rakefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ require "rake_compiler_dock"
88

99
cross_rubies = ["3.3.0", "3.2.0", "3.1.0", "3.0.0"]
1010
cross_platforms = [
11-
"aarch64-linux",
11+
"aarch64-linux-gnu",
1212
"aarch64-linux-musl",
13-
"arm-linux",
13+
"arm-linux-gnu",
1414
"arm-linux-musl",
1515
"arm64-darwin",
1616
"x64-mingw-ucrt",
1717
"x64-mingw32",
18-
"x86-linux",
18+
"x86-linux-gnu",
1919
"x86-linux-musl",
2020
"x86_64-darwin",
21-
"x86_64-linux",
21+
"x86_64-linux-gnu",
2222
"x86_64-linux-musl",
2323
]
2424
ENV["RUBY_CC_VERSION"] = cross_rubies.join(":")
@@ -42,6 +42,11 @@ Rake::ExtensionTask.new("precompiled", rcee_precompiled_spec) do |ext|
4242
# remove things not needed for precompiled gems
4343
spec.dependencies.reject! { |dep| dep.name == "mini_portile2" }
4444
spec.files.reject! { |file| File.fnmatch?("*.tar.gz", file) }
45+
46+
if spec.platform.os == "linux"
47+
# the `-gnu` suffix is not recognized in earlier versions of rubygems
48+
spec.required_rubygems_version.concat([">= 3.3.22"])
49+
end
4550
end
4651
end
4752

0 commit comments

Comments
 (0)