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
  3. zig cc does not define aarch64 outline atomics

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.14.3-py3-none-win_amd64.whl (691.9 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.14.3-py3-none-win32.whl (646.3 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.14.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (692.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.14.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (735.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.14.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (790.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.14.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (819.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.14.3-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.3-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 a3a51dc8234b387281c96a9182efe6431f21d679b9826d936e0454a80be749a1
MD5 2b1baf6ea95f836874b49f0a89ba09eb
BLAKE2b-256 d3d956b25859547980b9b64d7ec1770aecd00b00f4d419fae2f582cfddc14583

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 722c2e7315263f62de9e40dd322c19dcab5f80a178d4dd11aebd07fc50386549
MD5 99829ba3533128a2685b0c23dfb94e7e
BLAKE2b-256 fc7f14a3b7f44e8e1619c41605636c2106b5bfe65996e52fa2ff7bde5a8b6ab0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.3-py3-none-win32.whl
Algorithm Hash digest
SHA256 501e9aa94b450391d2a556e3daffcd92d6f2ef7864b6b9baf48f4c0d37bfd29b
MD5 34212c331bf7e42dfb39dac29f633b66
BLAKE2b-256 32136d674e0f3245cef1781498cfc4006d3e824a0af2ca765e919559af5cf3b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 85975cc7337e25daa7cea78cb641c731ca923fce5a77149ad79cf85435bbb84d
MD5 b6a6876d91d9098999bf7a2fd5c860f0
BLAKE2b-256 38fdac7ebf9707a93c3903edb42c80dff73efb98c9adebe0cda53e1527375821

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cd07c8ad1841ce3050874c690f38599ce1ecf1281ba2df00e7a97600a42e981d
MD5 276db3a20274c85b270b3ca1a259cd9b
BLAKE2b-256 90080f4ff02c90157dd6cf49966d81b58ce79666965db7a5fed82e0f7c733006

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b0ebd8e2a4c487ba5f924f6648145ed464f5d657308fca8bb8208b30d32c624a
MD5 8b067ba757c05a712e1068e5dcfba086
BLAKE2b-256 faaea14aa8d4db158b8d2458be5027247312960f4182aaba0e7131e514649dbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.3-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 357c264ea7e0d547dcd724b37268c24c5fc40898fecebb6148170c515a98ad11
MD5 e322e823cbc608f2a954fa35b4137554
BLAKE2b-256 0605049711ace56c331bc3c4549de4d3fe9eee7c1f294c8e190372f7fbd8c668

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.14.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.14.3-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 55afeab9805e3bb586e8272b447d52fbc1a01bf38c7cca5384665eb9f98f05fc
MD5 426333f141f4d7b8fcc92bc9ef24688b
BLAKE2b-256 984386b4d9a04aa00df8eebf07fdaf4f3024e2ae3dd4667f991ccd37d5aa2b63

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