Compile Cargo project with zig as linker for easier cross compiling.
bash
cargo install cargo-zigbuild
pip3 install ziglang
rustup target add aarch64-unknown-linux-gnu
cargo zigbuild
, for example, cargo zigbuild --target aarch64-unknown-linux-gnu
cargo zigbuild
supports passing libc version in --target
option, for example,
to compile for glibc 2.17 with the aarch64-unknown-linux-gnu
target:
bash
cargo zigbuild --target aarch64-unknown-linux-gnu.2.17
Currently only Linux, macOS and Windows gnu targets are supported, other target platforms can be added if you can make it work, pull requests are welcome.
Known upstream zig issues:
libiconv.tbd
to zig for linking to make it work.This work is released under the MIT license. A copy of the license is provided in the LICENSE file.