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

This version

0.6.4

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.6.4-py3-none-win_amd64.whl (541.2 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.6.4-py3-none-win32.whl (515.8 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.6.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (580.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.6.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (580.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.6.4-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (640.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.6.4-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (667.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.6.4-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.1 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.6.4-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.4-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 1f578e00862059abcedf53694aa247234a97a454a037c8f7363eea31367f5465
MD5 80da2df0b4785f92dee741a08c8d5ece
BLAKE2b-256 9ad7ac665d9d4545f41fa6aabaaf9c4c7c5b9b9d2ccdf56485942c817b943967

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f31de1d58601bd2f1bbaa9c50b45b0546f4cf6c25ac3b0315d6ca02047d36233
MD5 207325fb1caee5cd016b95c2452289d3
BLAKE2b-256 3e1b3a22e3b3a53134f3eeafbfb865e3643a832b7001d1565904a2dbc2a718bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.4-py3-none-win32.whl
Algorithm Hash digest
SHA256 4ed41b0a104ce81f985149ef9b14365a5a8d008d4cfd976aa9f0109fcd6034b4
MD5 7637cd0abfcf253775849c3e2fb9f4df
BLAKE2b-256 d19b1aaad52deb0c1f596c3f520212c30aeb39967634d88f4ac62b0052cc5c32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 1c51064b04c9a31b2ac8c99759c3e2236dff3fd662cb447ebb9f00c4fdaac5c4
MD5 ea7192821e95a731fc0114734d8b2d1e
BLAKE2b-256 dbcacaac102ceafa3c7eca2883c46f96f30a497b59e0368c535c16be5b544629

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3a2e62b8844742724158b867860f8450ad4e26a501fc0619177ceccd0f2f0c32
MD5 5d47ff86a2d15faa4d6174ba9ca635a4
BLAKE2b-256 f10aff30652f78422b9ef9736ba234d8e14ddb25716b382d3ae68a55fce436e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.4-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5ef9151e5ddb8dff531c010aef180f7bfca5f79a8b5f56675ea743092136b616
MD5 f3b438582ff2bcd9e0fdce2ed3989ed0
BLAKE2b-256 9daf928b04fad2af7fa6fdf005e1d639b9c8ffa15e64a61f33ff20b72e308a73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.4-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 7ba927aae99e6198791f9f0cdf60e67f6acc3dfcbf6ccc6beb20b3487de361a9
MD5 e8dcfac454521dd6f5ee77d1645af90f
BLAKE2b-256 fe2228587b62cda48b94f21cc0c4bfde8d1b61c7a638c0c84cc757cf7456db65

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.6.4-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.6.4-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3e5559a5487ab4dcde268f69fe76a8b7482d4571fa7c08260f12fa5959f9b24b
MD5 4450077f7131ec13ee0215b247df18a0
BLAKE2b-256 6bc25a8121ab16758f1b3b0bbf445945e0065674d278b701cb89656940a7d72e

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