Compile Cargo project with zig as linker
Project description
cargo-zigbuild
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
Usage
- Install zig following the official documentation,
on macOS, Windows and Linux you can also install zig from PyPI via
pip3 install ziglang
- Install Rust target via rustup, for example,
rustup target add aarch64-unknown-linux-gnu
- 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
- 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.
- If the
--target
argument is the same as the host target, for example when compiling from Linux x86_64 to Linux x86_64, Cargo by default also uses zig as linker for build dependencies like build scripts and proc-macros which might not work (See #4). You need to use the nightly Rust compiler then cargo-zigbuild will enable the unstabletarget-applies-to-host
option automatically to make it work out of the box. - Only current Rust stable and nightly versions are regularly tested on CI, other versions may not work.
Known upstream zig issues:
- zig cc: parse
-target
and-mcpu
/-march
/-mtune
flags according to clang: Some Rust targets aren't recognized byzig cc
, for examplearmv7-unknown-linux-gnueabihf
- 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
Built Distributions
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-win_arm64.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-win_arm64.whl
- Upload date:
- Size: 548.8 kB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1caa0c46048ee4cb2d795333e06970e190a1e8530160438c2b987ce071765b6 |
|
MD5 | 17a6cdcfd7f5ba990ba7a4b02a3216db |
|
BLAKE2b-256 | 616a859ffe1449676e7219d1bf8d4514118eb433fcd88f7a2e585a95c0378b7b |
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-win_amd64.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-win_amd64.whl
- Upload date:
- Size: 565.1 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d2fb9ee8c872cc14093213ab4c6df3028bc79643b115917e078597f80e81aca |
|
MD5 | 11cc0381608a46149bb64ba4e96dcd60 |
|
BLAKE2b-256 | 91f56a6fc5702959349f78ce0821759624063fe0c3e87aff3c6c911953df2b22 |
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-win32.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-win32.whl
- Upload date:
- Size: 535.4 kB
- Tags: Python 3, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3b73a262c1092c8e130dba666f40a55a20a04ec274d9bb5e6d2d4c24d346d05 |
|
MD5 | 50a00eb83232b100861dc088d470740b |
|
BLAKE2b-256 | 3c9e4046694d2f400466a56fa9e96a5624a7fed4a0c48c63d94e56cfa2f40516 |
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 608.3 kB
- Tags: Python 3, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d7b925b65af0d85250142d3a59f642d0284d936c7cf3fad276abce0b34334a0 |
|
MD5 | 60dca2dfdebb828999396f4cb7c8780b |
|
BLAKE2b-256 | 58b006ca57ecbe80e9b46d3fff4ee26eab49b725c35075893d65d46e96292347 |
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 614.4 kB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb83ec316218d271badecd3377e2f5b49854ba5a45dd522d48a632a30a30f72b |
|
MD5 | aad7cc3ab63ca7e2a19d87bb88f0317d |
|
BLAKE2b-256 | ad062cfdcb00257d62d1755488f4818a9013ae2ad35efa71fce8fad2df6751e2 |
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 669.0 kB
- Tags: Python 3, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 885c2db58c625401b4e0af533b3d17afe73b16f339f5ce32baa0af64b260431e |
|
MD5 | b0981d5fac112811563c0b5d5cff591e |
|
BLAKE2b-256 | 87749599aebfc038b194a82721ad3ae22275b14db967f094b9e3a37d44f50cdc |
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 701.7 kB
- Tags: Python 3, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6165573b8bca68ee785f2ef3bf1a6c96face52c79a5c8299de35684993efee1a |
|
MD5 | baeadc3e482eceacc05a110dcb891ee2 |
|
BLAKE2b-256 | 168e1dc82ef6c6f1654b219f9f9f9a3b583cf27f2f933709b4cfaa6f5c82a16f |
File details
Details for the file cargo_zigbuild-0.8.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: cargo_zigbuild-0.8.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.12.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f70b4379a4e5206d9d163bdbddb80fb30d58bbb068e038ca0a51e62e03ef209a |
|
MD5 | c0da30055e0aaa83786f4306b9b150d8 |
|
BLAKE2b-256 | 448c75b57453e4cf77125832f95790f09191c54811fb4ebaaee75125bb6917a0 |