Skip to main content

Compile Cargo project with zig as linker

Project description

cargo-zigbuild

CI Crates.io docs.rs

Compile Cargo project with zig as linker for easier cross compiling.

Installation

cargo 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 libc version

cargo zigbuild supports passing libc 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.

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.5.5-py3-none-win_amd64.whl (446.4 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.5.5-py3-none-win32.whl (427.4 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.5.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (505.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.5.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (507.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.5.5-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (560.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.5.5-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (582.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.5.5-py3-none-macosx_11_0_arm64.whl (552.4 kB view details)

Uploaded Python 3 macOS 11.0+ ARM64

cargo_zigbuild-0.5.5-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (972.4 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.5.5-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 8ba0ed48f11c169788ba414cc10e02c98d479a322f73e1670b29fb966317215e
MD5 eb4ec7a826b9c5734abb44ab0faa1573
BLAKE2b-256 853fdcbe5d0364c71dcb9351468d6f0df46e9c19a72f82bcc6429964fe795c80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c7a43b080ff8d3f2d8816db92dc59858bcbf445e2770418323a5937feaaee620
MD5 8d14cc443040e4264bc60e2842c94cd1
BLAKE2b-256 bef355e38ec826522e4fa5e1bd2b7a661b566b4427d701253f0ddfee75549db0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-win32.whl
Algorithm Hash digest
SHA256 8467143f0095a2c4518b87e193444894b6bc9b239c3d3d8a9b619e91b245ab5b
MD5 5d1abda58ee0c66b35a61b1af8b8b399
BLAKE2b-256 8bcecd5904b0b67c057886861fe931e9659b8eed641a2569c9728b8e81db7143

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 3a8a26c4d295930f599f415fd7590d2fb0fe6abf7fd4d13c6652c3da23270e08
MD5 d0012df591ac8630c1e0f73f62e030f2
BLAKE2b-256 3fdcc902165ed3f83f8bc82b22c6009d500d29841cfa382b159f18fc77bc3d4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b9e936f37b276b217d36de8619e5206a8b28c7ab3f82374105d2f24c3ec631b8
MD5 255a32182dd6805863bc6d9c6a64d594
BLAKE2b-256 2fa3e979b64c6e301025fbca752c09fcbbcc0e63e10af676d7b5a3d7854da77e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 581dd431088f9d5f64a7bf8879d7043902aa01292b174b0e2b5a99e5497f55eb
MD5 1f6e319c26d28f923a0339d33fcf494d
BLAKE2b-256 04aea996c372faedf418c8ddb98488a401bb1800a6225df7e1d7dfafeb6fcacc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 9283c990d1a89a8848013e4bafcdc17503e8939734b91476f10b4e9163da7680
MD5 b9fa6cd5899125d5ee38402c85bb4cd0
BLAKE2b-256 b25f04fc13d1624820cba428f4a79fedb11a710f0dfadcc7d9353318c91c0a55

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.5.5-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: cargo_zigbuild-0.5.5-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 552.4 kB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.10

File hashes

Hashes for cargo_zigbuild-0.5.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f324fbd398c446db38a8e70d7357269da5153d160834054afd37e6cd461b9812
MD5 3e7738a55e84db81250e171522dff655
BLAKE2b-256 70b119ba2a2f40b3f5cd18c7df763b99ba7178bdafda7309fa66f5209c8c2491

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.5.5-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.5.5-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3055ddd86d557c24a0878ba3fa80bcc58111c289b7dd2ff062d3e17ce9b148ed
MD5 f8a676dbd7c72e1b00949550ff1e95a2
BLAKE2b-256 eff3e40a2bf10e08bdd28591eeb50c248366a0abfc097d74638e382535e4cf07

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