Closed douglas-raillard-arm closed 8 months ago
Hi, and thanks for the report!
It seems maybe your cross-compiling C toolchain is not properly setup?
I'm testing on Archlinux, with aarch64-linux-musl-cross-bin
installed, after running rustup target add aarch64-unknown-linux-musl
, the command you wrote worked.
Here's a dockerfile that sets up a minimal environment and runs the desired command:
FROM archlinux
RUN pacman -Syu rustup base-devel git --noconfirm
RUN mkdir /pkg && chmod -R 777 /pkg
USER nobody
ENV RUSTUP_HOME=/pkg/rustup
ENV CARGO_HOME=/pkg/cargo
RUN rustup default stable
RUN cd /pkg && \
git clone https://aur.archlinux.org/aarch64-linux-musl-cross-bin && \
cd aarch64-linux-musl-cross-bin && \
makepkg
USER root
RUN pacman -U --noconfirm /pkg/aarch64-linux-musl-cross-bin/aarch64-linux-musl-cross-bin-*.pkg.tar.zst
USER nobody
ENV RUSTFLAGS='-C target-feature=+crt-static'
RUN rustup target add aarch64-unknown-linux-musl
RUN cd /pkg && \
git clone https://github.com/gyscos/zstd-rs --recursive && \
cd zstd-rs/zstd-safe/zstd-sys && \
cargo build --release --target=aarch64-unknown-linux-musl
I'll give another go to see if I can get more details. The environment is Alpine linux, and it does not distribute cross toolchains beyond clang and llvm tools. This is enough to cross compile everything else so far (at least everything that is in pure Rust, I'm not sure if I have any other C dependencies)
EDIT: the error I posted initially seems to have originated from my dev machine, not from my Alpine build env. It's using Ubuntu 20.04 with aarch64-linux-gnu-
toolchain installed from the official repos.
EDIT2: I actually used export CC=clang
with Ubuntu 20.04:
time CC=clang RUSTFLAGS='-Clinker=ld.lld -C target-feature=+crt-static' cargo build --release --target=aarch64-unknown-linux-musl
I suppose the issue here is that the CC is not targeting a musl build, whereas rustc is. In your setup, you properly install a musl C toolchain so the resulting object files can link cleanly against the ones produced by rustc when using a musl Rust target.
I can't reproduce the issue though so I think we can close it. If I manage to hit it again I can re-open a new one, thanks for looking into that.
Running on rust 1.75.0:
fails with: