Skip to main content

Compile Cargo project with zig as linker

Project description

cargo-zigbuild

CI Crates.io docs.rs PyPI Docker Image

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

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.10.3-py3-none-win_amd64.whl (599.8 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.10.3-py3-none-win32.whl (572.1 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.10.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (656.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.10.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (678.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.10.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (732.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.10.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (770.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.10.3-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.10.3-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 16cd234a83a931a0027ccdfc6aa00719964ee598a0d43638c611513a7a867d3b
MD5 00c5acacc7bc84d2b928935e89e5ec0c
BLAKE2b-256 6ac0bf17f674c106f23e34050c54f90adfe10fe08daf9e777e26088f5a16bb1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 38e9446c3cdd23f01c956adec8b1254446d8652bbf16db46bcf05a16b3a21160
MD5 6181dc69e38afce4dc22ddfa98d63daa
BLAKE2b-256 c591c94deacc752bbb55740db64e59874c0bb444b0e58b5e31f1bfa2453b88c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 c550f33c64f02430ed63cfcba8540a4dd942225f7f4f1e323685c2c721edcf56
MD5 0e90b65375ff47e40c102b5cd6f29989
BLAKE2b-256 ef65a232c1a4b72cbaa305f5858df3261ef7f40ba480961ff781f3a73f7c638a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8924789e639666f0ad8c6942fc09535c595ecdbacd1ba751b4f5175df36c5c95
MD5 9b4054a6b42dbc13d87f45a96c65ee4d
BLAKE2b-256 a6c44e87abb01c4e5ef58c3c9aaeb9e89240493b7eb410073c4b20c6e6918ebc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c3782f380ad2a031290a223dd873146f4abe3d19dcfeb4188b2f700d4323e1f1
MD5 2822172e6f2f4ebc579d4839467c7bc8
BLAKE2b-256 f6a8bdb3201b67b0bcbe4e257a35b3b6a625382da355b879f5553910a8928a55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bb2e9a07acf7df6ee97f2153128d79f96a48f1d43f038968ba12a5708bd4b39e
MD5 937fe21c48b40df9eee4fb7f9acb70d6
BLAKE2b-256 6b496f3fe83d5776d21233de7af690e5f137bdf8013b3fb02a3c62591459168b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 93ecc5964a458521e8d524b4310d31ad526733aaf324ced7dd4ff992730c568b
MD5 3037f773a834ad0228e23c4a0ac9c9d0
BLAKE2b-256 3eaf654c9d407756085a2dc25f146de679d603eea579cda5e1134bb4d2a60428

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.3-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.10.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 f526366cf36230f30535da5fa96fa6e09831df2d5bffa8f10330362e8f844373
MD5 81c38a89462372db4ba268b743ad4d2b
BLAKE2b-256 7c31bc5b63a1de45d2cb670b525806f63babd92d81aa6f727c52319151b76113

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