Skip to main content

Compile Cargo project with zig as linker

Project description

cargo-zigbuild

CI Crates.io docs.rs PyPI

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

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. If the --target argument is the same as the host target, for example when compiling from Linux x86_64 to Linux x86_64, Cargo by default also uses zig as linker for build dependencies like build scripts and proc-macros which might not work (See #4). You need to use the nightly Rust compiler then cargo-zigbuild will enable the unstable target-applies-to-host option automatically to make it work out of the box.
  3. 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.6.6-py3-none-win_arm64.whl (537.9 kB view details)

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.6.6-py3-none-win_amd64.whl (558.6 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.6.6-py3-none-win32.whl (530.5 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.6.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (596.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.6.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (597.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.6.6-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (656.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.6.6-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (684.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.6.6-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.6.6-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.6-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 db0f4bb5bd4d9f35d5b0072e972701024a9a0f65fb9fbd51e948d450887c0ab0
MD5 9f9fda2407d419f6fbabc92da3786d04
BLAKE2b-256 a58a3706370f5b6e0078b1d7248439ba524ae7203a85031d9595a4d261910871

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 75dbca84d28d4b09ea2026df4747e6caefba362d0efbd53b975b98f74ea31864
MD5 1131f574ee54d5849dc7b8ac7301552f
BLAKE2b-256 5a796bbdb0e4ba6ea7e618322df6d654ee21f8603248029ebecc5cc9427ec6e9

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.6-py3-none-win32.whl
Algorithm Hash digest
SHA256 a542b9094a07c7561db22402d57cd8d3fb2e5d183db14f3b21c260c367329350
MD5 33c03db1e0bd8717760c4594018ab016
BLAKE2b-256 b96733a37e9fabaf33396121e61a17de12f47c1e54a165e4ef93c1b230c9f32c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 534934175ee0ee8dc1742fb3bea91eaea29c111eb375f89a10fcb2766995d992
MD5 52b7abcccd297567f281b808ec5ffa6c
BLAKE2b-256 95a529b079e44f2456cc96581680a6fe9b20f608948ffa8bdcc4bbecb39d3aa7

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0655d2180d74ac51b7008c1174e806c03db759b2eaf18b12a51ea3e84f4e0664
MD5 103dd8b01661f8120b4265ecaf7f203a
BLAKE2b-256 fad273dca76a748cbd54e49fcc8965b6ca7ef7bc92db5afb8b8f0b2c167936a0

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.6-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d6d82cc217b59e4328b0d0de5c0568c3859ae9bdf7c5dc6f429b22a7ea81483c
MD5 a0c805eb26d679b04e845e04f7da30f2
BLAKE2b-256 f69d023235124750d1857c88a71d226b26f9c5e922ed5f91e6c33aea633ff0c7

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.6-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4241fcebca67ec3479d8abf0f61fd427cabd7d8d8bdf830c2f506f5a890c703e
MD5 5e69a561e978b500e6258fcee5bd1613
BLAKE2b-256 715590990a4583cd1ac2b9ff7d44be7c4e7a87946fbfdbcfa1dcca4bbfb823c9

See more details on using hashes here.

Provenance

File details

Details for the file cargo_zigbuild-0.6.6-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.6.6-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 211d6aeebffd93d0589ef99df542fb7343934942d54f83adbef7c5abb59a0b1d
MD5 19c7c51e499e1c76a77c94e37b724536
BLAKE2b-256 392e3fe0a266432e2d5e4642304240a5a90cb1e73f9e34b09c3cc120f2a13823

See more details on using hashes here.

Provenance

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