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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.10.1-py3-none-win_amd64.whl (598.5 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.10.1-py3-none-win32.whl (570.3 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.10.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (653.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.10.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (675.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.10.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (726.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.10.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (765.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 7250ab176600e6d9031d9d1d4ea27deabd1803425453b40770a750ca108ec0b6
MD5 b9ddf1b2852a82b0bf96243be2c896f2
BLAKE2b-256 462d634d7c9c7ea12eb9fd3fc4ad6e4a16d118ad5a483c4942a054f20522201f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 bc56720e463c5907570debecfda038e11c75e8d5743452aeab0954de6226408b
MD5 4c68319e9db351e007b14ec03c2bdcc2
BLAKE2b-256 30514ee0486faa81821caaefcce695ac0bc398194cc41fe726c72b3d268a9d26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 df2b11a8323e93d91224183a673cc36cde409ab743347519c74e866a408b1efe
MD5 9cdcf838ed02e2bf94aab0e1cbb8610a
BLAKE2b-256 fbd9a4dc45eb00660ad18857170b8efd4a40eb68752d5ef46cca7cbd7362e3aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 bde31320ad33aee569a6f1ce43c4ea6638c0b617062b3d1ad3fa8829ccaac362
MD5 af5de9670319537e7f27fa656fb9adff
BLAKE2b-256 7b63b4d0c8fd5676f47d1a40ce8d3ad985f5ca5071bdfb4620a48648bec50a82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f23d2bd6abb8f6dfd0a8725b859b7d19ecbe7e899d6a1f7fdf298fab5ed7ee34
MD5 f44585191f1ace7562c052289e345230
BLAKE2b-256 43b7824c5af3628812b8f1951c3e801a5c0495a5932beddc013a2e7abbc6f5a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8666d3731e0ea8d904a8f11ea43b280bac9b5d886a2067cd8b48310ef3417bd1
MD5 7e81d796eac151ff53927d6376bc776d
BLAKE2b-256 b67442c65e79254400a74d5eaf60dbcea8fd9230bb258e5072a66e10919f04ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 b708bee64034baed3a893343b3833c1043fc89cc510c984f93607a5994fcaeaa
MD5 6a9fee741d0d5294bb02896e4e2e0e14
BLAKE2b-256 f88667ea8174e7076925cc88cc3896851cf7d75dc6d5d76018512a35d4c0ccc4

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.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.10.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 94b16ff927f7817809ea9506b3c0d8337e0e3fb3ebb6ad3e1f03aa88ab030379
MD5 82d1dcb1c6f9eb805255666a6b8f3148
BLAKE2b-256 0df9544f74efaa2a38b842fef50c54cd0b232eaa407bc061a4989a2020b5fbdc

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