I was able to compile and cross compile the gnu and musl variants to all of our target triples :)
-
Install the cargo-zigbuild and dependencies (requires python3)
pip3 install ziglang cargo install cargo-zigbuild
-
Cross compiling for all musl variants
musl
rustup target add x86_64-unknown-linux-musl cargo zigbuild --target x86_64-unknown-linux-musl rustup target add aarch64-unknown-linux-musl cargo zigbuild --target aarch64-unknown-linux-musl rustup target add armv7-unknown-linux-musleabihf cargo zigbuild --target armv7-unknown-linux-musleabihf rustup target add arm-unknown-linux-musleabihf cargo zigbuild --target arm-unknown-linux-musleabihf
gnu
rustup target add x86_64-unknown-linux-gnu cargo zigbuild --target x86_64-unknown-linux-gnu rustup target add aarch64-unknown-linux-gnu cargo zigbuild --target aarch64-unknown-linux-gnu rustup target add armv7-unknown-linux-gnueabihf cargo zigbuild --target armv7-unknown-linux-gnueabihf rustup target add arm-unknown-linux-gnueabihf cargo zigbuild --target arm-unknown-linux-gnueabihf
The following hosts were able to succesfully build/compile the above targets.
- MacOS M1 (aarch64) natively
- MacOS M1 (aarch64) in arm64 debian container
- Linux (x86_64) GitHub Runner (ubuntu-20.04)
It seems that arm 32 bit targets don't work so well due to some compile issues with the ring dependency. The following targets failed to compile:
- armv5te-unknown-linux-musleabi
- armv5te-unknown-linux-gnueabi
- arm-unknown-linux-musleabi
- arm-unknown-linux-gnueabi
I ran into an initial problem building natively on MacOS M1. It turned out that there was a conflict between homebrew installed rust
package and the rust version installed via rustup
. Solution was to uninstall the homebrew rust
package.
Fix was provided by this post.
Thanks for this! It works like a charm!