Compile Cargo project with zig as linker
Project description
cargo-zigbuild
🚀 Help me to become a full-time open-source developer by sponsoring me on GitHub
Compile Cargo project with zig as linker for easier cross compiling.
Installation
cargo install cargo-zigbuild
You can also install it using pip which will also install ziglang
automatically:
pip install cargo-zigbuild
We also provide a Docker image which has macOS SDK pre-installed in addition to cargo-zigbuild and Rust, for example to build for x86_64 macOS:
docker run --rm -it -v $(pwd):/io -w /io messense/cargo-zigbuild \
cargo zigbuild --release --target x86_64-apple-darwin
Usage
- Install zig following the official documentation,
on macOS, Windows and Linux you can also install zig from PyPI via
pip3 install ziglang
- Install Rust target via rustup, for example,
rustup target add aarch64-unknown-linux-gnu
- Run
cargo zigbuild
, for example,cargo zigbuild --target aarch64-unknown-linux-gnu
Specify glibc version
cargo zigbuild
supports passing glibc version in --target
option, for example,
to compile for glibc 2.17 with the aarch64-unknown-linux-gnu
target:
cargo zigbuild --target aarch64-unknown-linux-gnu.2.17
Caveats
- 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.
- Only current Rust stable and nightly versions are regularly tested on CI, other versions may not work.
Known upstream zig issues:
- zig cc: parse
-target
and-mcpu
/-march
/-mtune
flags according to clang: Some Rust targets aren't recognized byzig cc
, for examplearmv7-unknown-linux-gnueabihf
- glibc 2.27 or older: fcntl64 not found, but zig's glibc headers refer it
License
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for cargo_zigbuild-0.12.0-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 059755e78d9a8449bd60ec2e7b08638f432cdefb29029f3ac160716c5be679e2 |
|
MD5 | 6e878aaaecacc1ab5d49e850af4825e0 |
|
BLAKE2b-256 | a9ab37e3194f6a2973ac766082251a548c3d40bbbfb3517399d1b5c739c23b8c |
Hashes for cargo_zigbuild-0.12.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82d381d69ea135273da91311f76e1c0fafde9073258688693ce32731492afeed |
|
MD5 | bd09188a3caeed5346802deb283d7ddb |
|
BLAKE2b-256 | c7ecf7cd569c52612a130f6553088b5d665c0c60650246b3a979c5fdafd2e4fa |
Hashes for cargo_zigbuild-0.12.0-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb6f0ee4da90cf56fd7e8c024b3617df79d14d20bcc7f956bdbd579d5c540de7 |
|
MD5 | 47f1ec80bbb8a7cd4ea97a98bb1099a8 |
|
BLAKE2b-256 | a21fd458eb091d417f331c537b007167db2f607e44a0e368443d898b9d1d3d51 |
Hashes for cargo_zigbuild-0.12.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63cf99783fd2e37e2f64e9c3bf452cc270fa99f22dc7bcc697e29a72e8d839b1 |
|
MD5 | 8a7843b91eb8120d7c888f9dad0e6c56 |
|
BLAKE2b-256 | 991765cbcbff28be318043361f266f1c664a86217ecd7de69d22e6686ca42a77 |
Hashes for cargo_zigbuild-0.12.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd8e90a748c1fd5a890ee69af816273866cdd051136c8f01dc188a7f02f04994 |
|
MD5 | 38a8bee42ff3421c86d2304a00a26d8a |
|
BLAKE2b-256 | ecd8a86040b850745825d8627319a409bcc228bafd04a7bd5bec09f62a4372b2 |
Hashes for cargo_zigbuild-0.12.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a23029a50bb68e4dfd77e71acabbbede877fdf48966516da71ca0b6b0a9f453 |
|
MD5 | d64dfdd3d992356856015515f9047ff3 |
|
BLAKE2b-256 | 0f32f03645f4cb7327122f74d1e0eff7a1e7f7c93fd6ff3ea5ae6caac8aeb606 |
Hashes for cargo_zigbuild-0.12.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90061214cc1dbecccae15700ae6b4223bb3bbea717f03d9e30e535a678ec0e26 |
|
MD5 | 6d6c89d617b6b1dffbbcf8b6283e8d50 |
|
BLAKE2b-256 | 66eb1361275cf87ccbf37f6d26aff265171756bda32e17d03b8eced666d0e578 |
Hashes for cargo_zigbuild-0.12.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e5f77304641a55ebebe38a2b941ee8f1b3cd5388ee2b58f2e980fcb42d8d290 |
|
MD5 | 954533b707b3b21776ac602cbacb3e5b |
|
BLAKE2b-256 | d8471e4c40fe6143e6c34403333f9817d844a918a482dd1d52491c5d8e676d3a |