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.10.2_beta.1-py3-none-win_arm64.whl (574.6 kB view details)

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.10.2_beta.1-py3-none-win_amd64.whl (599.6 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.10.2_beta.1-py3-none-win32.whl (571.7 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (655.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (677.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (729.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (767.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.10.2_beta.1-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.10.2_beta.1-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2_beta.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 91d6a976b21b35e958790548bf1c5f015b6492a38e94ca191b0d80c66a374ab1
MD5 b8b48513f2b5292b3f22edb6f6462c0a
BLAKE2b-256 109037d41807061010348646737e59c0f286757024eaa3ca2aff3b48232bceac

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.2_beta.1-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2_beta.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6bed112f5ef61e7c51010fcee6c410d805af6038a870de8d9566750cc243b5e4
MD5 f98ddb90393ad9c5474920858fe8cc37
BLAKE2b-256 f57c63f557fd63a44f431ffc451586133667185d0f261720a37b9db9bc2e7c49

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.2_beta.1-py3-none-win32.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2_beta.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 98861b7097b0839bcd246c428d52dfbe098072d009c51447ff07807581bf3b58
MD5 af9aaaf07b04c58fa23f5abe88b3b35c
BLAKE2b-256 dd5bba05ae0f6359207ea1e5b13fc385d6c6f9f3a93b42e72847f89823d9d7c6

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 c7b4b077807b48a83c99196916a1916f2625f9e6e65a6a00b62b5ee6e10ba424
MD5 892a218d56902e0583204d7a68a8323a
BLAKE2b-256 3161387be1a88cae7bc55dc4bda6133d29aaf97653284b50a53ff3a2611c8a2c

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b57727d0800b39aa167edbfcd732a212cb2cf440b32d20a7546ea0f069f8ee45
MD5 d055a77175f1913b9ae505a3567aa038
BLAKE2b-256 96a4c4e3580db8ef0229f197a31699f9b0da4aa3a5fbb9694c1f3fc57e4b7990

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c65b62ea98103c5a2a9d9a01c74639f221e1f7dbdd2e987a1ffa602c41673ff7
MD5 8edeafd5a75a82eb21d509605e9925db
BLAKE2b-256 2e780b7dd9fc6be05772102a2e7dffea19a64c240a640246fe17bd6324f59cd3

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.10.2_beta.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 1519cd04d8105e91dcfdc3e2b3115de042ccff91b4657cc8129694e3008c4023
MD5 0a165c3cc415036b978f616c655425f2
BLAKE2b-256 43b34def0ce536d33418dc6e267ff5aa8737b4b2ff1cfe361ad79ab57605359a

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.10.2_beta.1-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.10.2_beta.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 005475af11d6d9793d877556473cd25b6eaca334f9171cfdcb32e7efca9a9353
MD5 80aa2b297da8fc49f3ec7ade52b9ea1e
BLAKE2b-256 250287643a978d382b44618ef764284fdf842d48228846b0f022d791d6d86aab

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