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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.13.0-py3-none-win_amd64.whl (649.3 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.13.0-py3-none-win32.whl (617.1 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.13.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (678.0 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.13.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (702.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.13.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (757.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.13.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (793.9 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.13.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (1.4 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.13.0-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.13.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 44bc7c5e527f8f83f6ace906e536c432d25f05862739f84aa8074329364b4d74
MD5 7afef5853a05048d4d11d0cd3ec4d869
BLAKE2b-256 b82213992d3899620924391fb7e96558ec7ced609d77065f8459f5672bc2d0d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.13.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6d5af0367cae43a956d3942b1cf5e74bfecddf849e3afedf21df804c0d4dfe89
MD5 719e9beded3f725a14d6524f4293c472
BLAKE2b-256 8e316db3792c3ea46a3a4b0bf3ff41bad55513840a049d8524c6f92b7786393e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.13.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 12c3f3f25a58527343700c1e4e2b6bee68f6070f3befac607028c67c3e603b22
MD5 aa7127860edb0d8422d638f9ee66cfc9
BLAKE2b-256 44f582eb288192da446d66d10a3951338f4bf76f429da4ce220b4a5b08387564

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.13.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 af71c69ff7307213f707afbcf5e77f5520bcda99f0c0f9cf44e14ccd4cb0b2fa
MD5 a38a13ebde9b82fed21c4722656dba54
BLAKE2b-256 c83c707b5b4f58ec18b3710f91582b28e8cb35384a6a4192d282cd4e3f522c88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.13.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e2d3a340de70dff583e57fb5feb6d47c429c58f636b126424c4a44f25752439d
MD5 a16a32f38dd4d062380710ea4c774621
BLAKE2b-256 e5e4513f83d7996a446efd39145ed05708b91ba2996c3ce1d5cf2e072d744469

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.13.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 faaf58a8f2365840239585a30bc49a74381de1f561cdac8cece16ff2a5570fbf
MD5 bc1bdbf54dbb1260a6788f55694cfbf9
BLAKE2b-256 5afe831fe8286ccaf604a0cc7aa1dd7b4c192b25d8fa8910aceab2d65a38aba4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.13.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 4e091776c0dd5c246f14d113cebd04c3d40c2b23660a3eb7a604315b4973cfc4
MD5 10675fcc874326a1330c486fc1872775
BLAKE2b-256 f382a56edf2a2924247c3ee0d708d6f9cde28965251d8753313fb49040ee4542

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.13.0-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.13.0-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3405b1b9e8700cce008e65148fed457e30edc9abbce7f26111ee5130ccaf75c4
MD5 6864f8826a4b19dec0aa8a311b850982
BLAKE2b-256 7780d4f7ab46179ed608694dba781123f48daad56ef6c21ba701c4c42daf31d4

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