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.15.0-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 235103b7b6ec1a9bbb2c1a12614337a6205fc6cb11707d3c38fb30c965bce2b0 |
|
MD5 | 7526d1478aec40368faa4601a23aee65 |
|
BLAKE2b-256 | 49f84d0bc677b7306033c09a9e7073e7f0a00c98c6cd5f1aed4c1a4ee7a907b7 |
Hashes for cargo_zigbuild-0.15.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 309820b548373ef63742c11c8b0a289d584201d80d82b6722656ee3c5a0b6f2f |
|
MD5 | c6734f78c7ed9f1c4acec4d9df0355fe |
|
BLAKE2b-256 | 0a29481d1d3b6a6e5d0b230a4998c78b36ebfc28a5ea11a014f79fca4e4110ee |
Hashes for cargo_zigbuild-0.15.0-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6fbbcf340942803d6276d66cf494befd4ab81541562ad2335ec3147b61ef5de |
|
MD5 | 38751fc6758e30cb0334aa34d7a43d77 |
|
BLAKE2b-256 | 8c2cf37a464c256cea4984292f8a7a1c81f6a6111d1e62876b62cdde9ef14531 |
Hashes for cargo_zigbuild-0.15.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01c95f0bda965e000f68e5273746299846790d1a7879eafa21f9efec6ffb920c |
|
MD5 | 0e16f6e4e764728b3884f7c245941e22 |
|
BLAKE2b-256 | 69355c7ddcbbeb7f5f6fbc8a710c1f2676b3b943432a2daed0adc6954c53c99e |
Hashes for cargo_zigbuild-0.15.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2181d83a9e8adccb89d0408278f3dad6e18af93daf0a80171d318aff44b7951f |
|
MD5 | 28aeda48d74bb1bddedb0aafab4c11a3 |
|
BLAKE2b-256 | c308c70231b3d76c701ce9a086a8fb9899169f530edc1087d7f76ca13fbbf59c |
Hashes for cargo_zigbuild-0.15.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7921af5f2089656d9dba031174e951b7dc6c68acea281e537848da8d81ead68a |
|
MD5 | 74d69b0bd4324206ee5aea9d2cc45984 |
|
BLAKE2b-256 | e803800d26be4fbf6d97dcf42781cbbdffd6fe05989145cf218dcf8255f1d3f3 |
Hashes for cargo_zigbuild-0.15.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 561147883514bedead1a8bc87ed10210cee830e67cdcc2d29b3e591e483eb97c |
|
MD5 | 070407a3565fc5f75eee0b9a0d124403 |
|
BLAKE2b-256 | 52381b27b8021287b5eff3bfa0cfdccee7f7b3e97d2c6838a8c671d3d1a08a32 |
Hashes for cargo_zigbuild-0.15.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c04b181dcf8ace0bb12c5733835a19c2c5ffb980fe5acf9dcdd9b0cba35024c |
|
MD5 | 8a53bab9aa30b59a746b32106cb6ec0a |
|
BLAKE2b-256 | 50fd6ca4b992d11159d9e4604db8e15b329e772a8e277264f4caa611c42193a3 |