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.3-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3a51dc8234b387281c96a9182efe6431f21d679b9826d936e0454a80be749a1 |
|
MD5 | 2b1baf6ea95f836874b49f0a89ba09eb |
|
BLAKE2b-256 | d3d956b25859547980b9b64d7ec1770aecd00b00f4d419fae2f582cfddc14583 |
Hashes for cargo_zigbuild-0.14.3-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 722c2e7315263f62de9e40dd322c19dcab5f80a178d4dd11aebd07fc50386549 |
|
MD5 | 99829ba3533128a2685b0c23dfb94e7e |
|
BLAKE2b-256 | fc7f14a3b7f44e8e1619c41605636c2106b5bfe65996e52fa2ff7bde5a8b6ab0 |
Hashes for cargo_zigbuild-0.14.3-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 501e9aa94b450391d2a556e3daffcd92d6f2ef7864b6b9baf48f4c0d37bfd29b |
|
MD5 | 34212c331bf7e42dfb39dac29f633b66 |
|
BLAKE2b-256 | 32136d674e0f3245cef1781498cfc4006d3e824a0af2ca765e919559af5cf3b8 |
Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85975cc7337e25daa7cea78cb641c731ca923fce5a77149ad79cf85435bbb84d |
|
MD5 | b6a6876d91d9098999bf7a2fd5c860f0 |
|
BLAKE2b-256 | 38fdac7ebf9707a93c3903edb42c80dff73efb98c9adebe0cda53e1527375821 |
Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd07c8ad1841ce3050874c690f38599ce1ecf1281ba2df00e7a97600a42e981d |
|
MD5 | 276db3a20274c85b270b3ca1a259cd9b |
|
BLAKE2b-256 | 90080f4ff02c90157dd6cf49966d81b58ce79666965db7a5fed82e0f7c733006 |
Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0ebd8e2a4c487ba5f924f6648145ed464f5d657308fca8bb8208b30d32c624a |
|
MD5 | 8b067ba757c05a712e1068e5dcfba086 |
|
BLAKE2b-256 | faaea14aa8d4db158b8d2458be5027247312960f4182aaba0e7131e514649dbb |
Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 357c264ea7e0d547dcd724b37268c24c5fc40898fecebb6148170c515a98ad11 |
|
MD5 | e322e823cbc608f2a954fa35b4137554 |
|
BLAKE2b-256 | 0605049711ace56c331bc3c4549de4d3fe9eee7c1f294c8e190372f7fbd8c668 |
Hashes for cargo_zigbuild-0.14.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55afeab9805e3bb586e8272b447d52fbc1a01bf38c7cca5384665eb9f98f05fc |
|
MD5 | 426333f141f4d7b8fcc92bc9ef24688b |
|
BLAKE2b-256 | 984386b4d9a04aa00df8eebf07fdaf4f3024e2ae3dd4667f991ccd37d5aa2b63 |