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

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.7.2-py3-none-win_amd64.whl (561.2 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.7.2-py3-none-win32.whl (532.5 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.7.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (599.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.7.2-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.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (656.8 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.7.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (686.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.7.2-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.2-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 eab6d5cbd557145e54127b8d50ae671d5a7a1cb419794aacc2ff09f18ed7c900
MD5 767aca5fa4f4061d7a7437c3251ec522
BLAKE2b-256 76a6ead39458dc96bd214a795aed299afa884189c444db2a32f27eebf3b44b0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ae9fdf9e902e60b4051dff084ff31177440ac2e8b3156d9d836c3f54acd53c29
MD5 058adbc52dc880b2ffd1fd1f6e9a55c7
BLAKE2b-256 60e22c563fe720a014602eba37658b3cb616932e253bb865201f40fabf4a1425

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 92cd23ecfb81067c03883e69ff779fce43547fe881270285b3be79d1774f41c6
MD5 dc51e8f333a374d0a66bacf28f34d305
BLAKE2b-256 86a43c5de3b4caee55db6fff431c126e1a5fcff7a7666e4ff927271ebe03c85f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 cb133bd1daab9d9a6e9927b19c5b4d252f8047e82ec1d87801218bc674063441
MD5 0e9c4e2aead0cacacaf89cf235ea02f1
BLAKE2b-256 0520250d72adfb8b100b0c7ae68926802e147d69ee2387204444d9ac2a68b849

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 47a7ca8efaf042dee12d4b31a0e88f443be5e6931fb77b850de9055a317ab7ab
MD5 04eecde9f9b012b2c037a8b3b6db6fc4
BLAKE2b-256 153e46c792827633d8fd6c982b90433d979551ab0d7307469c882cfe4a5a64e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 96af41826be979f2a2c18def531ba11698d6e97f9c79762e00c813a9be1d5706
MD5 e304bb093df01526e28b40083e1db660
BLAKE2b-256 67c13d4f050d558418e5ff4e0fce119af7489db5321e6124608d703891a2a97c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.7.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 7ae0d80acc643123cefa738f29509019c27dd6764d01e600767271583f59f4ab
MD5 f2c17aaad03b2509724de657701a4b4e
BLAKE2b-256 3aad11245d477d485296e7ec8b885aae8242c8660ead33e8defc85d8e08602c2

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.7.2-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.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 2a3f83a5688bce050c2941b056ffe8dd8923da3eed240de55e1761fc79a6698a
MD5 73c9f61a5d7f03ca366296a77fdcf246
BLAKE2b-256 9dabf27610fc77f7296856d6f4c34bc677d75cdd4a5f4f12850bb996ba19a0b1

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