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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.11.3-py3-none-win_amd64.whl (619.1 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.11.3-py3-none-win32.whl (586.9 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.11.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (666.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.11.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (691.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.11.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (742.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.11.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (778.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.11.3-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.11.3-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 83c697459db5848315c96c5df006503dd8bd9330e87d0cdd640c06bc48ffa678
MD5 4d5c7d65b2ee29f806507a0d377427df
BLAKE2b-256 126400c65385cf8fc8553808d7c6da95c44866412cfbe1e8110318d895316c1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 420c4e7eef9640a4c4ae5642f9dfbddda5df0aa3f3b60ccf992d32f6c7261a08
MD5 3e50ef6246f3e170432524eae520fc2d
BLAKE2b-256 d7be77f8bd88bbd04bae9b53436915d34d8fd8da13d0d4e3e3f6fc4693fb6d9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 84074166774121e0bbe10c2fa78d268013198fcb4b3e9e7c804d0d905af73444
MD5 1ce5dae1b99aba59dfc4559528f0bd4d
BLAKE2b-256 831dc7b0aa3c8d65b3d714cc02125c05186836e05ed6550e0ae283ffc3af27eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 5fc3ef56c2bb8fac172d83e0f6cd01d24748d9ff53dbb724799c845f4fe75367
MD5 5f007390d427cd0a7c4a48f15828e4f3
BLAKE2b-256 e338e905e670aafead6907feb41256bccf32ba183f75ce06b1e05c90540af03c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6b301a6c0793f326262aa16c7d0cec09fd8c7d24c89a557ea6239f808f92886b
MD5 efeb1d9047de37b5c2ae50ddbcff66ec
BLAKE2b-256 2b369e7df1943846b71de2758be9c1fd987dc875887a8250a53871af7391877a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 65353652dbfdd92b318cfa75082fb3036c88acff462dec386bfb443dba170182
MD5 b55d31b78ee8d931644e7c90bc36452b
BLAKE2b-256 5f7124f2f71feaed7ba5cce50d16677dd8414720908c65a6afcfa3696b792034

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 12b3f74ec780b777585e17206041799259985f3f41e07f2638ec68b8e4108028
MD5 e0c48cd48104048f2feb9ac4059db7ba
BLAKE2b-256 67ca02213059976c85040b1d02fdf80b6e146b1978e829fcd4bc0143a33b6f70

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.3-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.11.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 038f93898fc457cf8c281c30e6713b3d73bc0d501e163f1c5a581a9834b50c38
MD5 597f67c5adc82920d3eed423c854be41
BLAKE2b-256 2d231f759252622e942d6b82a59d9742e185749cb09fe2af1f9e5f6da2f83aa9

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