Skip to content

Commit 78b8703

Browse files
committed
chore: update joseluisq/docker-osxcross to 1.0.0-beta.2
1 parent cb84e4c commit 78b8703

File tree

3 files changed

+194
-78
lines changed

3 files changed

+194
-78
lines changed

Makefile

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build:
66
docker build \
77
-t $(REPOSITORY)/rust-linux-darwin-builder:$(TAG) \
88
--network=host \
9-
-f Dockerfile .
9+
-f docker/amd64/Dockerfile .
1010
.PHONY: build
1111

1212
# Use to build both arm64 and amd64 images at the same time.
@@ -50,21 +50,23 @@ test-app:
5050
@echo
5151
@cd tests/hello-world \
5252
\
53+
&& echo "Compiling application (linux-gnu x86_64)..." \
54+
&& cargo build --release --target x86_64-unknown-linux-gnu \
5355
&& if [ "$$(uname -m)" = "x86_64" ]; then \
54-
echo "Compiling application (linux-gnu x86_64)..."; \
55-
cargo build --release --target x86_64-unknown-linux-gnu; \
5656
target/x86_64-unknown-linux-gnu/release/hello-world-test; \
57-
du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test; \
58-
file target/x86_64-unknown-linux-gnu/release/hello-world-test; \
59-
echo; \
57+
fi \
58+
&& du -sh target/x86_64-unknown-linux-gnu/release/hello-world-test \
59+
&& file target/x86_64-unknown-linux-gnu/release/hello-world-test \
60+
&& echo \
6061
\
61-
echo "Compiling application (linux-musl x86_64)..."; \
62-
cargo build --release --target x86_64-unknown-linux-musl; \
62+
&& echo "Compiling application (linux-musl x86_64)..." \
63+
&& cargo build --release --target x86_64-unknown-linux-musl \
64+
&& if [ "$$(uname -m)" = "x86_64" ]; then \
6365
target/x86_64-unknown-linux-musl/release/hello-world-test; \
64-
du -sh target/x86_64-unknown-linux-musl/release/hello-world-test; \
65-
file target/x86_64-unknown-linux-musl/release/hello-world-test; \
66-
echo; \
6766
fi \
67+
&& du -sh target/x86_64-unknown-linux-musl/release/hello-world-test \
68+
&& file target/x86_64-unknown-linux-musl/release/hello-world-test \
69+
&& echo \
6870
\
6971
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
7072
&& cargo build --release --target x86_64-apple-darwin \
@@ -94,6 +96,7 @@ test-app:
9496
&& cargo build --release --target aarch64-apple-darwin \
9597
&& du -sh target/aarch64-apple-darwin/release/hello-world-test \
9698
&& file target/aarch64-apple-darwin/release/hello-world-test
99+
&& echo
97100
.ONESHELL: test-app
98101

99102
test-zlib:
@@ -105,30 +108,34 @@ test-zlib:
105108
@echo
106109
@cd tests/zlib \
107110
\
108-
&& if [ "$$(uname -m)" = "x86_64" ]; then \
109-
echo "Compiling application (linux-gnu x86_64)..."; \
110-
cargo build --release --target x86_64-unknown-linux-gnu; \
111+
&& echo "Compiling application (linux-gnu x86_64)..." \
112+
&& cargo build --release --target x86_64-unknown-linux-gnu \
113+
&& if [ "$$(uname -m)" = "x86_64" ]; then
111114
target/x86_64-unknown-linux-gnu/release/zlib-test; \
112-
du -sh target/x86_64-unknown-linux-gnu/release/zlib-test; \
113-
file target/x86_64-unknown-linux-gnu/release/zlib-test; \
114-
echo; \
115+
fi \
116+
&& du -sh target/x86_64-unknown-linux-gnu/release/zlib-test \
117+
&& file target/x86_64-unknown-linux-gnu/release/zlib-test \
118+
&& echo \
115119
\
116-
echo "Compiling application (linux-musl x86_64)..."; \
117-
cargo build --release --target x86_64-unknown-linux-musl; \
120+
&& echo "Compiling application (linux-musl x86_64)..." \
121+
&& cargo build --release --target x86_64-unknown-linux-musl \
122+
&& if [ "$$(uname -m)" = "x86_64" ]; then
118123
target/x86_64-unknown-linux-musl/release/zlib-test; \
119-
du -sh target/x86_64-unknown-linux-musl/release/zlib-test; \
120-
file target/x86_64-unknown-linux-musl/release/zlib-test; \
121-
echo; \
122124
fi \
125+
&& du -sh target/x86_64-unknown-linux-musl/release/zlib-test \
126+
&& file target/x86_64-unknown-linux-musl/release/zlib-test \
127+
&& echo \
123128
\
124129
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
125-
&& LIBZ_SYS_STATIC=1 CC=o64-clang CXX=o64-clang++ \
130+
&& CC=o64-clang CXX=o64-clang++ \
126131
cargo build --release --target x86_64-apple-darwin \
127132
&& du -sh target/x86_64-apple-darwin/release/zlib-test \
128133
&& file target/x86_64-apple-darwin/release/zlib-test \
134+
&& echo \
129135
\
130136
&& echo "Cross-compiling application (linux-gnu aarch64)..." \
131-
&& CC=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu \
137+
&& CC=aarch64-linux-gnu-gcc \
138+
cargo build --release --target aarch64-unknown-linux-gnu \
132139
&& if [ "$$(uname -m)" = "aarch64" ]; then \
133140
target/aarch64-unknown-linux-gnu/release/zlib-test; \
134141
fi \
@@ -146,7 +153,7 @@ test-zlib:
146153
&& echo \
147154
\
148155
&& echo "Cross-compiling application (apple-darwin aarch64)..." \
149-
&& LIBZ_SYS_STATIC=1 CC=oa64-clang CXX=oa64-clang++ \
156+
&& CC=oa64-clang CXX=oa64-clang++ \
150157
cargo build --release --target aarch64-apple-darwin \
151158
&& du -sh target/aarch64-apple-darwin/release/zlib-test \
152159
&& file target/aarch64-apple-darwin/release/zlib-test
@@ -162,34 +169,49 @@ test-openssl:
162169
@echo
163170
@cd tests/openssl \
164171
\
172+
&& echo "Compiling application (linux-gnu x86_64)..." \
173+
&& cargo build --release --target x86_64-unknown-linux-gnu \
165174
&& if [ "$$(uname -m)" = "x86_64" ]; then \
166-
echo "Compiling application (linux-gnu x86_64)..."; \
167-
cargo build --release --target x86_64-unknown-linux-gnu; \
168175
target/x86_64-unknown-linux-gnu/release/openssl; \
169-
du -sh target/x86_64-unknown-linux-gnu/release/openssl; \
170-
file target/x86_64-unknown-linux-gnu/release/openssl; \
171-
echo; \
176+
fi \
177+
&& du -sh target/x86_64-unknown-linux-gnu/release/openssl \
178+
&& file target/x86_64-unknown-linux-gnu/release/openssl \
179+
&& echo \
172180
\
173-
echo "Compiling application (linux-musl x86_64)..."; \
174-
OPENSSL_STATIC=1 \
175-
cargo build --release --target x86_64-unknown-linux-musl; \
181+
&& echo "Cross-compiling application (linux-gnu aarch64)..." \
182+
&& CC=aarch64-linux-gnu-gcc \
183+
cargo build --release --target aarch64-unknown-linux-gnu \
184+
&& if [ "$$(uname -m)" = "aarch64" ]; then \
185+
target/aarch64-unknown-linux-gnu/release/openssl; \
186+
fi \
187+
&& du -sh target/aarch64-unknown-linux-gnu/release/openssl \
188+
&& file target/aarch64-unknown-linux-gnu/release/openssl \
189+
&& echo \
190+
\
191+
&& echo "Compiling application (linux-musl x86_64)..." \
192+
&& OPENSSL_STATIC=1 \
193+
cargo build --release --target x86_64-unknown-linux-musl \
194+
&& if [ "$$(uname -m)" = "x86_64" ]; then \
176195
target/x86_64-unknown-linux-musl/release/openssl; \
177-
du -sh target/x86_64-unknown-linux-musl/release/openssl; \
178-
file target/x86_64-unknown-linux-musl/release/openssl; \
179-
echo; \
180196
fi \
197+
&& du -sh target/x86_64-unknown-linux-musl/release/openssl \
198+
&& file target/x86_64-unknown-linux-musl/release/openssl \
199+
&& echo \
181200
\
182201
&& echo "Cross-compiling application (apple-darwin x86_64)..." \
183202
&& OPENSSL_STATIC=1 \
184203
CC=o64-clang CXX=o64-clang++ \
185-
cargo build --release --target x86_64-apple-darwin \
204+
cargo build --release --target x86_64-apple-darwin \
186205
&& du -sh target/x86_64-apple-darwin/release/openssl \
187206
&& file target/x86_64-apple-darwin/release/openssl \
188207
&& echo \
189208
\
190209
&& echo "Cross-compiling application (linux-musl aarch64)..." \
191210
&& OPENSSL_STATIC=1 \
192211
cargo build --release --target aarch64-unknown-linux-musl \
212+
&& if [ "$$(uname -m)" = "aarch64" ]; then \
213+
target/aarch64-unknown-linux-musl/release/openssl;
214+
fi \
193215
&& du -sh target/aarch64-unknown-linux-musl/release/openssl \
194216
&& file target/aarch64-unknown-linux-musl/release/openssl \
195217
&& echo \
@@ -200,5 +222,6 @@ test-openssl:
200222
cargo build --release --target aarch64-apple-darwin \
201223
&& du -sh target/aarch64-apple-darwin/release/openssl \
202224
&& file target/aarch64-apple-darwin/release/openssl \
203-
&& echo \
225+
&& echo
226+
204227
.ONESHELL: test-openssl

docker/amd64/Dockerfile

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM joseluisq/docker-osxcross:1.0.0-beta.1
1+
FROM joseluisq/docker-osxcross:1.0.0-beta.2
22

33
ARG VERSION=0.0.0
44
ENV VERSION=${VERSION}
@@ -45,49 +45,76 @@ RUN set -eux \
4545

4646
##### Libraries
4747

48+
# pkg-config related environment variables
49+
ENV PKG_CONFIG_ALLOW_CROSS=true
50+
ENV PKG_CONFIG_ALL_STATIC=true
51+
52+
RUN set -eux \
53+
&& dpkg --add-architecture arm64 \
54+
&& DEBIAN_FRONTEND=noninteractive apt-get update -qq \
55+
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends --no-install-suggests \
56+
musl-dev \
57+
musl-dev:arm64 \
58+
musl-tools \
59+
gcc-aarch64-linux-gnu \
60+
g++-aarch64-linux-gnu \
61+
&& apt-get clean \
62+
&& rm -rf /var/lib/apt/lists/* \
63+
&& true
64+
4865
# zlib - http://zlib.net/
4966
ARG ZLIB_VERSION=1.3.1
5067

5168
WORKDIR /tmp
5269

5370
RUN set -eux \
5471
&& echo "Downloading zlib ${ZLIB_VERSION}..." \
55-
&& cd /tmp \
56-
&& curl -LO "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \
57-
&& tar xzf "zlib-${ZLIB_VERSION}.tar.gz" \
58-
&& rm -rf "zlib-${ZLIB_VERSION}.tar.gz" \
72+
&& curl -Lo zlib.tar.gz "https://www.zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" \
5973
&& true
6074

61-
WORKDIR /tmp/zlib-${ZLIB_VERSION}
62-
6375
# x86_64 glibc
6476
RUN set -eux \
77+
&& mkdir zlib \
78+
&& tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \
79+
&& cd zlib \
6580
&& make distclean \
6681
&& CC=gcc ./configure --prefix=/usr/local/x86_64-linux-gnu \
6782
&& make -j$(nproc) \
6883
&& make install \
84+
&& cd .. \
85+
&& rm -rf zlib \
6986
&& true
7087

7188
# arm64 glibc
7289
RUN set -eux \
90+
&& mkdir zlib \
91+
&& tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \
92+
&& cd zlib \
7393
&& make distclean \
7494
&& CC=aarch64-linux-gnu-gcc ./configure --prefix=/usr/local/aarch64-linux-gnu \
7595
&& make -j$(nproc) \
7696
&& make install \
97+
&& cd .. \
98+
&& rm -rf zlib \
7799
&& true
78100

79101
# x86_64 musl
80102
RUN set -eux \
103+
&& mkdir zlib \
104+
&& tar -xvf zlib.tar.gz --strip-components=1 -C ./zlib \
105+
&& cd zlib \
81106
&& make distclean \
82107
&& CC=musl-gcc ./configure --static --prefix=/usr/local/x86_64-linux-musl \
83108
&& make -j$(nproc) \
84109
&& make install \
110+
&& cd .. \
111+
&& rm -rf zlib zlib.tar.gz \
85112
&& true
86113

87114
WORKDIR /tmp
88115

89-
# OpenSSL 3.5.3 - https://github.com/openssl/openssl/releases
90-
ARG OPENSSL_VERSION=3.5.3
116+
# OpenSSL v3 - https://github.com/openssl/openssl/releases
117+
ARG OPENSSL_VERSION=3.5.4
91118

92119
RUN set -eux \
93120
&& curl -LO "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" \
@@ -189,6 +216,27 @@ RUN set -eux \
189216
&& rm -rf "openssl-${OPENSSL_VERSION}" \
190217
&& true
191218

219+
RUN set -eux \
220+
&& tar xvzf "openssl-${OPENSSL_VERSION}.tar.gz" \
221+
&& cd "openssl-${OPENSSL_VERSION}" \
222+
&& echo "Building OpenSSL ${OPENSSL_VERSION} for aarch64 musl..." \
223+
&& mkdir -p /usr/local/aarch64-linux-musl/include \
224+
&& env CC=aarch64-linux-musl-gcc \
225+
./Configure no-asm no-engine no-shared no-zlib no-tests no-fuzz-libfuzzer no-fuzz-afl \
226+
-fPIC --prefix=/usr/local/aarch64-linux-musl \
227+
-DOPENSSL_NO_SECURE_MEMORY -mno-outline-atomics "linux-aarch64" \
228+
&& env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make depend \
229+
&& env C_INCLUDE_PATH=/usr/local/aarch64-linux-musl/include/ make -j$(nproc) \
230+
&& make -j$(nproc) install_sw \
231+
&& make -j$(nproc) install_ssldirs \
232+
&& rm -rf \
233+
/usr/local/aarch64-linux-musl/include/asm \
234+
/usr/local/aarch64-linux-musl/include/asm-generic \
235+
&& ls -l /usr/local/aarch64-linux-musl \
236+
&& cd .. \
237+
&& rm -rf "openssl-${OPENSSL_VERSION}" \
238+
&& true
239+
192240
RUN set -eux \
193241
&& echo "Testing musl-gcc with OpenSSL..." \
194242
&& openssl version \
@@ -199,26 +247,24 @@ RUN set -eux \
199247
-lssl -lcrypto \
200248
&& true
201249

250+
RUN set -eux \
251+
&& echo "Removing temp files..." \
252+
&& rm -rf *~ taballs *.tar.xz \
253+
&& rm -rf /tmp/* \
254+
&& true
255+
202256
WORKDIR /root
203257

204258
# OpenSSL related environment variables
205259
ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1
206260
ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/x86_64-linux-musl
207261
ENV X86_64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/x86_64-apple-darwin
262+
208263
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_STATIC=1
209-
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-gnu
264+
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR=/usr/local/aarch64-linux-musl
265+
ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_DIR=/usr/local/aarch64-linux-gnu
210266
ENV AARCH64_APPLE_DARWIN_OPENSSL_DIR=/usr/local/aarch64-apple-darwin
211267

212-
# pkg-config related environment variables
213-
ENV PKG_CONFIG_ALLOW_CROSS=true \
214-
PKG_CONFIG_ALL_STATIC=true
215-
216-
RUN set -eux \
217-
&& echo "Removing temp files..." \
218-
&& rm -rf *~ taballs *.tar.xz \
219-
&& rm -rf /tmp/* \
220-
&& true
221-
222268
WORKDIR /root/src
223269

224270
CMD ["bash"]

0 commit comments

Comments
 (0)