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
zig cc
does not define aarch64 outline atomics
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.14.2-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ec6654bc9fd21fef4c34fc8073bcf504d2157e7fe8dba137c733c6ddfa6f329 |
|
MD5 | fc83e219b742eda95bea5a24bbb1acc7 |
|
BLAKE2b-256 | 416d155f4525a4314e37345524667e784a20975cdc52a17e8e9b9f68e680b837 |
Hashes for cargo_zigbuild-0.14.2-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4169df60fcb95114fed006cf432a5a88fb6a4039dd47865e0397b93284fe55b2 |
|
MD5 | 9bb3673345f63a211118a1ce1368f377 |
|
BLAKE2b-256 | 37d255b633cce65423632e6474e0f298db5ed960d666a25ab98735415fc18087 |
Hashes for cargo_zigbuild-0.14.2-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a9b25e414106963758f9cfc56253c05a562f7a214d5ff5a23a0115dd8f55c3b |
|
MD5 | a528527965ea559735e4ce7fc3ee4bc9 |
|
BLAKE2b-256 | 7319072efb3780b7cf3659ced7ba456bae219d4706de23a3e998ed6a6449e7c1 |
Hashes for cargo_zigbuild-0.14.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 502bee0d762097360bb445f5bd075259eeac7e02fe1f46fdeba3a1a259f19e20 |
|
MD5 | f8c6b8412058d8811feb62ecaf787860 |
|
BLAKE2b-256 | 3dd8441aa4d730993a5f0c6ff4166f2e830c5ec97962e21ab53f9134ee0aa6ee |
Hashes for cargo_zigbuild-0.14.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cff8cad47f642f4cec0ee4f51d5e008536ea0f9714d5e3a4d39936dfc064cb0 |
|
MD5 | 08d416df341d4a4418326685854d36f9 |
|
BLAKE2b-256 | 74c0568be97af1f015a27c2458b8bf004314110da838ef4af9448638c017a046 |
Hashes for cargo_zigbuild-0.14.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aacf3780e06445b3bbb87ff38bf488934893327f64405e9fdc7878880a0dba78 |
|
MD5 | 052f7f294300fe60e0124c6a6a126462 |
|
BLAKE2b-256 | d5938782332c22e234d4c89297b3f0a66313aaab5bae9faf93015a697b02190c |
Hashes for cargo_zigbuild-0.14.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f8c9b5375574cb82fa75f8454c898939d200f26d66d02dc59f79593b00e0b90 |
|
MD5 | 9f19d4cba5bf5ab51b12cae6e022e3e6 |
|
BLAKE2b-256 | 4f0496a6299f7ee7cda139784c061c8462c18568eee405fe31f82165fd582316 |
Hashes for cargo_zigbuild-0.14.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c98d0ab11a37c8ea52be35b888f86be46fbb9e2c30083561cfb962bc0227a1c |
|
MD5 | 10703ad23fad78375798fd6281407380 |
|
BLAKE2b-256 | 245a18812dd6e81064c5b78bb578a500fd9fe86db8a813199e31040dc08c16e1 |