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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.9.0-py3-none-win_amd64.whl (571.3 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.9.0-py3-none-win32.whl (544.1 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.9.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (627.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.9.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (649.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.9.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (701.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.9.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (736.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.9.0-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.9.0-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.9.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 349d3dac758bfde3b7d6325a332b46eb786f8b5dabb7875140e596d1c4770a27
MD5 01770ad3c142dad2a6af22fd8921a634
BLAKE2b-256 e0c4785516a9ca5e58d15cb5c210a2aaaf1aa39d58ae869c0a6b3181b4e57115

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.9.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 071a94d48e6258e48bd2fc6f6a19b535c252e1452518f34131f49cf929146d12
MD5 0499218556aa74116802adf82ff0b53c
BLAKE2b-256 342fe80198514c5a7dfdd7f871f002151383268f99e9cc04785553ff55744ec3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.9.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 4da8a2fa97fd09f970d205891460bd68bb3ea10a336bcc3d3a45f58816b9d81c
MD5 27362dadd55a0535dad16988d68757cb
BLAKE2b-256 07934fb19bbc0ab64915134803163faa7165e1272b0541de09e760de26636a6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.9.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 60af320b31436d8de479a1a00bcbb3649645b21c3d11b1e37bb1dcd849d14b4f
MD5 c4f8f9e4044f1b13ff074898dde42534
BLAKE2b-256 078903746b1a92052ef6a723bc71896bf53fcc87af1aa21890f68701611e0110

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.9.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f9060599193885bf5b3c0a37405d7b30f53ab4f283fd1380d15d2adc69cd2e7f
MD5 62b60ac55f76c6b0939dc4acea1b9e09
BLAKE2b-256 add8d72674c64b5765c1dc4f3966c6b53f430fda403323a3f20c40d43519c5ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.9.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 03986155318b0bc8151cfcf0d4c6b260e67c89c2b2a456a0c2e7b25ea70d7e2c
MD5 71d4f03926d5330795417dd115b70bec
BLAKE2b-256 9c90dcb45fca78ad0d5970157f46c29f30f8061fcb68e81f197210132522cd72

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.9.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 6f55d2f6e2fd426967389e6cb27ce4e04a60e20c7f0f4ba69370b0c4c159ee1b
MD5 13e2a30f89f6b6ebae4853d671f99a3f
BLAKE2b-256 93994a0800027561670d7c4ab745a01dc3be08ed41c4c4d2f9e75b2e423067f7

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.9.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.9.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 ec8b5cd283caab3c4acc116104c58fac605a9c8824a0be2a4a867986e7c8064d
MD5 62d42f2c1ee3e663cd64dea14ab8640e
BLAKE2b-256 f250d4b2a465aa838255d1e4ccf82fb73815ed7d62f36d672c931dbc475cb081

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