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

This version

0.6.2

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.6.2-py3-none-win_amd64.whl (449.5 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.6.2-py3-none-win32.whl (427.6 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.6.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (502.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.6.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (501.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.6.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (552.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.6.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (573.8 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.6.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (963.9 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.2-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 d619435261fb6d0a90503cf0b56823788f20795c5189e9788498d7b442c5284d
MD5 28d940b8c9d3f6b58a3224680935a124
BLAKE2b-256 ef4184785510ad5aefeea266dc936eca27a1d2250813a33d61db680d002a75c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 116a6e654661be01ceb952284e1f85e6cac8feed21ac8adae30faef6e8fbc969
MD5 36b8b001f26d481413b60b6e3a46a214
BLAKE2b-256 548c9b8c079798ab505a9bd775f51086f80d8a19a4edefd44ca9880c4d244f7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 522d86131a9d097b5597fadfab387b71091b786ee41069098e3d0ce1a5c09d46
MD5 5d352bf3ba065d02cffdf18158bfea42
BLAKE2b-256 02e613a511c067719799ea5983b1ef5b7f45687b8eb89fa5ddaa6652811c3c63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 fdbd1ae9d9921856761d71d1e4c06d117c10d40539a9d4d1c813141cd45205a4
MD5 14f3a50477c3d2e2a237526654ea19fe
BLAKE2b-256 9293707297dd545cabaedc5b91808c0f3ddc089710d7d0b8bb853bf3788311d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 61615f67447837f695a44bcc983d66219978e3f2a949629f4184e0ae24b0a599
MD5 8bcf220f84b73c24a5959c1d91132805
BLAKE2b-256 02cf66529336aac7fe301fc947c10f9645c7f01a22932dac8554b2c71165cc7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3d4100085bd8c20c63d0d8825b5396335f1c0853e55fbddaf39544088da96fca
MD5 d39bbb073ff6f2684d3ab3ac86d54756
BLAKE2b-256 152289d998aa58afd6f53d11295343da2c72260fcfc11367697fcd7eddafb713

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 2f3e6a7dc48ab10801f06eb850d60c16ecbf35ef9de7b881cd2527a2c3410b55
MD5 8654305ef0cd7e9d130eadac7837a5a7
BLAKE2b-256 6caca2275d5b582a1e249abe6afe2e1f50ef1c930741469180343014b16d259c

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.6.2-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.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 4510db62fae07ff44c74d0f00335e4db739a7e63c37f7308831755db21a5e404
MD5 218cb6c67f434c798d67af380b72e865
BLAKE2b-256 6d1767a75e35956d0f7fbfbec9f83a79aee914a117099eb2540f6606f2b41e86

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