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

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.6.0-py3-none-win_amd64.whl (449.3 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.6.0-py3-none-win32.whl (427.7 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.6.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (500.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.6.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (501.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.6.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (552.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.6.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (573.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.6.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (963.6 kB 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.0-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 9175a59e4965987ac878bbc51b1390a9ba74763472411cc39d68ad5ba75e4b00
MD5 ec969bda93f80f2874be2170ec6ecce0
BLAKE2b-256 bef8bd0fc82f282451342d7e923d75a793d2d266d05ee2314ad12907bdab79ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c9004c6c5f663331238022d0a5496c55bb502fc1a33e846ceb847c2456496187
MD5 1b7039c800566f633d02d43771c0b716
BLAKE2b-256 e99dccff593482630d1ce5145799cfec8c5ebc7b1355b36252fc4c435fe186b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 178ea74773996d2f49cb0d3b7b7e2f0304433854944fcc2dfea56857328a3971
MD5 4eb77644ad232b934b274b6d1bd5d449
BLAKE2b-256 5bedb39af75cd57bf389299d4447b03b20e81a23b3e753232b3c74051fada3ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 0ab75a8e7a7ce8a298bbab342ae70823a5f680d056207b6636f8efc167f7df03
MD5 624953da48e16b80dbd1ce1bf76c50be
BLAKE2b-256 e5504eda48a182bbab38598022ae90c2bbcbf9f88f6cbd47143831937f0ba14b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f1e2ff5ca0ad90657e6d54df21505167fc69af182a99ac60afa88741db910874
MD5 881c5be9ac7014ce0515b6e9b460ac6a
BLAKE2b-256 677617f80773de520d47bec6e5720b94a9f5e8848c095c29e9e46084ede42d34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2f43a818ceceee700d38c813ca79a9a31038f1166140ff996e68adc74d0d603b
MD5 60af4dd10f5e1843472c4bff8d5612e2
BLAKE2b-256 096760d72d233a4a191aeffab93d0f82785c1213ee80512669ce0d3d3b073ab0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 e7c14550569a38d2303adfde1d27ffaec4b2b751acb96f0f976f69747c17adb2
MD5 c8477d5c2607304ed2a46c2e4e5745ba
BLAKE2b-256 2d019cc5e94e51ea09288004749011cf45307a4986b6cb85354176c70d2d267b

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.6.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.6.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 306e6e1ed88ae22d5c75e2e76727884fe4c714cb06a1244630db3b307b7c8671
MD5 fc487e6d52200dc28439a6f88e64dbec
BLAKE2b-256 52ef843d6ed4c489e8b51dda041b49161d3f899068a9cb919fc7c7d706e9c4b4

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