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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.8.6-py3-none-win_amd64.whl (560.5 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.8.6-py3-none-win32.whl (535.2 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.8.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (607.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.8.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (612.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.8.6-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (663.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.8.6-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (699.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.8.6-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.2 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.8.6-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.6-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 5638733d1991bcdba7f9c36bf3365dc145336b43f7e0b6790b4c095ad88caba3
MD5 1acea7ac7c493345f6eeb98feb6ce445
BLAKE2b-256 aba96b2fefa97491721e9e398cb8985d3441124b1b286341fabad51ec901631b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5324b3b1bfd07571a3e98dae1313e96340dfac7ff3fd169434a99f846227e090
MD5 f94e11ac2c67b4624a22dc95019aa337
BLAKE2b-256 eeadfae07623abeb1bb6b4619288756bf07577dfc8b1c81b102981188cf029f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.6-py3-none-win32.whl
Algorithm Hash digest
SHA256 77cbbf303db7493aa177c156fde986bfb9049f0b2c59eba10bf59725cfa15ed0
MD5 6b9b7f7f747888bb61bf01dfa785b36b
BLAKE2b-256 61f0b417af58109ef04806c0d273b3c946b7c19f2d1c5ef2ffaa1ae55dcc79e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 3ddd50cc1b92f8e6eba3edaefe90199733bb535f229a14d3cc99c470d4fcf4d4
MD5 845c6e696709a11055be63252da7025c
BLAKE2b-256 24be50b63c8793ab3ffac21a9b95ed60414c87c361c2b2e5ae7307128380d38c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a1fc5a18c8ea911fa7bb93284bfc77405ad1d6197f47ffeb1bfadfd334f1baa8
MD5 17198ccffbf3779eea1ef3222f472779
BLAKE2b-256 4bdb99a89785f3f21e5e275f9ad23be8b8663f1992c0a219ae3fa4f51c196a4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.6-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a8b90388d78049ffb9a68b0fe52de03a6982d3d6c518a7deb98b23fbea90174a
MD5 6747c5059bda03d1cba59022c27449a9
BLAKE2b-256 779db69e89712a48b8f540bfae0c7db1d2b35626a114e6b9670bf8452f8bdc65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.6-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 b2e87d40b5d63983598e9ada5f1485d9adbd78b7b2ce46d2b03e5ed1ba1fa5e8
MD5 ad411a9130cf0870a803ad19cead9a76
BLAKE2b-256 8af565838bb1cb0d87211e70f2fb3056b8efd007f09ec6dfa1ce9f68303f1f9e

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.8.6-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.8.6-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 457b7f37db0ecaa5dee40d17b98bbd2d88b04e5fe176f41592320fbb3a17dae8
MD5 698bc50cab0aa326e8ed60a5675f4336
BLAKE2b-256 69df509d349532a52ff715d9a564d9c1da0ecc1fe14d5bf75418acadc881a750

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