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.1-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58beff7c0cbef149cdafa1f561f5ae6840cb276036d66c93388bf23ecc13ca48 |
|
MD5 | ce9a35df79c892f1dfbd68cc4c93168c |
|
BLAKE2b-256 | fc3622798c433f7a008a75c074ed949c7f80ed9cf15375169062fde7d193ed22 |
Hashes for cargo_zigbuild-0.12.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0563ada5fd9e097e0e52620a7f3a8e6ba1ec465d23fbf38a2374da71d39f102 |
|
MD5 | 4261eec52cf1db86cda6a6a79e0643ff |
|
BLAKE2b-256 | 5a07ea89a46bbc10ed8c064031eb428b37998c7ff6049eebf20a221cfe84923c |
Hashes for cargo_zigbuild-0.12.1-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8f2b20624a7d56f0947548de71af83341210aa57b552f0a9098ce13f4166d9a |
|
MD5 | 70477444f0237198087050dd070cc3b1 |
|
BLAKE2b-256 | 35c12936cd059dbd3c1010ab3ef0c501e8044a3f87c9ce5cbf18319c67db1b38 |
Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0a7fcc14f41d89bec01763dc11f666b82a96d215808d37ea9cf3f7d36c05d4d |
|
MD5 | 7e35ab44061d7f29d5e7b9a7e6c5d574 |
|
BLAKE2b-256 | 004334a1d055fe6e1f660ef9a7178d307f63356dc935df86cf497b73e468f0c5 |
Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebfd134a7baefed476b5f99ca4eec41e0380a991ad5d98be8aa2edcdf9da7604 |
|
MD5 | 557a85b5d38930f76209335d1bbbd459 |
|
BLAKE2b-256 | e15adeb5f5e7b55d60e22b513c064c9d812a7abb134a0603ad08ce09c9dde23e |
Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7850981bc982f78aa8857bf6dd515743d136615ff07f35c006e92d1c8484878f |
|
MD5 | 324e7fe08ac83a724df0ff04fdf129c3 |
|
BLAKE2b-256 | 8218a5c0bb0fb6ed360255fd5c166e876450a69a50effae8960c9e252c781909 |
Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f1bc8cd9f2df712d2536ded7d2721afc2a493fd83c1a545859c12979fe790f8 |
|
MD5 | 27a8b5162044f93c73fb0527f9e9ea3f |
|
BLAKE2b-256 | c9bbf678602b60d75245a20d69b06da2c711b40f72fdedd2c1ba262d79dcb9e3 |
Hashes for cargo_zigbuild-0.12.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc8a376f410e1b1b7d5281cb4bf636da918436fc42ffff0968a3899ddc6c15ce |
|
MD5 | 42bf8e036f9133ee5869db3e8f8a00f6 |
|
BLAKE2b-256 | fa0754c538829aa746d0f776241502632c60fa9455eb924e872c67838a4c5901 |