Skip to content

Commit 46dbb80

Browse files
committed
feat: add arm-linux-musl
note that we have to patch rake-compiler to build ruby 2.7 on 32-byte arm because of coroutine issues that weren't fixed until 3.0. ci: extract testing matrices for arm-linux gnu and musl
1 parent ee2db79 commit 46dbb80

File tree

6 files changed

+76
-8
lines changed

6 files changed

+76
-8
lines changed

.github/workflows/ci.yml

+63
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
alias: aarch64-linux
5050
- platform: arm-linux-gnu
5151
alias: arm-linux
52+
- platform: arm-linux-musl
5253
- platform: arm64-darwin
5354
- platform: jruby
5455
- platform: x64-mingw-ucrt
@@ -317,6 +318,68 @@ jobs:
317318
ruby -rrcd_test -S rake test
318319
"
319320
321+
test_arm-linux-gnu:
322+
name: arm-linux-gnu
323+
needs: build_native_gem
324+
strategy:
325+
fail-fast: false
326+
matrix:
327+
ruby: ["3.3", "3.2", "3.1", "3.0", "2.7", "2.6", "2.5", "2.4"]
328+
platform: [arm-linux]
329+
include:
330+
# ruby 3.0 and earlier ship rubygems < 3.2.33, so can't recognize the -gnu suffix
331+
- ruby: "3.3"
332+
platform: arm-linux-gnu
333+
- ruby: "3.2"
334+
platform: arm-linux-gnu
335+
- ruby: "3.1"
336+
platform: arm-linux-gnu
337+
runs-on: ubuntu-latest
338+
steps:
339+
- uses: actions/checkout@v3
340+
- name: Download gem-${{ matrix.platform }}
341+
uses: actions/download-artifact@v3
342+
with:
343+
name: gem-${{ matrix.platform }}
344+
- name: Run tests
345+
run: |
346+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
347+
docker run --rm -v $PWD:/work -w /work \
348+
--platform=linux/arm/v7 ruby:${{ matrix.ruby }} \
349+
sh -c "
350+
gem install --local *.gem --verbose &&
351+
cd test/rcd_test/ &&
352+
bundle install &&
353+
ruby -rrcd_test -S rake test
354+
"
355+
356+
test_arm-linux-musl:
357+
name: arm-linux-musl
358+
needs: build_native_gem
359+
strategy:
360+
fail-fast: false
361+
matrix:
362+
ruby: ["3.3", "3.2", "3.1"] # TODO can we update rubygems and get earlier images working?
363+
platform: [arm-linux-musl]
364+
runs-on: ubuntu-latest
365+
steps:
366+
- uses: actions/checkout@v3
367+
- name: Download gem-${{ matrix.platform }}
368+
uses: actions/download-artifact@v3
369+
with:
370+
name: gem-${{ matrix.platform }}
371+
- name: Run tests
372+
run: |
373+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
374+
docker run --rm -v $PWD:/work -w /work \
375+
--platform=linux/arm/v7 ruby:${{ matrix.ruby }}-alpine \
376+
sh -c "
377+
gem install --local *.gem --verbose &&
378+
cd test/rcd_test/ &&
379+
bundle install &&
380+
ruby -rrcd_test -S rake test
381+
"
382+
320383
test_native_gem:
321384
name: test native
322385
needs: build_native_gem

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.yardoc
33
/Dockerfile.mri.aarch64-linux-gnu
44
/Dockerfile.mri.arm-linux-gnu
5+
/Dockerfile.mri.arm-linux-musl
56
/Dockerfile.mri.arm64-darwin
67
/Dockerfile.mri.x64-mingw-ucrt
78
/Dockerfile.mri.x64-mingw32

Dockerfile.mri.erb

+3-5
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,9 @@ else
148148
]
149149
end
150150

151-
xrubies_build_plan.each do |xrubies, bootstrap_ruby_version| %>
152-
ENV XRUBIES <%= xrubies %>
151+
strip = '-s' if platform !~ /darwin/
153152

154-
<% strip = '-s' if platform !~ /darwin/ %>
155-
# Build xruby versions, then cleanup all build artifacts
153+
xrubies_build_plan.each do |xrubies, bootstrap_ruby_version| %>
156154
RUN bash -c " \
157155
rbenv shell <%= bootstrap_ruby_version %> && \
158156
export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform =~ /x64-mingw-ucrt/ %>' && \
@@ -161,7 +159,7 @@ RUN bash -c " \
161159
<%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
162160
<%= "export CC=#{target}-clang &&" if platform =~ /darwin/ %> \
163161
export MAKE='make V=1' && \
164-
rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
162+
rake-compiler cross-ruby VERSION=<%= xrubies %> HOST=<%= target %> && \
165163
rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources \
166164
"
167165
<% end %>

Rakefile

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ platforms = [
1212
# tuple is [platform, target]
1313
["aarch64-linux-gnu", "aarch64-linux-gnu"],
1414
["arm-linux-gnu", "arm-linux-gnueabihf"],
15+
["arm-linux-musl", "arm-linux-musleabihf"],
1516
["arm64-darwin", "aarch64-apple-darwin"],
1617
["x64-mingw-ucrt", "x86_64-w64-mingw32"],
1718
["x64-mingw32", "x86_64-w64-mingw32"],

build/patches2/rake-compiler-1.2.5/0004-Enable-build-of-static-libruby.patch

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ diff --git a/tasks/bin/cross-ruby.rake b/tasks/bin/cross-ruby.rake
22
index 8317a2a..5a1b3ea 100644
33
--- a/tasks/bin/cross-ruby.rake
44
+++ b/tasks/bin/cross-ruby.rake
5-
@@ -116,10 +116,22 @@ RUBY_CC_VERSIONS.split(":").each do |ruby_cc_version|
5+
@@ -116,10 +116,26 @@ RUBY_CC_VERSIONS.split(":").each do |ruby_cc_version|
66
"--host=#{mingw_host}",
77
"--target=#{mingw_target}",
88
"--build=#{RUBY_BUILD}",
@@ -12,7 +12,8 @@ index 8317a2a..5a1b3ea 100644
1212
'--disable-install-doc',
1313
'--with-ext=',
1414
]
15-
+ if mingw_host=~/darwin/
15+
16+
+ if mingw_host =~ /darwin/
1617
+ options += [
1718
+ '--enable-static',
1819
+ '--disable-shared',
@@ -23,6 +24,9 @@ index 8317a2a..5a1b3ea 100644
2324
+ '--enable-shared',
2425
+ ]
2526
+ end
26-
27+
+
28+
+ # https://github.com/docker-library/ruby/issues/308
29+
+ options << "--with-coroutine=arm32" if major == "2.7" && mingw_target =~ /arm-linux-musl/
30+
+
2731
# Force Winsock2 for Ruby 1.8, 1.9 defaults to it
2832
options << "--with-winsock2" if major == "1.8"

test/rcd_test/Rakefile

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ else
2323
aarch64-linux-gnu
2424
arm-linux
2525
arm-linux-gnu
26+
arm-linux-musl
2627
arm64-darwin
2728
x64-mingw-ucrt
2829
x64-mingw32

0 commit comments

Comments
 (0)