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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.6.8-py3-none-win_amd64.whl (560.2 kB view details)

Uploaded Python 3 Windows x86-64

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

Uploaded Python 3 Windows x86

cargo_zigbuild-0.6.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (598.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.6.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (597.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.6.8-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (657.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.6.8-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (685.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.6.8-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.8-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.8-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 c2c0b3a0850955737608a2a2bb173d120499ebc01f7ca727cafc33b621e48d16
MD5 4af6baaada25ceac0bb6a453303d4e55
BLAKE2b-256 b9abfb12f8aaebfd379955bf956857840c6637f2c15f6378f9cada052669b485

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c556364262e9ec74025e1f1f9ca69eada4bf78693f4751824b4063e01c0178d6
MD5 855ed5f77347e31fd295859cf016cb28
BLAKE2b-256 b121fb419fc150d445490984079965cd124cfd0412958ef29cd90a7a19fc17b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.8-py3-none-win32.whl
Algorithm Hash digest
SHA256 00227a68997d208839d471c1e4c7aaaf0f2e609c16351955ce1189dc5c9954ab
MD5 c4f4f36136716a035513da3e00e00e1b
BLAKE2b-256 e060b0f5749edd818db2eb630e9f31a26794c3ab260660b08fa25fe901de4857

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 a7ad3a6593b8f577d603a826ef9c06d9ff760be631351e998c3efe1bc3b943ea
MD5 8772ea54fcb570bb04bdff3dca91a142
BLAKE2b-256 af3f7b80b2855a84a52b8ab6d2f2d2436577f296ae4b5fca5bea5effd32200a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9f22387581ab10887e86acee18670edc34ae95af77c794a9ba9d98747907214f
MD5 85aaa9af5395276a3ca1744e559a91e0
BLAKE2b-256 082d38355f98e83b9478c376fd5b4663f6874787fee8599ffa07e1a1903197e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.8-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e76e83f14cdb1afdbfd89e8b5c9cf4b66a33bb4cc2e86caa59f78f25e414c54d
MD5 b561ba61aa0d60af210634baa240e969
BLAKE2b-256 c92470c0877d55e46d6179131356e570b0609cfc56a2c1e1dbbd7dc3ebd534b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.8-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4df358b618949c0a409f879acf0e1c8e4a8ee3f2531c2d7f7243866fa84d3532
MD5 0190e35a6de29f25e02e0458c2e74ea6
BLAKE2b-256 22ccceb0396874cf9298a8761fb2011a44c5d0bf5e4484f48110023e6f49168b

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.6.8-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.8-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d723857ab170c125cb2247b64f0c9c570c034e20ac27826e51d35ba19687e54d
MD5 5bbbd525ea7dae3a946463030cab6024
BLAKE2b-256 b16f01645b6908d941cfcc02aac8acfb3a3571933f113f8138b3e8833936cffd

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