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_beta.1-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53c8a9e692ae667d7fd023ee0178d952c95d0851ee65792fb3339fce5a5f6794 |
|
MD5 | 584ed01f1bffaf8916c0ad9757def793 |
|
BLAKE2b-256 | c66f5d9f72202271ae4d4bd27765678e6257c9eebeedd8d536194c3e00079c56 |
Hashes for cargo_zigbuild-0.12.0_beta.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a90f643051d00923474f41d3d9d58f853482d244b417e5322fbacadc12b48f5e |
|
MD5 | c5c67ac760c0d229f9391ec1b09a340f |
|
BLAKE2b-256 | 26c81f4f613642c75160d0e2c0c1c48f8fb528e598ce91e942484deb63238cff |
Hashes for cargo_zigbuild-0.12.0_beta.1-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d26a9aaa596229e574a9aac1c8836f9fa4e31a1449b7f5646b6bb0c3069d88a |
|
MD5 | 987ecf13581a4b139344517da99f8541 |
|
BLAKE2b-256 | 7d725a44af28574930371f857ba0328edff1ce49755ae52aa31b19b4adced69b |
Hashes for cargo_zigbuild-0.12.0_beta.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a22fbb9d87a16c4e9d017a3d997271c0d763906acba9c3b661f3361de1ce9ed1 |
|
MD5 | 96a0c7469552eaa6cff9626c42f7c9b0 |
|
BLAKE2b-256 | 98ae898d342ff0cb99f660de2924a61456e87b6cb512c129ff7a92c11701250f |
Hashes for cargo_zigbuild-0.12.0_beta.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8210ee07fe103dfba94223f9e326a115bbb98fc2e2ba0efb42761cb2365a4fcc |
|
MD5 | b098a46628c8a4866203d1d46d29e0b5 |
|
BLAKE2b-256 | c652000f3f495626490b7647a6e0b56044e297d5d5045e4efcf78c3cd05ed372 |
Hashes for cargo_zigbuild-0.12.0_beta.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f8a17cc35550b386252af2fd96fbe38f080e03ba331e970f9b0e95d113a27fb |
|
MD5 | 0b05f91678b8032da73b108b07d89ced |
|
BLAKE2b-256 | 8f608219f5ec553a9673ee98598fd3e2622d9c3e4a23bda8a5b7536d22d9b383 |
Hashes for cargo_zigbuild-0.12.0_beta.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e663917b2c5c90a57d7567e59302e5d3dbc51b0591cd37c097a66059aa674ca5 |
|
MD5 | a98a9dbbba593c6c47e28b75f25f4087 |
|
BLAKE2b-256 | 245462e5aa3325447f59dd1e06e52065d527645520db701d9e95584b38c82216 |
Hashes for cargo_zigbuild-0.12.0_beta.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36c82e2d3da1379d9c2a2b0ac25b09bf6ed9a11386d3eb4fc40999e31c9c8fc5 |
|
MD5 | 4943dc127ac4a26d40b7555d04370ce8 |
|
BLAKE2b-256 | 6573284b677e7e73c50da377a498de0f79c817852b3e61a00b2a9b8c2f82f271 |