Skip to main content

Compile Cargo project with zig as linker

Project description

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

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.12.3-py3-none-win_amd64.whl (638.8 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.12.3-py3-none-win32.whl (604.3 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.12.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (667.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.12.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (692.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.12.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (745.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.12.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (781.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.12.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.3 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.12.3-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 0d9cd21135081fe8631a8f452e663d2723edf723acc251d5af8f721198738248
MD5 fa29111c84ca54c240349e5f6581ec82
BLAKE2b-256 0d4ad86767f0dea2dd8d4e4d2453330fdc4a95663d40dc0006ec5d3e7e255524

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4faf1b8200e89280e7d287bfe8aebf0316817e8479dff2b2fe717493b82704e5
MD5 0525e13f2c88b2802e0fdeaf02b9c446
BLAKE2b-256 c77d216b5a39e8ebf9a601faa12436b6dfadb179c8602d172c0b5596b4c625ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 3715acb4a18b634301234f770ff82b2fee307de054d577ebe6e65f973359591e
MD5 7be37f8661b9c3028f4a906402799532
BLAKE2b-256 9b5a912fc2dd78d4712077613df0955d40a876b81da852241bd663bc208d842e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 f7132c3129c13063202d3f275889aa9b8e7643141663cf212b18b2954756b39b
MD5 97338017eff7ba62df11f318e4854421
BLAKE2b-256 6a1bcca0e705fc8e028a8cc09a4c0490d317ebb1070960a115faa121898537fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f1eb0449f89647cdf059b1b6b9f078d64028a66cc0009a1196b535aedac18043
MD5 b115ed65ea16893e1305e12a3fc78798
BLAKE2b-256 cd2a1c0a7334c5f40a22128679d07057a25cb1244a65f01c58e45c92601aa321

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9666b76e5d41ddd6e137f5cdd12fcb51e8b97816926e077f33a4c7f79a351c27
MD5 1bc89823c3b42b2a9c1d2dde4b1c06cb
BLAKE2b-256 aeccbb4c2ae3d16e83781b38d7649f474f5b070e2c82e42a514ba43690157b22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.12.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 1827ba7081400e69d8229030af31b76fd477f812ca715dbbdcf3d252981707df
MD5 40159753db09f8142e32907bee07e636
BLAKE2b-256 b2f76e1163843df5c3138226a82b32992af22a2ad96ef972853b367ed228c984

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.12.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.12.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 63815e15ac8bfa69e3ac5de8912a4e385227a0f56724335660e46b094d03a2ec
MD5 bc86e5998b774fcd37ba3bc101e9706c
BLAKE2b-256 3736cc848b292dcca320808dcfae4f5bed15c22cfb7cc2c0ab213052e2693ab0

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