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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.14.5-py3-none-win_amd64.whl (692.7 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.14.5-py3-none-win32.whl (645.3 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.14.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (693.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.14.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (735.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.14.5-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (791.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.14.5-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (820.2 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.14.5-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.5 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.14.5-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.5-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 46e5e03c20ee4ddd69f69fbdd4da41fedb5862f087666467bb3d85b3d65332b5
MD5 3284d5314531f42103827167368e07fd
BLAKE2b-256 e62fa42ccee116a9139e68bdf396d6412cec341e6e29c94792b293e75a445024

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 78457c199aa454a6d0a0158518028638cd26f15260ca4ab286b3ec056c2f74ed
MD5 5253033e9c0805c68570ac73e87429c9
BLAKE2b-256 44a84e0befeecef5559be8e1cb87b789dba16c745a2af56d5e909ee49f02e0be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.5-py3-none-win32.whl
Algorithm Hash digest
SHA256 091b93fe3d8aa41e899cf82bed96230a0d701a8e3a3e30bb09ad677b9c0ee8fc
MD5 48364e9cc93f0c3528f2d4ddddf55d5f
BLAKE2b-256 3f10f3e6c9f20b71cb1e1ef4c32b5ee5db3f27a4e8926337f59df7b84b326c56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 1cc6b674303d463f0b1f65a062deb2ec22e6f0f6465100177926334c66ffb10e
MD5 c409f29cb895cc9f1bf7ee4f8693e7d0
BLAKE2b-256 8f075e71e511a6db36f018d5ba27f8c1ff0b52716cb8a82415c003c005698026

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 199a08f44382406b14aa016e81df931f17ccde68290282c0993ef00161b1c5fc
MD5 4df9203a054c1bfab07c93ccdb098e20
BLAKE2b-256 44b068a4d9b0d4733b27e89a858f7d8c487e5fed246d76f8ae2842400d64fb8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.5-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 225104224ce81ee632cd3768bc8a3ee6ec7b2b6d107122f33c8452bb2fa0b1af
MD5 d062c543deb99940fb46d316ac755e53
BLAKE2b-256 80ec1633106fe044ee1855b0a33747eed56fa41f166459f815b28dff010c00f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.5-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 d6f8d964daf4bfb6aa936c8e42928b4c965a829ee9b7baa4f18035d7bc173898
MD5 e412b3c33253ddaa32a765cf0af5b8c6
BLAKE2b-256 7773af9c306d4dfee6f855ab94b1df3833ddeb75bb0152853d39cd652fdb36a3

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.14.5-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.14.5-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 1625798d0dfe67e81a69d273896baad4f243f72a61aaaf41eece7cc800666316
MD5 f786a5d2f14ea656c5b87d5876368c65
BLAKE2b-256 b5ff158c188968ba42412646da0dbd91a2f52eb717b0435055230b3addfe849a

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