Skip to main content

Compile Cargo project with zig as linker

Project description

cargo-zigbuild

CI Crates.io docs.rs PyPI

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

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. If the --target argument is the same as the host target, for example when compiling from Linux x86_64 to Linux x86_64, Cargo by default also uses zig as linker for build dependencies like build scripts and proc-macros which might not work (See #4). You need to use the nightly Rust compiler then cargo-zigbuild will enable the unstable target-applies-to-host option automatically to make it work out of the box.
  3. 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.7.0-py3-none-win_arm64.whl (540.1 kB view details)

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.7.0-py3-none-win_amd64.whl (560.8 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.7.0-py3-none-win32.whl (531.9 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.7.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (598.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (598.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.7.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (657.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.7.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (685.8 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.7.0-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.7.0-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 3b3282c0cb7a7c682ca7b6828fcbc86ef2708aabecefb7164dff4f6cb9562ec2
MD5 3617f94056d03a5db78b9fee84d8ac04
BLAKE2b-256 5338f729902b4d1863bfe808010b146a369b614c1429b5893f1046da8b7818ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1fbfb207d2c7c5fce681ca9ffff55d491e975c48a8a8d99a291d84622ce61363
MD5 774b42c7d7d7a551ae00584067876a17
BLAKE2b-256 2d4c7e89b02ed42f48e60a8b8369d31ab53ca5b16ed2b71e681fa890c57ba0ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 d4c4ae1a4b1d3a0432dbf4f8917fc6dcbf5a2031036e0d33dc0a17856ac97079
MD5 7faeb8ebe915aaa7b827702a532f3c8a
BLAKE2b-256 998bc9c9a42441655a3d8d2598dae7ef1c2a2cd583309f20290ee31658e943f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 41ccb68cd97c072ffbba31d545cd3a48f814e1ed427970ceaa724fc018d6d3d1
MD5 b0a362369cb93a8d229236e6c149d2a1
BLAKE2b-256 c61af1512871d36570a92bb01243079d02a2eb15d25cf3effe78dcb7c400fbb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0ec47b6ab792cd1a2e23258385d6bf29020ebae5d5ad6b8dc9a5003a248ca08c
MD5 56c2bca656e0c9499e24a23b735f1dea
BLAKE2b-256 4fcd1935cf37f07ca616d09de0e4db1a624785196ad49466dbad9e484c30400b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8b8d30eee006f4738712bb85203fd73145669846d1bb5cb7c003e5ebffa21679
MD5 d8910fdfe007644034e212fe3755cecf
BLAKE2b-256 3e73e3da9ee1a219a86a7c0ad30a4f8387e6dd3599bb2448bb822a6c551e9eac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 30767d96ff69f76e5de1e1834a6110d080928f83445000f73c12b533c3626a11
MD5 ca9d50d4ad6bafbeb562bf5f8ef88bf8
BLAKE2b-256 0447615123d38ba564c32b666709dc90fbe2e8716029969936e64b73d3e6b53c

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.7.0-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.7.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 bdab542e32cfe289c651c35e8789e6ce61013bfc7750668d42781d6054a6ccd9
MD5 90159306422238567cf3d9f0dd6cc096
BLAKE2b-256 a941121f5948d4292927729c3b167294d01a9f192f81a258c0b9ba9a4c0d20d9

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