Skip to main content

cargo-zigbuild

CI Crates.io docs.rs PyPI Docker Image

🚀 Help me to become a full-time open-source developer by sponsoring me on GitHub

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

Packaging status

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

macOS universal2 target

cargo zigbuild supports a special universal2-apple-darwin target for building macOS universal2 binaries/libraries on Rust 1.64.0 and later.

rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
cargo zigbuild --target universal2-apple-darwin

Note

Note that Cargo --message-format option doesn't work with universal2 target currently.

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, workaround by using -mcpu=generic and explicitly passing target features in #58
  2. glibc 2.27 or older: fcntl64 not found, but zig's glibc headers refer it: workaround by using linker script in #14
  3. ability to link against darwin frameworks (such as CoreFoundation) when cross compiling: Set the SDKROOT environment variable to a macOS SDK path to workaround it

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

Metadata

Release files for cargo-zigbuild 0.16.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for cargo-zigbuild 0.16.1
File Actions
cargo_zigbuild-0.16.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for cargo_zigbuild-0.16.1-py3-none-win_arm64.whl
cargo_zigbuild-0.16.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for cargo_zigbuild-0.16.1-py3-none-win_amd64.whl
cargo_zigbuild-0.16.1-py3-none-win32.whl Python 3 none Windows x86-32 Details for cargo_zigbuild-0.16.1-py3-none-win32.whl
cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details for cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64 Details for cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl Python 3 none Linux glibc 2.5+ x86-32 Details for cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
cargo_zigbuild-0.16.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl Python 3 none macOS 11.0+ ARM64, macOS 10.9+ x86-64, macOS 10.9+ universal2 (ARM64, x86-64) Details for cargo_zigbuild-0.16.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Total release size: 8.4 MB

Release files / cargo_zigbuild-0.16.1-py3-none-win_arm64.whl

Download URL cargo_zigbuild-0.16.1-py3-none-win_arm64.whl
Size 849.4 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
5c79ad69455af9e33a54aae7c622542306c66a911998b95c31b39f0f4a331117
BLAKE2b-256 checksum
How to use checksums
dfef962a0b7754c712a5d4750e591cdca94149a1b71d93ed787b5649c73f2436
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Release files / cargo_zigbuild-0.16.1-py3-none-win_amd64.whl

Download URL cargo_zigbuild-0.16.1-py3-none-win_amd64.whl
Size 900.4 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
a5f77b429dcee8d8def6e428fcdf24bd073e7bdb05e085c331b1675d7befe580
BLAKE2b-256 checksum
How to use checksums
8b5decb5eccaef3b07113b33621e0cd285065ba3a477e0d06daaaade03c27092
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Release files / cargo_zigbuild-0.16.1-py3-none-win32.whl

Download URL cargo_zigbuild-0.16.1-py3-none-win32.whl
Size 839.6 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
e6727ac699e1d6e3bbdb7f8348c77da90c23d1816a0c07b7d2171569a7c59cb9
BLAKE2b-256 checksum
How to use checksums
e89996f080f224119a1053dba1c4681eba0651162f0996ee3b38c8bf8887ca20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Release files / cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 883.3 kB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
b48380f79623f41efb019edc332aab0705dd4056ee5b17935e92421a02ac5375
BLAKE2b-256 checksum
How to use checksums
6135cbffd50e6dce9b8529649a3b428ef8fc800b08b9f854689b460a669961af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Release files / cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL cargo_zigbuild-0.16.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 930.5 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
cf7852b921f0d689b749561112c976d88088a82770c5ead9b196e75f8ea7e593
BLAKE2b-256 checksum
How to use checksums
6525062d5e5b1108abe3b7c8182d5ea3cf256e6a1dff0926277a3d0eb2347d1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Release files / cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.0 MB
Tags Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
43ef5b698328b5b898d77e3faef8c10bb0125572b1f1864fccedb9c8e3f25d1f
BLAKE2b-256 checksum
How to use checksums
ef8feb41e72f7e47d426a7fefed1e7a41fef0b3707c10bb81b4b3c338d8e15e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Release files / cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl

Download URL cargo_zigbuild-0.16.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Size 1.0 MB
Tags Linux glibc 2.5+ x86-32 Python 3
SHA-256 checksum
How to use checksums
1d7cb888370104480d61bdf2645bb9003514eba8ef5203b74de27b05d845cb10
BLAKE2b-256 checksum
How to use checksums
cebe3f09e35fdb7f2a86a9e349872ae9c3640b0e1eed63134f209a09dfd5d847
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Release files / cargo_zigbuild-0.16.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl

Download URL cargo_zigbuild-0.16.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 1.9 MB
Tags Python 3 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
43ec0165f22eb0e8262ab6b26f32fbc56d39e4a30cdc24a32ec9d05c80c2c08a
BLAKE2b-256 checksum
How to use checksums
77999a618ac455115d3d3676ada597c97c6d6d2e5248ec9878f841ec942fa007
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.14.14

Security for cargo-zigbuild 0.16.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.16.1 This release

8 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page