Skip to content

Commit aa27315

Browse files
authored
Merge pull request #137 from rake-compiler/multiplat
Allow using multiplatform images
2 parents cc37afb + 26eaa65 commit aa27315

File tree

5 files changed

+76
-10
lines changed

5 files changed

+76
-10
lines changed

Dockerfile.mri.erb

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ ENV BASH_ENV=/etc/rubybashrc
3737
##
3838
<% if platform =~ /x64-mingw-ucrt/ %>
3939
COPY --from=larskanis/mingw64-ucrt:20.04 \
40-
/build/binutils-mingw-w64-x86-64_2.34-6ubuntu1.3+8.8_amd64.deb \
41-
/build/g++-mingw-w64-x86-64_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
42-
/build/gcc-mingw-w64-base_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
43-
/build/gcc-mingw-w64-x86-64_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
44-
/build/mingw-w64-common_7.0.0-2_all.deb \
45-
/build/mingw-w64-x86-64-dev_7.0.0-2_all.deb \
40+
/build/binutils-mingw-w64-x86-64_*.deb \
41+
/build/g++-mingw-w64-x86-64_*.deb \
42+
/build/gcc-mingw-w64-base_*.deb \
43+
/build/gcc-mingw-w64-x86-64_*.deb \
44+
/build/mingw-w64-common_*.deb \
45+
/build/mingw-w64-x86-64-dev_*.deb \
4646
/debs/
4747
RUN dpkg -i /debs/*.deb
4848

@@ -57,6 +57,7 @@ if platform =~ /darwin/ %> clang python lzma-dev libxml2-dev libssl-d
5757
if platform =~ /aarch64-linux-gnu/ %> gcc-aarch64-linux-gnu g++-aarch64-linux-gnu <% end %><%
5858
if platform =~ /arm-linux-gnu/ %> gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf <% end %><%
5959
if platform =~ /x86-linux-gnu/ %> gcc-i686-linux-gnu g++-i686-linux-gnu <% end %><%
60+
if platform =~ /x86_64-linux-gnu/ %> gcc-x86-64-linux-gnu g++-x86-64-linux-gnu <% end %><%
6061
if platform =~ /x86-mingw32/ %> gcc-mingw-w64-i686 g++-mingw-w64-i686 <% end %><%
6162
if platform =~ /x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end %> && \
6263
rm -rf /var/lib/apt/lists/*
@@ -148,7 +149,7 @@ RUN bash -c " \
148149
RUN find /usr/local/rake-compiler/ruby/*linux*/ -name libruby.so | xargs rm
149150
RUN find /usr/local/rake-compiler/ruby/*linux*/ -name libruby-static.a | while read f ; do cp $f `echo $f | sed s/-static//` ; done
150151
RUN find /usr/local/rake-compiler/ruby/*linux*/ -name libruby.a | while read f ; do ar t $f | xargs ar d $f ; done
151-
RUN find /usr/local/rake-compiler/ruby/*linux*/ -name mkmf.rb | while read f ; do sed -i ':a;N;$!ba;s/TRY_LINK = [^\n]*\n[^\n]*\n[^\n]*LOCAL_LIBS)/& -lruby-static -lpthread -lrt -ldl <% if platform =~ /x86_64/ %> -lcrypt <% if platform !~ /musl/ %> -lz <% end %> <% end %>/' $f ; done
152+
RUN find /usr/local/rake-compiler/ruby/*linux*/ -name mkmf.rb | while read f ; do sed -i ':a;N;$!ba;s/TRY_LINK = [^\n]*\n[^\n]*\n[^\n]*LOCAL_LIBS)/& -lruby-static -lpthread -lrt -ldl/' $f ; done
152153
<% end %>
153154

154155
<% if platform =~ /mingw/ %>

build/mk_osxcross.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set -x
1313
curl -L -o MacOSX11.1.sdk.tar.xz https://github.com/larskanis/MacOSX-SDKs/releases/download/11.1/MacOSX11.1.sdk.tar.xz
1414
tar -xf MacOSX11.1.sdk.tar.xz -C .
1515
cp -rf /usr/lib/llvm-10/include/c++ MacOSX11.1.sdk/usr/include/c++
16-
cp -rf /usr/include/x86_64-linux-gnu/c++/9/bits/ MacOSX11.1.sdk/usr/include/c++/v1/bits
16+
cp -rf /usr/include/*-linux-gnu/c++/9/bits/ MacOSX11.1.sdk/usr/include/c++/v1/bits
1717
tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk
1818

1919
set +x

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ 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,27 @@
5+
@@ -116,11 +116,30 @@
66
"--host=#{mingw_host}",
77
"--target=#{mingw_target}",
88
"--build=#{RUBY_BUILD}",
99
- '--enable-shared',
1010
+ '--enable-install-static-library',
1111
+ '--disable-jit-support',
12+
+ 'ac_cv_lib_z_uncompress=no',
13+
+ 'ac_cv_lib_crypt_crypt=no',
14+
+ 'ac_cv_func_crypt_r=no',
1215
'--disable-install-doc',
1316
'--with-ext=',
1417
]

mingw64-ucrt/Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN cd mingw-w64-* && \
3232

3333
# Install UCRT enabled deb-packages
3434
RUN dpkg -i mingw-w64-common_7.0.0-2_all.deb \
35-
mingw-w64-tools_7.0.0-2_amd64.deb \
35+
mingw-w64-tools_7.0.0-2_*.deb \
3636
mingw-w64-x86-64-dev_7.0.0-2_all.deb
3737

3838
# Download gcc-binutils sources for mingw
@@ -52,6 +52,10 @@ RUN apt-get source gcc-mingw-w64 && \
5252
cd gcc-mingw-w64-* && \
5353
mk-build-deps -ir -t "apt-get -o Debug::pkgProblemResolver=yes -y --no-install-recommends"
5454

55+
# Add version based alias
56+
RUN ln -s `which autoconf` `which autoconf`2.69 && \
57+
ln -s `which autom4te` `which autom4te`2.69
58+
5559
# Build gcc (only C and C++) based on UCRT headers and crt
5660
ADD gcc-mingw-w64-*.patch ./
5761
RUN cd gcc-mingw-w64-* && \

mingw64-ucrt/README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Docker image with compilers for ruby platform x64-mingw-ucrt
2+
------------------
3+
4+
This Dockerfile builds compilers for Windows UCRT target.
5+
It takes the mingw compiler provided by Debian/Ubuntu and configures and compiles them for UCRT.
6+
Outputs are *.deb files of binutils, gcc and g++.
7+
Rake-compiler-dock reads them from this image as part of its build process for the x64-mingw-ucrt platform.
8+
9+
The image is provided for arm64 and amd64 architectures.
10+
They are built by the following command:
11+
12+
```sh
13+
docker buildx build . -t larskanis/mingw64-ucrt:20.04 --platform linux/arm64,linux/amd64 --push
14+
```
15+
16+
17+
Create builder instance for two architectures
18+
------------------
19+
20+
Building with qemu emulation fails currently with a segfault, so that it must be built by a builder instance with at least one remote node for the other architecture.
21+
Building on native hardware is also much faster (~30 minutes) than on qemu.
22+
A two-nodes builder requires obviously a ARM and a Intel/AMD device.
23+
It can be created like this:
24+
25+
```sh
26+
# Make sure the remote instance can be connected
27+
$ docker -H ssh://isa info
28+
29+
# Create a new builder with the local instance
30+
$ docker buildx create --name isayoga
31+
32+
# Add the remote instance
33+
$ docker buildx create --name isayoga --append ssh://isa
34+
35+
# They are inactive from the start
36+
$ docker buildx ls
37+
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
38+
isayoga docker-container
39+
\_ isayoga0 \_ unix:///var/run/docker.sock inactive
40+
\_ isayoga1 \_ ssh://isa inactive
41+
default* docker
42+
\_ default \_ default running v0.13.2 linux/arm64
43+
44+
# Bootstrap the instances
45+
$ docker buildx inspect --bootstrap --builder isayoga
46+
47+
# Set the new builder as default
48+
$ docker buildx use isayoga
49+
50+
# Now it should be default and in state "running"
51+
$ docker buildx ls
52+
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
53+
isayoga* docker-container
54+
\_ isayoga0 \_ unix:///var/run/docker.sock running v0.18.2 linux/arm64
55+
\_ isayoga1 \_ ssh://isa running v0.18.2 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386
56+
default docker
57+
\_ default \_ default running v0.13.2 linux/arm64
58+
```

0 commit comments

Comments
 (0)