Skip to content

Commit 74ae38b

Browse files
committed
Add arm rust build toolchain with cross-compilation
1 parent 6fada9d commit 74ae38b

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

‎recipes/arm64-musl/Dockerfile‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ RUN apk add --no-cache \
2222
ccache \
2323
xz \
2424
patch \
25-
# extra packages required for creating the musl based cross-compiler
25+
rust=1.87.0-r1 \
26+
cargo=1.87.0-r1 \
27+
# extra packages required for creating the musl based cross-compiler
2628
rsync make gcc g++ bzip2 git
2729

2830
COPY <<-EOF /config/config.mak
@@ -46,6 +48,25 @@ RUN RELEASE="3635262e4524c991552789af6f36211a335a77b3" && \
4648
cd / && \
4749
rm -rf /musl-cross-make-${RELEASE}/ ${RELEASE}.tar.gz
4850

51+
# Install the aarch64-unknown-linux-musl cross-compilation target stdlib.
52+
# The version must match Alpine's rust package (see pinned version above)
53+
RUN RUST_STD_VERSION="1.87.0" && \
54+
RUST_STD_SHA256="15fd0652e2f3a8b678be8a83e396a1103fb1bb941afabe3fdaec706f3bdc85d0" && \
55+
wget -O /tmp/rust-std.tar.xz \
56+
"https://static.rust-lang.org/dist/rust-std-${RUST_STD_VERSION}-aarch64-unknown-linux-musl.tar.xz" && \
57+
echo "${RUST_STD_SHA256} /tmp/rust-std.tar.xz" | sha256sum -c - && \
58+
tar -xJf /tmp/rust-std.tar.xz -C /tmp && \
59+
cp -r /tmp/rust-std-${RUST_STD_VERSION}-aarch64-unknown-linux-musl/rust-std-aarch64-unknown-linux-musl/lib/rustlib/aarch64-unknown-linux-musl \
60+
/usr/lib/rustlib/ && \
61+
rm -rf /tmp/rust-std*
62+
63+
# Configure Cargo to use the musl cross-compiler as linker for aarch64
64+
COPY <<-EOF /usr/local/cargo/config.toml
65+
[target.aarch64-unknown-linux-musl]
66+
linker = "/opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc"
67+
EOF
68+
ENV CARGO_HOME=/usr/local/cargo
69+
4970
COPY --chown=node:node run.sh /home/node/run.sh
5071

5172
VOLUME /home/node/.ccache

0 commit comments

Comments
 (0)