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

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

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.11.2-py3-none-win_amd64.whl (619.0 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.11.2-py3-none-win32.whl (586.8 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.11.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (666.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.11.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (691.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.11.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (741.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.11.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (777.8 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.11.2-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.11.2-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 019c4d9ab31453c3ce871d192daf8aee87151617d767c9e5b51d1dc579bab5da
MD5 2e28f7d65b9df93400bac0273a2f8d34
BLAKE2b-256 0cd8dc0411254f16aa9aa6aef16149b8fcdd19f8808bd29cc545db7e68aaa6e6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 4c7a36364d383080f8495341be45da6740c004fb808803f9e140f65c60e3c184
MD5 5490de2b65f565b3b5f1512e66daa7cb
BLAKE2b-256 96cd8f68dbfb7dd769542c47849050a746513757835a7572eceebf1d4e95352d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 7195bd4de1709b25e0efe8be95c2d433a4f6bd1123fdc437f64bd740810fbcf7
MD5 4e7d858d3f7738ed79f56896ff106bdb
BLAKE2b-256 79fac64d5676bc01a0ff36f0041ebe388e0d5d82f8a4b4f305ddf9b653c75fc0

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 718a2f26dc1b932cea03f1d7378318c542ebda5cf484b1cd83fbd04f3486db41
MD5 99e70c7491fb239e0ce6e71794cc4851
BLAKE2b-256 58bac02d1c1b7999fbde759666873c150ab29a58c547baaddd730bd302a1a104

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2f087bca6520f50ff2eff1c7785c66bf1e43749bfd52aa6b91edf075fad2c9a7
MD5 eb3a4e3d2354474db23605c503026b6b
BLAKE2b-256 57c755834ecfd97be1cd756ab974b27ac9357deb3841c86db5bc30e3677a6b1d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 515aa29c3267a2adab236dff0e2c70cedcad2f3ef3fdcaac4059fc03dac0ac32
MD5 466f8b447ada540b86009177aac6460e
BLAKE2b-256 cefd6395fc50fc1979adb007f8277fcd4836fbdc0b4979b550074587b03b925f

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4c473066eb17c9b76b9cf71c275744548a4f810144bd6547386c09a067d8ae41
MD5 e925597ae361d72ff37e83f962626352
BLAKE2b-256 0d77754e600589db1c08812f49a3d001771f7ce5e7be049dc0cba25421274b3a

See more details on using hashes here.

Provenance

File details

Details for the file cargo_zigbuild-0.11.2-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.11.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 9cdecca8a00e7f3d2c44379797f3551be27e86a9772045314b8d20b0146258a1
MD5 7d445bb0a374d9abf53c60a32d1f2b3f
BLAKE2b-256 0babda4c3471c9812b7e3da411a89fd681c6521f50d924658b41ec1a6e4a60bf

See more details on using hashes here.

Provenance

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