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

This version

0.8.1

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

Uploaded Python 3 Windows ARM64

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

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.8.1-py3-none-win32.whl (531.3 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.8.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (600.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (599.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.8.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (658.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.8.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (688.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.8.1-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.1-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 08c2ae9bac8a67ef9a41a6a6487abef79054b0e6659ffbf8b98d3f6b75e6d074
MD5 6b106d044ab67b2918ddf93c6e751e4b
BLAKE2b-256 78dceaf00aeb32655ef9a63c095ba8e67ecfbaf7a147d08377a52023fe3f119a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9b2ebd9009372c8764bc0ca23f23a4ffbde5c5195a32f933e0b6cebf26f2012d
MD5 501bf8952992980683dc2a82971d31ab
BLAKE2b-256 f783a7321722d39cb002de846ce9dd41ed5f22b87e9e9c367ca0781d2369d346

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 5e22454afe7c9b476d059487efa4b19e87814d014558370f6e24257d5fe33e2e
MD5 e53767b6c391b204549758efe05a049f
BLAKE2b-256 ba3e2832f66e46d9a4c0a02eaf6dccb10723c7dce56ba6e1dfee968d7c526246

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 bbd37a9ae870c7ab3c8220a3557297cb14afa2816e73c688461cac01abc03e90
MD5 e5a3b9f185b8234e7f8681b12e527560
BLAKE2b-256 9ad7872359ed24ef7c0967025456b01622281ff49c7473021771d2817a8b3b7e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5aa5a66a7642d667ae31479d0c28087f20fcca5bcd428eb1d3baff19363acc7b
MD5 7fcd9fa61709870ee7f985dc5100c404
BLAKE2b-256 896e5d518e1944d1273da7d51ed62f41190b57b212eb11cf184354ebb97bc84e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 965194c207cf45dc282cd1e9bb9129bfef2be55941894e74f821b272b4eea6e0
MD5 70e665db6bf592d74d3c5ec7706b0c18
BLAKE2b-256 bec15b0cbf30220f83ba7fe225803694f2197c2e6f841e4be6fab43bc4e0d101

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ad7112bbafbdf18275a481a061ef9f3d013a391c5947762ebe5639b44f0825fe
MD5 f31612ca71d4d11a99429e78795f4508
BLAKE2b-256 51a184a101fc25bda2ffeb2d0a92da37cc9b726c43a59b773ce44e864dce55ef

See more details on using hashes here.

Provenance

File details

Details for the file cargo_zigbuild-0.8.1-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.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 98a30c2505d034741de514de7945caafd499e4ec6a9da59bbb75d0ad7c58d2ef
MD5 79b248a0e935e306df9d94051eae72cf
BLAKE2b-256 f9bec207802cbd9b4687a42fd129f3537f35f868b84a4248021acb11fa6db392

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