Skip to main content

Compile Cargo project with zig as linker

Project description

cargo-zigbuild

CI Crates.io docs.rs PyPI Docker Image

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

  1. Install zig following the official documentation, on macOS, Windows and Linux you can also install zig from PyPI via pip3 install ziglang
  2. Install Rust target via rustup, for example, rustup target add aarch64-unknown-linux-gnu
  3. 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

  1. 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.
  2. Only current Rust stable and nightly versions are regularly tested on CI, other versions may not work.

Known upstream zig issues:

  1. zig cc: parse -target and -mcpu/-march/-mtune flags according to clang: Some Rust targets aren't recognized by zig cc, for example armv7-unknown-linux-gnueabihf
  2. 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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

cargo_zigbuild-0.11.0-py3-none-win_arm64.whl (574.4 kB view details)

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.11.0-py3-none-win_amd64.whl (598.7 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.11.0-py3-none-win32.whl (570.9 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.11.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (655.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.11.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (677.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.11.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (730.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.11.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (768.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.11.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.3 MB view details)

Uploaded Python 3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 6c62947ba11ac770f91ae2b295db5624a829e62f70c9b7c47c21e4755704ed28
MD5 5b77f0d8be5f968a986d1c4c56fc9bc7
BLAKE2b-256 43433c27bc14144bdd7ba8069a2a439617cb46b2d7eaa47f8e25544b15deaa8e

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a88041cd86bc8a32e0ba834a16738148dcff4e811a1fcae4c9ec5a08241f9e4b
MD5 dfa452e56fd3e88ed80b941b594b6b19
BLAKE2b-256 a886b7f7cbe6d7f9126a9008a5bc0a13c5164ee98492dc8a4626c60852dac2c5

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-win32.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 a755ec6a44b727e32a708c690d4b1cbbf03564c4bff3c8f949d4e7afa7a3fb30
MD5 db7b5964a3e69947db7381161859a669
BLAKE2b-256 d4e9c7f93da5fc25a5b8d34bdc0eb98d892e233ede3f6e9ea1a362fd18041ec5

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 31c61c88f2b0f937e9be3ae296618f526ddd86ee027d10bae32d44fd6a3b5ae5
MD5 93590cbcfdacf01121b7cbfc2d7263ca
BLAKE2b-256 6f076b7b0c770703d1b0f3a8b31ea1811ba9c370dcd7252d7e1f7ccdaa93263a

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 705c98d462ee2046082f4e5dfad5e5c8216d8c8ab80f80bab73c041498eca2b7
MD5 dc6120fa678734511313854e2be4574c
BLAKE2b-256 063f2464adf817c5afe202feb8af757794c743c1ba941b7872bdad8081298d0d

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 19a8e3896a371778cd5edefeb159755eb7e274bebc715ebd1679da8c5711b86c
MD5 543cfefc2fb281d1d603a33210885eb4
BLAKE2b-256 9bca3e3eb13c399427010966e528b57e417a5044f02394a09e8a62af939386fa

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 bbf778906ad721ebc955f8d9df6f4a7849d207eb0dafc2587dff306913918c64
MD5 b53003181b845377e695d81b87df76fe
BLAKE2b-256 e2920b6738f12b2bb75ad9c44604c5572647cd736a178e3f554cb31c04d4380b

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 e66e49d150c8e5c63b73de3e71b60a1c51b3e4f296570ecc2cc8c5c5470df5d0
MD5 0043f4d34fcb758051efbdb45008814d
BLAKE2b-256 be6ed52d5b253e8c3c06ff541ac87536764abdf0fc627cac3ca08e4886f017ea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page