Skip to content

Commit ae530dc

Browse files
committed
Allow using multiplatform images
This way we can provide not only images running on x86_64 but also aarch64. The docker platform names are "linux/amd64" and "linux/arm64". On the native platform (x86_64-linux or aarch64-linux) ruby configure script finds libz and libcrypt and makes use of it in libruby. Disabling them per ac_cv_* variables unifies cross builds and we can remove platform specific injection of -lz and -lcrypt into mkmf.rb . Fixes #78
1 parent cc37afb commit ae530dc

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-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-* && \

0 commit comments

Comments
 (0)