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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.6.7-py3-none-win_amd64.whl (559.3 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.6.7-py3-none-win32.whl (530.7 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.6.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (597.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.6.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (596.8 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.6.7-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.7-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (683.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.6.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.6.7-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.7-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 383eaf7779222bf9e3562de8c6eefec081c04ff2ccfaad37f0d2fe67983f195e
MD5 5d9fe4aee9dcd4c129cfb8cee41b5dc4
BLAKE2b-256 5c028941cb78cfa6b36b74a7f377234fa7e639450d6155cdd365713870bf5cd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c7b743dd3bfd35fd0c73953afcb1c17c8193480daa0546f174464e5adf83adf0
MD5 d1354051bd5ab93a630a5dbee379730d
BLAKE2b-256 159d211f53201841ba59e748f17bb9485663141c90b758a11f47efad1bd1a313

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.7-py3-none-win32.whl
Algorithm Hash digest
SHA256 c087c7f313481b084b4416e67e8aa1078e1cd70cd902176fef73afb6da3e4894
MD5 7af45beb71bd1a3bfc3a7a396aff9fb6
BLAKE2b-256 0f13d32ab2a307400e20804096e985fa0df6716ec245984d6e8a6583c256b03e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 b68e65e3d7b3b01d07a4a020b18388f20413f86bf4a46a7af2ac5fd7c1e13aa0
MD5 79a81868b07cbc15158c4a607cf80c7f
BLAKE2b-256 1e6df1c04f1ebc6fc90bbe77d1d477ebb0f25f76a659913cd424a8179cf14539

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b21c832e47304ad43c0842f1536b972836819a58e8391b12d3bcdaf9b446d2e8
MD5 99d78ef5397dbb31b57e295f4dce1705
BLAKE2b-256 077367649a82a062b446aad7811a4ae906ca139b73a3a40f5a8b2b88e4d5029d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.7-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bac7369dcd6a40a47919092a333b575a3eec3300eeb03e8d41dd329f9f3976cb
MD5 554f5d95266f4b0ad2e06606547862d1
BLAKE2b-256 4232f54c5267dddbe3ce94ad769765276587ed36d73c556ebbdcf3c6f23cebfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.7-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 20e2a3c81996afbddc68dde19c25692568cf8842d0e94d90f882d3074eeea740
MD5 215262538b78618f7c6cc68975f2d8a6
BLAKE2b-256 476f3a4cd4541e370814324306858da848792707147146e2f228750a5453735c

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.6.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.6.7-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3723bef82f7aec811b9791757293b9805d8459d462390a73155261429d41fed0
MD5 aec2475d368f24eb7c70aaf9ffd08230
BLAKE2b-256 7f190ed85aa4903f4db77015acff2143703ec9f2f92bf41dc7053c64a1c25e6e

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