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

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

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.8.3-py3-none-win_amd64.whl (565.1 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.8.3-py3-none-win32.whl (535.8 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.8.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (608.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.8.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (614.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.8.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (668.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.8.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (701.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 1a33cc42a994a9d3ee3785e20bd48474f5a9b2ec4ce76e2477ad0b513e44cfb7
MD5 2faedda3175a932efb377179e67d7a46
BLAKE2b-256 ed0bc87501540915ce53ba65e5cef06b96464be01a1d018a9a43f744b0d79618

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a29464c27f790a57498a4fa5f3e12eb3bbeed110663d97b46a3df56446be71df
MD5 6c6b02d1040204064e24b1c2321b2cff
BLAKE2b-256 13650c03c94536902e17caa6903bb04a8be0db99b51dc9f08816fd4ce4be2ac9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 2eb862cf11d6283fd8f31cd8e4c387c8f241eec4b334225df2790b3ad1ccaddf
MD5 85e8315516de3507e231841dd113c38c
BLAKE2b-256 21613540571bad9ea8cbb671cf1fca022599e15ab9a00d6004fbb68ab703cdb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 88279332e24ed51dd7120e2eeca549f18b3d4be5a904af402d810b6b58fef32b
MD5 0fed0cdf76460d057303aff72f6c7138
BLAKE2b-256 a3217ebf53fdc2a7d95f77769fb2f80763bd6ad9c90cfd566e10226cb07e03f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 91eb7369cc29a0ef628448b944b94c144a0f439b75567660ec6c3fd0774b5661
MD5 79b43c187179f366b978c5d33075781e
BLAKE2b-256 8bd4fd94d52f73f8ff3cd038ea08f66e91542b1d794381b3e1e51a1ee5076176

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6c9d76965be55f8d7cb3072f0069ad3c3a3343bc0898ed25ab2cdf50ddcb393b
MD5 baefd27c4592f86cdfcbd33256067bd8
BLAKE2b-256 ee3ee26fdacfd27bc08938f7d0505131ee26b4182374f2defca7069d7cf22a0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.8.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 629d316a0e1b32e699bd3ef408fa63fe07cc6c419d868a889fc6426acb7e0b68
MD5 e47544cfe563f429a47a580080651218
BLAKE2b-256 8a79b390788f36bfd50299127720ee0f2fe0c968ed35689c959cd428ef6757b4

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.8.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.8.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0ddad89883b7230b8ae2b1d87f320590ed59141942699534bdd51524729d2b49
MD5 ca1ca9f09092e48bdbc57cf4fc16d2bb
BLAKE2b-256 43b8fcd22d3f8c21840ca54b5af381e8ea210d2758dbaf43bb7a50017c0d4e2b

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