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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.10.2-py3-none-win_amd64.whl (599.7 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.10.2-py3-none-win32.whl (571.5 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.10.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (654.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.10.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (677.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.10.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (729.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.10.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (767.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.10.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.10.2-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 b3c11af0c9f088de18172090de9fb71aea708c6cbf42553ad6b0824401416afb
MD5 1569aaa7268e7a75e1655d215406a767
BLAKE2b-256 8e2fc66fb5b556b0c8f0db2efe71e14cb1fac01b5af6dbcc994223d5c5ba6e49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 601a242985cace07bf8f1dd808d23ebe4087b07b43938a895bd8191c5b7c92f9
MD5 144d9c32026537e25418058cfd27b393
BLAKE2b-256 37f4120cde7d9827829f12f455b40b47f186e5acdc0ca488b42790f430727b1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 7f6d8962399d1160a81959e62e08ead21fe1112587a84ffcd4c4f9d282b19454
MD5 5f00a78660b245426df87c3e451767e4
BLAKE2b-256 c87887d8ee2f136b32f5c098644d9918491c62e2140956f8cc5a008539164370

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 9997bda5dbbda0bbd0cecc6cb2afb16172bbc7c61410f0a210b341c151bc9d05
MD5 3a76a568f66dfa360b3314ba965c6176
BLAKE2b-256 74ff3d27f3e234c392779ef2c9d05c5849a7334b6f7c5b28f225c0da69384d98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0e870d356b37ea489d464a7f01c240767c0f7d1acee29e2d556f76fbb6546828
MD5 476672171c901afe9b2528b07db691f7
BLAKE2b-256 97e4d9f7912fd79e7a204adb969367ec68de970c3211cc016eb0cc0dc24d0918

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 83c28a8e7d2b1edd408977e2e1a3232ce441f8f2faacbcc6502404b439940764
MD5 d6a814bfb6aab073eea3c448ad64868f
BLAKE2b-256 6e2c2a0a44df136fd5e2f1d06196eb0e07907b4aad08fcd8dd134c1c4ae081d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 71c758670679f9e9f25d368913f0957a5b827941eef67e5dfafdc9e7ad6c3ad9
MD5 0cd22c1e70aa25a29b2ba6ed583a4d82
BLAKE2b-256 b89a376e9ea8a4eda58d97d8a6a8c4f0e3e106d40827540f103ce7a411af1918

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.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.10.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 936d302bf3b2101f878ebc3a20c0e92ecc8eaa2a4b2b5e8ad824f7634880fefc
MD5 27a4a4dbeaf9e98846e6f2588bb2c0f3
BLAKE2b-256 f141a7a5388c472be3df006ee770a9fc67a7d9788ab6c3c96be611dff142a9e2

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