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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.8.8-py3-none-win_amd64.whl (556.2 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.8.8-py3-none-win32.whl (531.8 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.8.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (611.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.8.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (631.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.8.8-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (681.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.8.8-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (718.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.8.8-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.8-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.8-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 20bcbbc0a586dbb4b4870d03d63444165dcbb74a1efebda7b5fc10d76b821382
MD5 61e5110c90cfc5eed47319bde1af234e
BLAKE2b-256 32ce65eccbdc2e10dcf359bfee8ccf7e1522568bcb898a0c3306da22188a93e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.8-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 25a25614de8a2a0ea9d1563ff5aa29f4a5757b94adc0e0307531e31cf95de812
MD5 41304930cfb26ba9982be1a7f2f4130a
BLAKE2b-256 55acee0899b8d720c655dda9e7f2c10ccf3f195e48167e9ac5127d666ffc820c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.8-py3-none-win32.whl
Algorithm Hash digest
SHA256 c7b96ed5c4eafec66b983a7b0c9181d78c1037ef32cb2afca9448a07bd1c3d66
MD5 5c68e67fb1efef6b35b92a1d9812874f
BLAKE2b-256 ea060f2e32b6cbaa18d8a4b71cfdd971778c7059ff35fd37300d429ee81ef744

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.8-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 40fa3dfd9d824e3bd663bd21274ddc7066083895dd6f37d225afc2b63a1bd1b9
MD5 017d3ea5c8914399c55d22cd64a67981
BLAKE2b-256 1d4969597b606b99f7d6485d6d5c5e1f3b69cbd2ccfa0ded95e01db6938c412d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eaa774e1c26bccc93971e6c671dae273479222e2e4b6bee49ff9af583e08cd3c
MD5 9e405ca9f6666eaa61084d90c85f6df8
BLAKE2b-256 57e428221de6a4f1cca807d626fb59274ddcb931d95784aafe50438988d8c689

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.8-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0bdb47b74cd47ecc0a3df42ab32dd59ce614cb69963f1c1fe5e1537677f154bf
MD5 0018d6b0bab47ccf2f4a0a006c44b5cc
BLAKE2b-256 6ffffb827f0f87fc2f32ed0d545c8dff269a5e41199086af5b4940d9ff24c009

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.8-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ca2c45f22b936d473022f09e5b8bdc6a5fb14a3194cbb22395b8d5820f44f24c
MD5 9668563ffc08ccfbec2082d00addc174
BLAKE2b-256 e729fc01b5a51ff02555db61bcc31cf3d8d21aa3c6d32e5d7af4aad641e41a2e

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.8.8-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.8-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 47b44871f793fec62df30aea1c1b285a97bd4e0f07753d34ed10e0c4f0f4b5e4
MD5 f884533a439d65f82d64a66f7b649488
BLAKE2b-256 af607f3ec35a9d0ea08ede8dcdb1f644ccca3ded464c01aed17fdc4ed171a74d

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