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. 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
  3. zig misses some compiler_rt functions that may lead to undefined symbol error for certain targets. See also: zig compiler-rt status.
  4. CPU features are not passed to clang

License

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

Release files for cargo-zigbuild 0.17.5

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.17.5
File
cargo_zigbuild-0.17.5-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
cargo_zigbuild-0.17.5-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
cargo_zigbuild-0.17.5-py3-none-win32.whl Python 3 none Windows x86-32 Details
cargo_zigbuild-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details
cargo_zigbuild-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
cargo_zigbuild-0.17.5-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64 Details
cargo_zigbuild-0.17.5-py3-none-manylinux_2_5_i686.manylinux1_i686.whl Python 3 none Linux glibc 2.5+ x86-32 Details
cargo_zigbuild-0.17.5-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl Python 3 none macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64 Details

Total release size: 8.7 MB

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

Download URL cargo_zigbuild-0.17.5-py3-none-win_arm64.whl
Size 865.4 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
3fe1004715c74d231775f6e4a4d94555282f88e2ff67c5ae9a4b4c6072636025
BLAKE2b-256 checksum
How to use checksums
c0d0e3b217ac6e519b8fa2d0bad351172ed9e714770927bcb97e9c2e3a091665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

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

Download URL cargo_zigbuild-0.17.5-py3-none-win_amd64.whl
Size 907.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
6700ceb27b53e3cee0f19a41275db367a98ee31d18da2a56ea77fe72d3639451
BLAKE2b-256 checksum
How to use checksums
6c963676793f160b961d794eeb1fb9e2eae47c37ce1a09f15fd083251b98c10c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

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

Download URL cargo_zigbuild-0.17.5-py3-none-win32.whl
Size 847.4 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
7393d3d1e2bf30346d5f791968473a350cad8030727709aca19f8c8cb97f0319
BLAKE2b-256 checksum
How to use checksums
2775f0523085fd614dc9fc01e78c0233ca4ebaad91f35139d44b485baafcb780
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

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

Download URL cargo_zigbuild-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 933.0 kB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
52f994f4cdcecfc7a81a5b0a72da0fd0c85875e2815cec2e715012505f3e013a
BLAKE2b-256 checksum
How to use checksums
314372b9f4ec4c4cfc08e2bbf494ac576d9f2bc7b70ca9248744f331f267a134
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

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

Download URL cargo_zigbuild-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 979.7 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
10ce351dd4ef26fa10cf25e08d2e18385841867b06120151afc2447916e6bbc0
BLAKE2b-256 checksum
How to use checksums
3cdb0929b9710002c9361494b9099380a1d59c3194dc90ea0ebfbe1b307381a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

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

Download URL cargo_zigbuild-0.17.5-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 1.1 MB
Tags Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
cd39ae96f9daa559f7719bc944dd78ba213a78e2b7e3c5a956b1284a6eae9831
BLAKE2b-256 checksum
How to use checksums
622e4f4eb82aebbc5d3f9b78ca8fafb55996b17d77f928a5a0bb6fd10ea8d556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

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

Download URL cargo_zigbuild-0.17.5-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Size 1.1 MB
Tags Linux glibc 2.5+ x86-32 Python 3
SHA-256 checksum
How to use checksums
0d64de0d905b3f4ca2e4b2ec15fc12ed6827eb4d4bcc0e5f1b3adab9d10ef4f2
BLAKE2b-256 checksum
How to use checksums
cad10e7b3fec78c73d0282b3590ffc5f195b35bd2bb9db2fbf5c799fbcdd34b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

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

Download URL cargo_zigbuild-0.17.5-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Size 2.0 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
59581f9577b42567bc131cde5fa5cf3722e8a6a6dc142aa52af6758144194146
BLAKE2b-256 checksum
How to use checksums
2ab4298a33e2801887bbfaedfc2c3dad4d449ed1424dd1c1b2c424d2915c42eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

Release history Release notifications | RSS feed

0.23.3

8 release files

0.23.2

2 release files

0.23.1

8 release files

0.23.0

8 release files

0.22.3

7 release files

0.22.2

8 release files

0.22.1

8 release files

0.22.0

8 release files

0.21.8

8 release files

0.21.7

8 release files

0.21.5

8 release files

0.21.4

8 release files

0.21.3

8 release files

0.21.2

8 release files

0.21.1

8 release files

0.21.0

2 release files

0.20.1

8 release files

0.20.0

8 release files

0.19.7

8 release files

0.19.6

8 release files

0.19.5

8 release files

0.19.4

8 release files

0.19.3

8 release files

0.19.2

8 release files

0.19.0

8 release files

0.18.4

8 release files

0.18.3

8 release files

0.18.2

8 release files

0.18.0

8 release files

This release

0.17.5 This release

8 release files

0.17.4

8 release files

0.17.3

8 release files

0.17.2

8 release files

0.17.1

8 release files

0.17.0

8 release files

0.16.9

8 release files

0.16.8

8 release files

0.16.7

8 release files

0.16.5

8 release files

0.16.4

8 release files

0.16.3

8 release files

0.16.2

8 release files

0.16.1

8 release files

0.16.0

8 release files

0.15.0

8 release files

0.14.5

8 release files

0.14.4

8 release files

0.14.3

8 release files

0.14.2

8 release files

0.14.0

8 release files

0.12.3

8 release files

0.12.2

8 release files

0.12.1

8 release files

0.11.3

8 release files

0.11.2

8 release files

0.11.0

8 release files

0.10.3

8 release files

0.10.2

8 release files

0.10.1

8 release files

0.9.0

8 release files

0.8.8

8 release files

0.8.7

8 release files

0.8.6

8 release files

0.8.5

8 release files

0.8.4

8 release files

0.8.3

8 release files

0.8.2

8 release files

0.8.1

8 release files

0.8.0

8 release files

0.7.2

8 release files

0.7.1

8 release files

0.7.0

8 release files

0.6.8

8 release files

0.6.7

8 release files

0.6.6

8 release files

0.6.5

8 release files

0.6.4

8 release files

0.6.3

8 release files

0.6.2

8 release files

0.6.1

8 release files

0.6.0

8 release files

0.5.5

9 release files

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