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

This version

0.8.7

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.8.7-py3-none-win_arm64.whl (551.2 kB view details)

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.8.7-py3-none-win_amd64.whl (563.7 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.8.7-py3-none-win32.whl (536.5 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.8.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (609.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.8.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (615.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.8.7-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (666.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.8.7-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (704.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.8.7-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.2 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.8.7-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.7-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 30048158f8147a85fb08b7c4a6d251b16479654975ab365212e92e670506279b
MD5 c5f4a8bf46494389e7d1f6f7839cc407
BLAKE2b-256 a58f73408a0a42e6d7b6cb5919fe1840b59f6674223934a37d1b909494e62e29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6b79f59c60486a45e26c82d095da02006012b78513a27dcfa2ea1d6bf27163d6
MD5 e95ac83e8a32e1e584d31719075e4911
BLAKE2b-256 45b42f5023ef13bf4613d548502c6dc3346ccf4aff5e68e64247f75159b60375

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.7-py3-none-win32.whl
Algorithm Hash digest
SHA256 8a2b007e7bd72d62f4fa723a5205b70b59a752a6dd952c9b93ca898ce59da828
MD5 fc0eba49155e74131223370f4c317d24
BLAKE2b-256 ee116bdf2f267b18a8036391ec2aa63f8a737d2007b413a4037ee211335f7b92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8fdaf3cc9ed445b476b8e1983c95d2e18a7177b0edc040b05cc678d83812f31e
MD5 9b34e5acab1c8d405d9a0926eea5b121
BLAKE2b-256 c81137f8833b34133edbc769600623e2c5eca362202ac53300e244badebe4e2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 651efa5b3bebc24935932c103046ea5dbb5b86e9d01da16afdd88b5a032d97c0
MD5 036c60cfdb02509eae46b8a91c55e4da
BLAKE2b-256 3f11b6fb53a7e0eef342544f898c53a661a153fba733ebe84fe0961cbcf54202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.7-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b6e1e78b2bc8abdcaf53975b30db0c15415dbe66adc8cfde85051b81970d5fa6
MD5 ecef6d6e1ec0af18198d27c232afd8b0
BLAKE2b-256 9700ad50d76dee9be9428153131708cd6a4e82b40c58a5586d6ce45c745e9d79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.7-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 38bbfbfbf207b102433e03adba44799db84139314632cde7b7c96cde42486c8f
MD5 18bcce80b5ced13be3a7406f9da2cc9c
BLAKE2b-256 13c531fd10f3fabc50ccec730fdd9a7653ca35d487a2a1b745bcb1a1a12cd45d

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.8.7-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.8.7-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3205e2cdfeb6c7a6e025907a3bb148f89b95ddbff84ff154c94d8d949a670bf5
MD5 a8103cb43d0619b204db9b5e17edc627
BLAKE2b-256 4e11a554d228310feaf1f31605f7f8c6326cb66053b5503db9e2ac1ae68dfec7

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