Skip to content

Commit 2917d31

Browse files
committed
Merge branch 'master' into linux/arm64
* master: doc: update History.md gitignore the ucrt Dockerfile reduce gems installed, move things around update base packages for psych and ffi requirements move osxcross building into a script update to rake-compiler 1.2.1 update base images with yaml dev package, for psych 5 turn off parallelism in windows 3.2.0-rc1 build
2 parents 191fdcb + b93b4b0 commit 2917d31

File tree

7 files changed

+120
-95
lines changed

7 files changed

+120
-95
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/Dockerfile.mri.arm-linux
55
/Dockerfile.mri.arm64-darwin
66
/Dockerfile.mri.arm64-linux
7+
/Dockerfile.mri.x64-mingw-ucrt
78
/Dockerfile.mri.x64-mingw32
89
/Dockerfile.mri.x86-linux
910
/Dockerfile.mri.x86-mingw32

Dockerfile.mri.erb

Lines changed: 68 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ manylinux = !!(image =~ /manylinux/)
1010
%>
1111
FROM <%= image %>
1212

13+
##
14+
## RVM and native rubies
15+
##
16+
# Install packages which rvm will require
1317
<% if manylinux %>
14-
# install packages which rvm will require
15-
RUN yum install -y autoconf gcc-c++ libtool readline-devel sqlite-devel ruby openssl-devel xz cmake sudo less libffi-devel git wget
18+
RUN yum install -y sudo ruby less git wget curl autoconf libtool cmake gcc-c++ xz readline-devel sqlite-devel openssl-devel libffi-devel libyaml-devel
1619

1720
# Prepare sudo and delete sudo as alias to gosu
1821
RUN rm -f /usr/local/bin/sudo && \
@@ -21,7 +24,7 @@ RUN rm -f /usr/local/bin/sudo && \
2124
<% else %>
2225
ENV DEBIAN_FRONTEND noninteractive
2326
RUN apt-get -y update && \
24-
apt-get install -y curl git-core xz-utils build-essential zlib1g-dev libreadline-dev libssl-dev wget unzip sudo gnupg2 dirmngr cmake pkg-config autoconf && \
27+
apt-get install -y sudo wget autoconf cmake curl git-core pkg-config build-essential xz-utils unzip gnupg2 dirmngr zlib1g-dev libreadline-dev libsqlite0-dev libssl-dev libyaml-dev libffi-dev && \
2528
rm -rf /var/lib/apt/lists/*
2629
<% end %>
2730

@@ -44,38 +47,31 @@ RUN mkdir ~/.gnupg && \
4447
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
4548
(curl -L http://get.rvm.io | sudo bash) && \
4649
bash -c " \
47-
source /etc/rubybashrc && \
48-
rvm autolibs disable && \
49-
rvmsudo rvm cleanup all "
50+
source /etc/rubybashrc && \
51+
rvm autolibs disable && \
52+
rvmsudo rvm cleanup all \
53+
"
5054

51-
# Import patch files for ruby and gems
55+
# Install native rubies and fix permissions
5256
COPY build/patches /home/rvm/patches/
53-
54-
# install rubies and fix permissions on
5557
ENV RVM_RUBIES 2.5.9 3.1.0
5658
RUN bash -c " \
57-
export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
58-
for v in ${RVM_RUBIES} ; do \
59+
export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
60+
for v in ${RVM_RUBIES} ; do \
5961
rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
60-
done && \
61-
rvm cleanup all && \
62-
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
63-
64-
# Install rake-compiler and typical gems in all Rubies
65-
# do not generate documentation for gems
66-
# TODO: stop pinning rubygems to 3.3.20 once https://github.com/rake-compiler/rake-compiler/pull/209 is merged
67-
RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
68-
bash -c " \
69-
rvm all do gem update --system=3.3.20 --no-document && \
70-
rvm all do gem install --no-document bundler 'bundler:~>1.16' 'rake-compiler:1.1.6' hoe mini_portile rubygems-tasks mini_portile2 && \
71-
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
72-
73-
# Install rake-compiler's cross rubies in global dir instead of /root
74-
RUN sudo mkdir -p /usr/local/rake-compiler && \
75-
sudo chown rvm.rvm /usr/local/rake-compiler && \
76-
ln -s /usr/local/rake-compiler ~/.rake-compiler
62+
done && \
63+
rvm cleanup all \
64+
"
7765

78-
# Add cross compilers for Windows and Linux
66+
RUN bash -c " \
67+
rvm all do gem update --system --no-document && \
68+
rvm all do gem update --no-document && \
69+
rvm all do gem install bundler --no-document \
70+
"
71+
72+
##
73+
## Cross compilers
74+
##
7975
USER root
8076

8177
<% if platform=~/x64-mingw-ucrt/ %>
@@ -100,77 +96,46 @@ if platform=~/x64-mingw32/ %> gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 <% end
10096
rm -rf /var/lib/apt/lists/*
10197
<% end %>
10298

103-
RUN bash -c " \
104-
rvm alias create default 3.1.0 && \
105-
rvm use default "
106-
10799
<% if manylinux %>
108100
# Create dev tools x86-linux-*
109101
COPY build/mk_i686.rb /root/
110-
RUN bash -c " \
111-
ruby /root/mk_i686.rb "
102+
RUN /root/mk_i686.rb
112103
<% end %>
113104

114105
<% if platform=~/darwin/ %>
115-
RUN git clone -q --depth=1 https://github.com/tpoechtrager/osxcross.git /opt/osxcross && rm -rf /opt/osxcross/.git && \
116-
cd /opt/osxcross/tarballs && \
117-
curl -L -o MacOSX11.1.sdk.tar.xz https://github.com/larskanis/MacOSX-SDKs/releases/download/11.1/MacOSX11.1.sdk.tar.xz && \
118-
tar -xf MacOSX11.1.sdk.tar.xz -C . && \
119-
cp -rf /usr/lib/llvm-10/include/c++ MacOSX11.1.sdk/usr/include/c++ && \
120-
cp -rf /usr/include/"$(uname -m)"-linux-gnu/c++/9/bits/ MacOSX11.1.sdk/usr/include/c++/v1/bits && \
121-
tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk && \
122-
cd /opt/osxcross && \
123-
UNATTENDED=1 SDK_VERSION=11.1 OSX_VERSION_MIN=10.13 USE_CLANG_AS=1 ./build.sh && \
124-
ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config && \
125-
ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=11.1 ./build_compiler_rt.sh && \
126-
rm -rf *~ build tarballs/*
127-
128-
RUN echo "export PATH=/opt/osxcross/target/bin:\$PATH" >> /etc/rubybashrc && \
129-
echo "export MACOSX_DEPLOYMENT_TARGET=10.13" >> /etc/rubybashrc && \
130-
echo "export OSXCROSS_MP_INC=1" >> /etc/rubybashrc
131-
132-
# Add links to build tools without target version kind of:
133-
# arm64-apple-darwin-clang => arm64-apple-darwin20.1-clang
134-
RUN rm /opt/osxcross/target/bin/*-apple-darwin-* ; \
135-
find /opt/osxcross/target/bin/ -name '*-apple-darwin[0-9]*' | sort | while read f ; do d=`echo $f | sed s/darwin[0-9\.]*/darwin/`; echo $f '"$@"' | tee $d && chmod +x $d ; done
136-
137-
# There's no objdump in osxcross but we can use llvm's
138-
RUN ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/x86_64-apple-darwin-objdump && \
139-
ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/aarch64-apple-darwin-objdump
140-
106+
COPY build/mk_osxcross.sh /home/rvm
107+
RUN /home/rvm/mk_osxcross.sh
141108
<% end %>
142109

143-
# Patch rake-compiler to build and install static libraries for Linux rubies
110+
111+
##
112+
## Cross-compile rubies
113+
##
144114
USER rvm
115+
116+
RUN bash -c "rvm all do gem install --no-document rake-compiler:1.2.1"
117+
118+
# Install rake-compiler's cross rubies in global dir instead of /root
119+
RUN sudo mkdir -p /usr/local/rake-compiler && \
120+
sudo chown rvm.rvm /usr/local/rake-compiler && \
121+
ln -s /usr/local/rake-compiler ~/.rake-compiler
122+
123+
# Patch rake-compiler to build and install static libraries for Linux rubies
145124
COPY build/patches2 /home/rvm/patches/
146125
RUN bash -c " \
147-
for v in ${RVM_RUBIES} ; do \
148-
cd /usr/local/rvm/gems/ruby-\$v/gems/rake-compiler-1.1.6 && \
149-
echo applying patches to ruby-\$v /home/rvm/patches/rake-compiler-1.1.6/*.patch && \
150-
( git apply /home/rvm/patches/rake-compiler-1.1.6/*.patch || true ) \
151-
done "
152-
153-
# Patch rubies for cross build
154-
#USER root
155-
#RUN bash -c " \
156-
# for v in 2.7.0 3.0.0 3.1.0 ; do \
157-
# curl -SL http://cache.ruby-lang.org/pub/ruby/\${v:0:3}/ruby-\$v.tar.xz | tar -xJC /root/ && \
158-
# cd /root/ruby-\$v && \
159-
# git apply /home/rvm/patches/ruby-\$v/*.patch && \
160-
# cd .. && \
161-
# mkdir -p /usr/local/rake-compiler/sources/ && \
162-
# tar cjf /usr/local/rake-compiler/sources/ruby-\$v.tar.bz2 ruby-\$v && \
163-
# chown rvm /usr/local/rake-compiler -R && \
164-
# rm -rf /root/ruby-\$v ; \
165-
# done "
166-
#USER rvm
126+
for v in ${RVM_RUBIES} ; do \
127+
cd /usr/local/rvm/gems/ruby-\$v/gems/rake-compiler-1.2.1 && \
128+
echo applying patches to ruby-\$v /home/rvm/patches/rake-compiler-1.2.1/*.patch && \
129+
( git apply /home/rvm/patches/rake-compiler-1.2.1/*.patch || true ) \
130+
done \
131+
"
167132

168133
<%
169134
axrubies = if platform =~ /x64-mingw-ucrt/
170135
[
171136
# Rubyinstaller-3.1.0+ is platform x64-mingw-ucrt
172-
["3.2.0-rc1", "3.1.0", true],
173-
["3.1.0", "3.1.0", true],
137+
# parallel=false because 3.2.0-rc1 has undefined references when using a high -j arg
138+
["3.2.0-rc1:3.1.0", "3.1.0", false],
174139
]
175140
elsif platform =~ /x64-mingw32/
176141
[
@@ -194,16 +159,16 @@ ENV XRUBIES <%= xrubies %>
194159
# Build xruby versions in parallel
195160
# Then cleanup all build artifacts
196161
RUN bash -c " \
197-
rvm use <%= rvm %> && \
198-
export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform=~/x64-mingw-ucrt/ %>' && \
199-
export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %>' && \
200-
export LDFLAGS='-pipe <%= strip %>' && \
201-
<%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
202-
<%= "export CC=#{target}-clang &&" if platform =~ /darwin/ %> \
203-
export MAKE='make V=1 <%= "-j`nproc`" if parallel %>' && \
204-
rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
205-
rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources && \
206-
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
162+
rvm use <%= rvm %> && \
163+
export CPPFLAGS='<%= "-D__USE_MINGW_ANSI_STDIO=1" if platform=~/x64-mingw-ucrt/ %>' && \
164+
export CFLAGS='-O1 -fno-omit-frame-pointer -fno-fast-math -fstack-protector-strong <%= strip %>' && \
165+
export LDFLAGS='-pipe <%= strip %>' && \
166+
<%= "export LIBS='-l:libssp.a' &&" if platform =~ /mingw/ %> \
167+
<%= "export CC=#{target}-clang &&" if platform =~ /darwin/ %> \
168+
export MAKE='make V=1 <%= "-j`nproc`" if parallel %>' && \
169+
rake-compiler cross-ruby VERSION=$XRUBIES HOST=<%= target %> && \
170+
rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources \
171+
"
207172
<% end %>
208173

209174
<% if platform=~/linux/ %>
@@ -224,12 +189,14 @@ RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed
224189
RUN find /usr/local/rake-compiler/ruby -name lib*-ruby*.dll.a | while read f ; do n=`echo $f | sed s/.dll//` ; mv $f $n ; done
225190
<% end %>
226191

192+
##
193+
## Final adjustments
194+
##
227195
USER root
228196

229197
# Fix paths in rake-compiler/config.yml
230198
RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml
231199

232-
233200
<% if platform=~/mingw/ %>
234201
# Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
235202
COPY build/strip_wrapper /root/
@@ -276,6 +243,12 @@ RUN echo "source /etc/profile.d/rcd-env.sh" >> /etc/rubybashrc
276243
# Install sudoers configuration
277244
COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
278245

246+
RUN find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw
247+
RUN bash -c " \
248+
rvm alias create default 3.1.0 && \
249+
rvm use default \
250+
"
251+
279252
ENV RUBY_CC_VERSION 3.2.0:3.1.0:3.0.0:2.7.0:2.6.0:2.5.0:2.4.0
280253

281254
CMD bash

History.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
1.3.0 / unreleased
2+
------------------
3+
4+
* Add Ruby-3.2 cross-compilation support.
5+
* Update RVM installations to latest rubygems.
6+
* Update to rake-compiler 1.2.1.
7+
* Reduce pre-installed gems to only rake-compiler and bundler.
8+
* Install yaml and ffi development headers in the base images, for psych and ffi gem compilation.
9+
* Ensure autoconf is installed in the base iamges.
10+
11+
112
1.2.2 / 2022-06-27
213
------------------
314

build/mk_i686.rb

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /usr/bin/env ruby
2+
13
require "fileutils"
24

35
Dir["/usr/bin/x86_64-linux-gnu-*"].each do |file|

build/mk_osxcross.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#! /usr/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
set -x
6+
7+
git clone -q --depth=1 https://github.com/tpoechtrager/osxcross.git /opt/osxcross
8+
rm -rf /opt/osxcross/.git
9+
10+
set +x
11+
cd /opt/osxcross/tarballs
12+
set -x
13+
curl -L -o MacOSX11.1.sdk.tar.xz https://github.com/larskanis/MacOSX-SDKs/releases/download/11.1/MacOSX11.1.sdk.tar.xz
14+
tar -xf MacOSX11.1.sdk.tar.xz -C .
15+
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
17+
tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk
18+
19+
set +x
20+
cd /opt/osxcross
21+
set -x
22+
UNATTENDED=1 SDK_VERSION=11.1 OSX_VERSION_MIN=10.13 USE_CLANG_AS=1 ./build.sh
23+
ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config
24+
ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=11.1 ./build_compiler_rt.sh
25+
rm -rf *~ build tarballs/*
26+
27+
echo "export PATH=/opt/osxcross/target/bin:\$PATH" >> /etc/rubybashrc
28+
echo "export MACOSX_DEPLOYMENT_TARGET=10.13" >> /etc/rubybashrc
29+
echo "export OSXCROSS_MP_INC=1" >> /etc/rubybashrc
30+
31+
# Add links to build tools without target version kind of:
32+
# arm64-apple-darwin-clang => arm64-apple-darwin20.1-clang
33+
rm -f /opt/osxcross/target/bin/*-apple-darwin-*
34+
find /opt/osxcross/target/bin/ -name '*-apple-darwin[0-9]*' | sort | while read f ; do d=`echo $f | sed s/darwin[0-9\.]*/darwin/`; echo $f '"$@"' | tee $d && chmod +x $d ; done
35+
36+
# There's no objdump in osxcross but we can use llvm's
37+
ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/x86_64-apple-darwin-objdump
38+
ln -s /usr/lib/llvm-10/bin/llvm-objdump /opt/osxcross/target/bin/aarch64-apple-darwin-objdump

0 commit comments

Comments
 (0)