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.0-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d75d31cdd3c362aa578b656af2f0b672b7a0aeefe9789578be01c59a2b10c1fa |
|
MD5 | 4694b1cce285b13b01ec3e72eaca355f |
|
BLAKE2b-256 | 286dcddf4008a1bd659c5cf1097c89906cff6b4fc90444b06e69b9e85623920e |
Hashes for cargo_zigbuild-0.14.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17a6aefa5be089a1a15b52e3ed9ba65daab01d3dd1147f6ffe225ae2f14dd93e |
|
MD5 | 31ebd80edac5f95d6bde50562c4fb501 |
|
BLAKE2b-256 | 00bda328c3b1463e3edfe3aa4c92f3264f406f28d7bfa2df3a797711a290be79 |
Hashes for cargo_zigbuild-0.14.0-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dfadb711c256a6ca5c127a05a573e6cba62dbba07afc755abf7f0c1ad49ae70 |
|
MD5 | a6fd9e3d432fe7f859bee73854bfcb77 |
|
BLAKE2b-256 | 97593793fb0a54a243f25588eb0e0faf18e60cbc56f75e3954e7264ae24e3dde |
Hashes for cargo_zigbuild-0.14.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 197874c78cd2c75cd856d773f81020296ecbcfe73341731044424c74fb7eb966 |
|
MD5 | 2d20943baea6beb36f009a445a89a6fa |
|
BLAKE2b-256 | ba63378abd090d97091880538c956f908192840a51a5096b1ee56a2abd917a7a |
Hashes for cargo_zigbuild-0.14.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3c602179c3f699c12d80e80a011f7492c52527dc6c304a9708a50cedb0cefd9 |
|
MD5 | 278571a9b0c688cc05411c2e35f44c83 |
|
BLAKE2b-256 | c948657e353e817267359fb37ae03a3f6cc728d7d050191aa8baf7b59f19e23b |
Hashes for cargo_zigbuild-0.14.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcfc69258790df3674444e8d177af48feba6b86c668c861f95cd09393913023e |
|
MD5 | 813ad0c637f97fc37af79ea49322278b |
|
BLAKE2b-256 | 979d547b4351e3f8005ad74f23a22d185583be2199ce3b368e5eaff87e600335 |
Hashes for cargo_zigbuild-0.14.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f05ccd57fb8d119038e41264392002da0f40ff2c17a0c400f7a996aec73db5a4 |
|
MD5 | 5148f377ca0757e5b28f2f3b49b76ce5 |
|
BLAKE2b-256 | 5558dcd3e7be5fde88db4a590d42be36120047c24db83e31bca98b2a418b1782 |
Hashes for cargo_zigbuild-0.14.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93de0d2f132dec9e5c9798867ec416a5574fbc1c19d55ee75677191c58087466 |
|
MD5 | 3f4454e6592a5d1b9496fde4650853e4 |
|
BLAKE2b-256 | eb9130d551fccf02c674185e966b6a58edeec54b3dfb8ba63e0d3fed9ff7fc09 |