Skip to content

Commit d0f0510

Browse files
authored
Merge pull request #152 from rake-compiler/add-woa
Add new platform aarch64-mingw-ucrt aka Windows on ARM
2 parents 95e6149 + a0f1718 commit d0f0510

File tree

9 files changed

+34
-3
lines changed

9 files changed

+34
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
- platform: aarch64-linux-gnu
4949
alias: aarch64-linux
5050
- platform: aarch64-linux-musl
51+
- platform: aarch64-mingw-ucrt
5152
- platform: arm-linux-gnu
5253
alias: arm-linux
5354
- platform: arm-linux-musl

.github/workflows/publish-images.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
platform:
1616
- aarch64-linux-gnu
1717
- aarch64-linux-musl
18+
- aarch64-mingw-ucrt
1819
- arm-linux-gnu
1920
- arm-linux-musl
2021
- arm64-darwin

.github/workflows/release-images.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
platform:
2323
- aarch64-linux-gnu
2424
- aarch64-linux-musl
25+
- aarch64-mingw-ucrt
2526
- arm-linux-gnu
2627
- arm-linux-musl
2728
- arm64-darwin

Dockerfile.mri.erb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ COPY --from=larskanis/mingw64-ucrt:20.04 \
2424
/debs/
2525
RUN dpkg -i /debs/*.deb
2626

27+
<% elsif platform =~ /aarch64-mingw-ucrt/ %>
28+
RUN wget https://github.com/mstorsjo/llvm-mingw/releases/download/20250114/llvm-mingw-20250114-ucrt-ubuntu-20.04-<%= RUBY_PLATFORM[/^\w+/] %>.tar.xz && \
29+
tar xf llvm-mingw*.tar.xz && \
30+
mv `ls -d llvm-mingw-*/` /llvm-mingw && \
31+
echo "export PATH=/llvm-mingw/bin:\$PATH" >> /etc/rubybashrc && \
32+
rm -r /llvm-mingw/bin/i686-w64* /llvm-mingw/bin/armv7-w64* /llvm-mingw/bin/x86_64-w64* /llvm-mingw/i686-w64* /llvm-mingw/armv7-w64* /llvm-mingw/x86_64-w64*
33+
2734
<% elsif platform =~ /linux-musl/ %>
2835
COPY build/mk_musl_cross.sh /tmp
2936
RUN /tmp/mk_musl_cross.sh <%= target %>
@@ -116,6 +123,10 @@ xrubies_build_plan = if platform =~ /x64-mingw-ucrt/
116123
# Rubyinstaller-3.1+ is platform x64-mingw-ucrt
117124
["3.4.1:3.3.7:3.2.6:3.1.6", "3.4.1"],
118125
]
126+
elsif platform =~ /aarch64-mingw-ucrt/
127+
[
128+
["3.4.1", "3.1.6"],
129+
]
119130
elsif platform =~ /x64-mingw32/
120131
[
121132
# Rubyinstaller prior to 3.1 is platform x64-mingw32
@@ -128,7 +139,7 @@ else
128139
]
129140
end
130141

131-
strip = '-s' if platform !~ /darwin/
142+
strip = '-s' if platform !~ /darwin|aarch64-mingw/
132143

133144
xrubies_build_plan.each do |xrubies, bootstrap_ruby_version| %>
134145
RUN bash -c " \
@@ -179,7 +190,7 @@ RUN find /usr/local/rake-compiler/ruby/*/*/lib/ruby -name rbconfig.rb | while re
179190
##
180191
USER root
181192

182-
<% if platform =~ /mingw/ %>
193+
<% if platform =~ /(x64|x86)-mingw/ %>
183194
# Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
184195
COPY build/strip_wrapper_vbox /root/
185196
RUN mv /usr/bin/<%= target %>-strip /usr/bin/<%= target %>-strip.bin && \
@@ -192,6 +203,16 @@ RUN printf "1\n" | update-alternatives --config <%= target %>-gcc && \
192203
printf "1\n" | update-alternatives --config <%= target %>-g++
193204
<% end %>
194205

206+
<% if platform =~ /aarch64-mingw/ %>
207+
# Fool libtool to allow building a shared library although linking to libclang_rt.builtins-aarch64.a
208+
#
209+
# Linker option "-llibclang_rt.builtins-aarch64.a" is required on Windows on ARM when compiling C++ and when clang is called with -nostdlib (due to be invoked by libtool).
210+
# Unfortunately libtool then forces a static build.
211+
# This is a ugly hack to make libtool beleave that the library is a DLL instead of an archive and to allow building a DLL instand.
212+
#
213+
RUN sudo cp /llvm-mingw/aarch64-w64-mingw32/bin/libc++.dll /llvm-mingw/aarch64-w64-mingw32/lib/libclang_rt.builtins-aarch64.0
214+
<% end %>
215+
195216
<% if platform =~ /darwin/ %>
196217
# Install wrapper around strip to re-sign binaries (ad-hoc signature)
197218
COPY build/strip_wrapper_codesign /root/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The following platforms are supported for cross-compilation by rake-compiler-doc
1616

1717
- `aarch64-linux` and `aarch64-linux-gnu`
1818
- `aarch64-linux-musl`
19+
- `aarch64-mingw-ucrt`
1920
- `arm-linux` and `arm-linux-gnu`
2021
- `arm-linux-musl`
2122
- `arm64-darwin`
@@ -191,6 +192,7 @@ This can be done like this:
191192
PLATFORMS = %w[
192193
aarch64-linux-gnu
193194
aarch64-linux-musl
195+
aarch64-mingw-ucrt
194196
arm-linux-gnu
195197
arm-linux-musl
196198
arm64-darwin

Rakefile

Lines changed: 1 addition & 0 deletions
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
["aarch64-linux-musl", "aarch64-linux-musl"],
15+
["aarch64-mingw-ucrt", "aarch64-w64-mingw32"],
1516
["arm-linux-gnu", "arm-linux-gnueabihf"],
1617
["arm-linux-musl", "arm-linux-musleabihf"],
1718
["arm64-darwin", "aarch64-apple-darwin"],

build/patches/rake-compiler-1.2.9/0004-Enable-build-of-static-libruby.patch

Lines changed: 2 additions & 1 deletion
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 8317a2a3..8ed21718 100644
33
--- a/tasks/bin/cross-ruby.rake
44
+++ b/tasks/bin/cross-ruby.rake
5-
@@ -116,11 +116,30 @@
5+
@@ -116,11 +116,31 @@
66
"--host=#{mingw_host}",
77
"--target=#{mingw_target}",
88
"--build=#{RUBY_BUILD}",
@@ -12,6 +12,7 @@ index 8317a2a3..8ed21718 100644
1212
+ 'ac_cv_lib_z_uncompress=no',
1313
+ 'ac_cv_lib_crypt_crypt=no',
1414
+ 'ac_cv_func_crypt_r=no',
15+
+ 'extra_warnflags=-Wno-shorten-64-to-32 -Wno-dll-attribute-on-redeclaration',
1516
'--disable-install-doc',
1617
'--with-ext=',
1718
]

test/rcd_test/Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ else
2222
aarch64-linux
2323
aarch64-linux-gnu
2424
aarch64-linux-musl
25+
aarch64-mingw-ucrt
2526
arm-linux
2627
arm-linux-gnu
2728
arm-linux-musl

test/rcd_test/ext/mri/extconf.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
puts "cc --version: #{ %x[#{CONFIG['CC']} --version].lines.first}"
1919
puts "-"*70
2020

21+
$CFLAGS << " -Wall -Werror"
22+
2123
have_func('rb_thread_call_without_gvl', 'ruby/thread.h') ||
2224
raise("rb_thread_call_without_gvl() not found")
2325

0 commit comments

Comments
 (0)