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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.11.1-py3-none-win_amd64.whl (608.4 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.11.1-py3-none-win32.whl (579.3 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.11.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (653.6 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.11.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (677.5 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.11.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (728.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.11.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (763.7 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.11.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.11.1-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 6fcb9a4117166caee2cc3e2158e9e6c38737b1a5cc5a32d375a30f480af40414
MD5 98afc933c85ee0c41d4be5aa17ff75f9
BLAKE2b-256 a0d41dfc449285b7b30a4d243a1a951521e0b7c3e68f6dbb311b5241ef0d9757

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3edef65f27343c338f0a466b3cef6f5ad6cb545a228659a274b968d5228b0d80
MD5 ee788afe2d65f4a8811f7e4cf8bfd02f
BLAKE2b-256 456b9593e59d565c16ba48f0be1294fe8c7a48a224b113bf61b0cf5ca26fa06f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 633a3af49218edd65a20b44ea6ec61dfb22fa212c6a41fdd7bfe64498ebbc013
MD5 bf79547636b6561147bfdbd53ff18904
BLAKE2b-256 ae102d4e55e393f70fd4a6816e2d688fdfd06455f74886334dda707077a99122

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8f5685bdb5363f31fcfd35662c87c3527b95adada49f6a6681c33942bd003ac3
MD5 1172fba9b1b3ba913ea66119779597c3
BLAKE2b-256 9d3ac81d476795f3a83b5e69d61c785540997da85402c6e1742a4491a1343e9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4d2e243e2e0129f2091bc1074854f6454e2d9e2635c5d5c7203b9fc4a2dbb199
MD5 ae2e95e276f67d6e0f6bf2c7418e4b85
BLAKE2b-256 431460063a728fab3b4cf681538ed3026214abb5bb5ae212365602e6696d2a35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 16176eae1fa3dd4996b7551478d662248625c8aa66e61921c8aee58272a27d6c
MD5 4790fd698e8608470e7e7537d8bd708c
BLAKE2b-256 6091258c2c52b5f4d136438cb5c2820b1d1d5ad8e328c75f14ccd3ec27f44be3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.11.1-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ae39021c960ae21a38920c0fe9ecb983c9d6bd5c7dde8e4a9f9b22adc8a5eb0f
MD5 8c5e521271719420f1b36fad31356dba
BLAKE2b-256 7829442a9b4c2992b8c752509730f8bd79c79083a87a1acf3ebb58c2ff59bd9d

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.11.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.11.1-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c17a2a6693a2ec608ff9ec681006d5d6600151902d284289277a3b2e87b329da
MD5 b8806b167f39fd9bb638f361b62a4039
BLAKE2b-256 b9e8fb331da0fbf0eed18f0ca9d344e374058af8aa6b7e3d8e8355a0e9ddd40d

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