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

Uploaded Python 3 Windows ARM64

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

Uploaded Python 3 Windows x86-64

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

Uploaded Python 3 Windows x86

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 4ae2d4fcb3e30201a44ee3097eef25db8941d1af5c826db96feeb16a1c683d88
MD5 21da26ec5fab8d3d65f0580bfde7e4f9
BLAKE2b-256 053a6323dc51c4cd788c63f13fea89b3b3815479a59451236c4189cbeccb401e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 77c119b9f90c9c2147485e716576b11122ad568f9ca7f86475edeb2cd4c8750b
MD5 b6722b40cf4117451f2f5244c04cf31f
BLAKE2b-256 87005ae393c3161488b6ea8224f87dd535a9fc21b84670e8ecd215e89a4df29d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 4a61ac6d868750d7f2b2f335f98b04ec8e7cdea6e68151ec5a18aaf1249be1a5
MD5 cdcadf92b13c8b47421844371ce7529b
BLAKE2b-256 af4c6f89ecf9d0075c3669762ad05634f9d87884ff1d3ea5a07658d7d384216f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 29bea877219088d448e29951ea6c871f2fdae9940f71c522dbd1a6ee1393e8c7
MD5 27f7a9a2a9985d7cac4b3f502080fb45
BLAKE2b-256 64ee847376457af720cde1f1a4e7c56c4de9461b949516ebe61d6399e5d47823

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 232849808d13dfd40777a96e05166f529470e1b994ce263c561a086a3e059f6d
MD5 4cb468335c87cd9345ee43da555c915f
BLAKE2b-256 2adb6fd5f90cb7066d45a5594a345f137861293f7d6688af99ff5493fdf35ffa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 15cd40ff8496c7438e8ffd88906633bd34a6f4e65c90ba07448be9f39ef3c12e
MD5 4d9b24c661ff0820bec6ee3a09254cf4
BLAKE2b-256 1f4660c3c829d4ef40a69fea51d44c0afc75b0ecbbb1fd7c1d8dfdebd4c2ca7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 efe7bc372467f0fc845a26218056b509a5c187feb7d2928f2092925ef431c3ac
MD5 508bdf97ec1cfc7209423e4cbc49c094
BLAKE2b-256 23bb4929295b2b57ab515ca1c9fa8799d5c0c276d8f1a2e2259c6b50f819999d

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.6.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.6.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 7643397ed15d2793ad7b1b13d692f51f2e51b0ae1aa62339a938e225daf1b883
MD5 e5404fb1b73d62f8594f1d9ea6e11997
BLAKE2b-256 c5a502d5fb8453898dd1bc7ddc28d6d4766385be9785d75506a85caa8994a80f

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