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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.12.1-py3-none-win_amd64.whl (634.9 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.12.1-py3-none-win32.whl (600.5 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.12.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (664.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.12.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (688.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.12.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (740.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.12.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (776.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.12.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.12.1-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 58beff7c0cbef149cdafa1f561f5ae6840cb276036d66c93388bf23ecc13ca48
MD5 ce9a35df79c892f1dfbd68cc4c93168c
BLAKE2b-256 fc3622798c433f7a008a75c074ed949c7f80ed9cf15375169062fde7d193ed22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b0563ada5fd9e097e0e52620a7f3a8e6ba1ec465d23fbf38a2374da71d39f102
MD5 4261eec52cf1db86cda6a6a79e0643ff
BLAKE2b-256 5a07ea89a46bbc10ed8c064031eb428b37998c7ff6049eebf20a221cfe84923c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 c8f2b20624a7d56f0947548de71af83341210aa57b552f0a9098ce13f4166d9a
MD5 70477444f0237198087050dd070cc3b1
BLAKE2b-256 35c12936cd059dbd3c1010ab3ef0c501e8044a3f87c9ce5cbf18319c67db1b38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 a0a7fcc14f41d89bec01763dc11f666b82a96d215808d37ea9cf3f7d36c05d4d
MD5 7e35ab44061d7f29d5e7b9a7e6c5d574
BLAKE2b-256 004334a1d055fe6e1f660ef9a7178d307f63356dc935df86cf497b73e468f0c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ebfd134a7baefed476b5f99ca4eec41e0380a991ad5d98be8aa2edcdf9da7604
MD5 557a85b5d38930f76209335d1bbbd459
BLAKE2b-256 e15adeb5f5e7b55d60e22b513c064c9d812a7abb134a0603ad08ce09c9dde23e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7850981bc982f78aa8857bf6dd515743d136615ff07f35c006e92d1c8484878f
MD5 324e7fe08ac83a724df0ff04fdf129c3
BLAKE2b-256 8218a5c0bb0fb6ed360255fd5c166e876450a69a50effae8960c9e252c781909

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 6f1bc8cd9f2df712d2536ded7d2721afc2a493fd83c1a545859c12979fe790f8
MD5 27a8b5162044f93c73fb0527f9e9ea3f
BLAKE2b-256 c9bbf678602b60d75245a20d69b06da2c711b40f72fdedd2c1ba262d79dcb9e3

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.12.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.12.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 cc8a376f410e1b1b7d5281cb4bf636da918436fc42ffff0968a3899ddc6c15ce
MD5 42bf8e036f9133ee5869db3e8f8a00f6
BLAKE2b-256 fa0754c538829aa746d0f776241502632c60fa9455eb924e872c67838a4c5901

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