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

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.3

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.6.3-py3-none-win_amd64.whl (540.2 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.6.3-py3-none-win32.whl (514.6 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.6.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (581.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.6.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (579.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.6.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (638.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.6.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (665.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.6.3-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.3-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 9acf37869b3527decbcf900080abddbb4bad9315b315e7a7a235ab25a18188b9
MD5 b2f2057418919540c705b34fe64fa3ec
BLAKE2b-256 fdb9c5b496e8fdd6ee2e17c0a438fb8c4bd810c8d54c41c80682f3a652a54dbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4bc28999226b6cc9c32610a677eab275ae1165324bf51043e9f659d9188a23ed
MD5 9a1bc1edbe123b03f586320295bd007c
BLAKE2b-256 878fea4244136fae40832e3cbc9d5b5864fc7438955e49b3a4eb86d8028f909c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 b7459b47057febe2202a2acd5d312df0809997fe64d08f2212b2eef37a3de482
MD5 112194699f6400e7bd995199e428b74c
BLAKE2b-256 46cdf28ef86be6157eba331322bb4c6dc8bdbdee5bdcce6658a3155e7be50b3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 507afa78d0172bbdca4ee1b63518764236d8921014bb4bff9b9ea96396811196
MD5 0291008ede580bba3a7a6809c5311195
BLAKE2b-256 607b13badefb03e1807ec1f83e9a4d0efbe3584163f3b0082aab8c46d80c9ea6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6a4a2bf4f6201d8d5a9dc04e2368d07c7049dcf0aa5221bea79abadf2c981fe5
MD5 b32d8a23fc02907cd7555ebec7cdd1cb
BLAKE2b-256 8edfd9f7a208282ab3a457df452d61e6b13f24b5492ee91ece84a74cc3bde75a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f23c76e50fcfd6a4c4e6aff3b7cdcb75fa303dce47a758449b38326d95a307b7
MD5 b276d05b85aee7070c33f32c83c31d12
BLAKE2b-256 ab3b08522b193764c602e9ffc89fed91885f9ec4895c46b9eee8b57033c1d9fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.6.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 03ecaaadaf0127e7654601a7c4ea73d7c6317a4f95cc60bc6d84f761aea41b94
MD5 2502fe6756ad54e93e8b43e032aed39f
BLAKE2b-256 1c38f7153640755d2eaaf47269632612fbc1275ded9ae530765c7d33d1cddec5

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.6.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.6.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 66b27889081330229b250fd0f9ab8c44a89f234f614894332ef9f8d9b7d5d777
MD5 ba8ab2fdb6f41494b70e37256af1907e
BLAKE2b-256 11e5915060ba53f70b2d35bd022b894690b2d40c36558574274f035f15ce1cbd

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