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.1-py3-none-win_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54504f2be6b6314f8342dfdbc7f8a4435e6325f95090fb02ba7f4e22c8a2b7a3 |
|
MD5 | 1522514975cead0303ffae162e0ff3ba |
|
BLAKE2b-256 | 74972d5ad50d0d5d9892bb5fe979e3e2f4c45004db2a2d484d1af35bf0ce4b1c |
Hashes for cargo_zigbuild-0.14.1-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f10137498edbcb2729b4a6d70b7e55b5adcaee7c4571692fa5175c795f32e793 |
|
MD5 | 6b8f24f85131159f8dae9a529e06e4a5 |
|
BLAKE2b-256 | bdffb8743c776eed3cdb892e24ea02a573b7d6bbc9e049864c64b8f86df3e78d |
Hashes for cargo_zigbuild-0.14.1-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa374e711a1afd7f54035dee44d0d0a3e9e6896b50ae023a35409b351e5e8ca6 |
|
MD5 | 3c4700f7895dd2048341dc703d7ba8d0 |
|
BLAKE2b-256 | edf404c39296dde4b5804f997c3b04e30268dc6ca8c99dc5749ca4b19216fe1d |
Hashes for cargo_zigbuild-0.14.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00376986108650ce7e05e1d46ee836d6e713c6d799753aee3b4d152f9867e67e |
|
MD5 | 2453640eabb8a0c091aefbdc281a6fc7 |
|
BLAKE2b-256 | 640b6421213f0e42ab7ee44e8966e7ed45fabff4685bd0fa736215d1f4d256f0 |
Hashes for cargo_zigbuild-0.14.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56db2a65ece4a0c733bdfd64b934e1159111e483d442a9983fa0783524be0899 |
|
MD5 | 4c4cad8f9bf02abd1b1f262435cf2150 |
|
BLAKE2b-256 | cab9108aebb5f3fb71dc1ffe5fac244e09415bedc606456175351c5c0f575468 |
Hashes for cargo_zigbuild-0.14.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4f7e1e0d980e369a4fad711ba4d1a3b8bca6d48f70b3d86975a034b77ab6fd7 |
|
MD5 | a99232412c280e22496aaa8ec9c63ed2 |
|
BLAKE2b-256 | 7fc7bfb14d143b5ed116caed063f32a00ee963825461c86d9f7ed4da398bf9d5 |
Hashes for cargo_zigbuild-0.14.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc736951ce0db8f34a21b6786fd76b4b897342d4038f5fe1c73feafa9198b4c5 |
|
MD5 | 86154873950d34714c380e4736d7696a |
|
BLAKE2b-256 | f467b9c4f81b2b4f83539b2c391c945f7e98e3cb14f89ba754e64f7b7d2b53f2 |
Hashes for cargo_zigbuild-0.14.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9af5ea4641acfdc0d3e880498fb0e9d88fe3ceab7d9f6f4b4349a380b57fa6ec |
|
MD5 | ec657d012df9f8077e24fb4486cac2f1 |
|
BLAKE2b-256 | d7f56b71d2a04514e49aeb1fee699270cf1db02ffe29e492292a7efd4af30016 |