Skip to main content

Compile Cargo project with zig as linker

Project description

cargo-zigbuild

CI Crates.io docs.rs PyPI Docker Image

🚀 Help me to become a full-time open-source developer by sponsoring me on GitHub

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

We also provide a Docker image which has macOS SDK pre-installed in addition to cargo-zigbuild and Rust, for example to build for x86_64 macOS:

docker run --rm -it -v $(pwd):/io -w /io messense/cargo-zigbuild \
  cargo zigbuild --release --target x86_64-apple-darwin

Packaging status

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.12.2-py3-none-win_amd64.whl (635.1 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.12.2-py3-none-win32.whl (600.6 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.12.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (664.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.12.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (689.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.12.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (741.8 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.12.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (777.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.12.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.3 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.12.2-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 96b859870693ee989fa00bec2b0bd02fbcea1f60335ea4850ad4680ed60668bc
MD5 48c01d692e83b4c2f082458392378db8
BLAKE2b-256 402882ae66a1dba857d885a5e8a530ee39673193eff6e49286c25285e70fc5ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b92a701957579000381b1cb9088efc63faac3f590a471d2e5e14fc8cb160f3dd
MD5 b20f1c67d0806d1c32a8175addefcd7a
BLAKE2b-256 dd61a11e7be52fb5796c8b9a29f86730cf086e252fffd6ae2abbcc1678ac9208

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 a455fe507605c26b5a0bb81f98430c942d17444cd076413202e0fb4e5000aecb
MD5 2053eec88e13355bcfc984676f31e248
BLAKE2b-256 c6c83be7919b9fa386ffcf1f2e1f72f7c66d2fd92ee37ac36e3f030f1572bb63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 3fcf475d0fb49881612f45c6800319731bd386f09ca00ea9a2295dfad9a2d8a2
MD5 afe1c267c1f200671298c05b5ed96e36
BLAKE2b-256 61ef60d75bd18ecdb212a01554270f4749e0ff2ee10102620a9dd703a0e32c18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 22e69be1c01d39aa942b9983e81586ce34030b99a047bf410e8640a541a50c97
MD5 eefef9ba9c3267eb18cc9ecfe47dbb18
BLAKE2b-256 4165a280ca6f2adc26d0d339f84c459513fe9f57a04f88a29a589bf3bf27c1c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9587513fde7b1e470f609e80cbf909498bc626db89bc0f5b8a95ebb6e11e7aa0
MD5 92bc797b6b25adfad35ed9bfd44869f5
BLAKE2b-256 c869f586468ce5457bbe40139320ae7271b36040cd80e52c4436e8bed060e71a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4b6939c8e6f7dff42b8ec21ea1d33c998fe60b2e1c7d14a8fb6ff4a7160c9f9e
MD5 19535e6aa747891c8766e39a7a9be629
BLAKE2b-256 b65eca03a748c3503d4415e839b0624f1d3070aec31bc1991c1db612190cd4b5

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.12.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.12.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 10e0ecca3c6de1de619bfbd62e9d7e0c889219a15e9c1cb60944b7a88df8093b
MD5 522523ac7a98cc30d2c87dd97e7b6509
BLAKE2b-256 99a3ae4dde6f9383be7bf0251bb4902ee4a9ccc2cfa261643b83406da0e38184

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