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

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

Uploaded Python 3 Windows ARM64

cargo_zigbuild-0.14.4-py3-none-win_amd64.whl (687.6 kB view details)

Uploaded Python 3 Windows x86-64

cargo_zigbuild-0.14.4-py3-none-win32.whl (642.9 kB view details)

Uploaded Python 3 Windows x86

cargo_zigbuild-0.14.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (689.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

cargo_zigbuild-0.14.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (731.3 kB view details)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

cargo_zigbuild-0.14.4-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (784.4 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ x86-64

cargo_zigbuild-0.14.4-py3-none-manylinux_2_5_i686.manylinux1_i686.whl (815.1 kB view details)

Uploaded Python 3 manylinux: glibc 2.5+ i686

cargo_zigbuild-0.14.4-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.4-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.4-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 018e66e69a1727d1b1b1250cb9fba51f2520d4643c8c96999a90d9c65ad7bdd5
MD5 9139935044a17571e20b76c53deb2720
BLAKE2b-256 dddecf81e5887e1c91ffe6025d84136441d05f7cf1221da0dc00f8f8f1091332

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b858ff992c9c5f7494dc44e1dab556d80cd3eede7dbc78ca6c033d09eaabc9f0
MD5 1d9da6c8defa293b6e3247e6c5afbd99
BLAKE2b-256 7ac871f631d8ae32dd5af60a7505c5932edc78e5864444d591fb37068579c0c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.4-py3-none-win32.whl
Algorithm Hash digest
SHA256 a1b73b08736ff7735a49d5085fc0b6787dd95be5db6e4e031f635829955abe92
MD5 e324f4d4fdcb842eeb389b3fbcb91343
BLAKE2b-256 2b1ca4cc23c0942ce5c5dacbc1d10b60c2450e9b3f52cec5eadfa30f83bd4bbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 9af2a00333ece7eae464181b5ae9fca45deb14f19fb9ce0862ba662665bd90bc
MD5 1d97d48debefc5fdcbd946f5f8dda695
BLAKE2b-256 8dde100042af4f7fb5933cba2b13e28b28d751782ecd8285a3797209340f500d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c242762aae1ef8ff3b9d8b543503ed8af2546991916dae1c4949b23ac4b03362
MD5 d75ecfa92eed58c6a719557e820d7e23
BLAKE2b-256 a9c00900b522d790f2d45335d3b9a0caa43237af846ff1587245a0388888eb86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.4-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bcca63debe37d800fea0561647bf3467e0cfa6ac6d0660aa35f043797053f2c7
MD5 c83c0cc89689c213e40021bc49c0dc0a
BLAKE2b-256 1d6a4cf0be67d22238e41d43bc7c96076528be8f1bb4cd61e2eada5dd88f9c8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cargo_zigbuild-0.14.4-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 606db4ccfa165b261da45aad7c930c3fa01c0bb4b0886a3607a617cc99735692
MD5 380dbce0718765245c76676549ab838d
BLAKE2b-256 2de75ab995d48a6631f6f6fd585b79ee517836c9ea946883ff2d00775aa71cf2

See more details on using hashes here.

File details

Details for the file cargo_zigbuild-0.14.4-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.4-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 82029d21d789188960b4fa0b3500defb63835a24bcb2bd73b3ccfb0eaceacafc
MD5 b93fb20c71f66d671ff716e4482f08c4
BLAKE2b-256 c19bed1c7e1d3509d06ce1151872f2009fb8aff56dc9f70a604530679eeb0003

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