zigcc
Scripts aimed at simplifying the use of zig cc for
compiling C, C++, Rust, and Go programs.
Why
In most cases, we can use following command to use Zig for compile
CC='zig cc' CXX='zig c++' ...
However in real world, there are many issues this way, such as:
- zig cc: parse -target and -mcpu/-march/-mtune flags according to clang #4911
- Targets compare: Rust to Zig
- unsupported linker arg
- Rust + `zig cc` CRT conflict. : rust
So this project was born, it will
- Convert target between Zig and Rust/Go
- Ignore link args when
zig ccthrow errors, hopefully this will make compile successfully, WIP.
Install
pip3 install -U zigcc
This will install three executables:
zigcc, used forCCzigcxx, used forCXXzigcargocan used to replacecargo, it will automatically setCCCARGO_TARGET_<triple>_LINKERtozigccCXXtozigcxx
Use in GitHub Action
Adding a step to your workflow like this:
- name: Install zigcc
uses: jiacai2050/my-works@main
with:
zig-version: master
Then you can invoke zigcc zigcxx
zigcargo in following steps.
Config
There some are env variable to config zigcc:
-
ZIGCC_FLAGS, space separated flags, pass to zig cc. -
ZIGCC_ENABLE_SANITIZEBy default Zig will pass-fsanitize=undefined -fsanitize-trap=undefinedto clang when compile without-O2,-O3, this causes Undefined Behavior to cause an Illegal Instruction, see Catching undefined behavior with zig cc.So we disable it by default, set this variable to
1to re-enable it. -
ZIGCC_BLACKLIST_FLAGS, space separated flags, used to filter flagszig ccdon't support, such as-Wl,-dylibotherwise you could see errors belownote: error: unsupported linker arg: -dylib
-
ZIGCC_VERBOSESet to1enable verbose logs.
Metadata
Release files for zigcc 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zigcc-1.1.0.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zigcc-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / zigcc-1.1.0.tar.gz
| Download URL | zigcc-1.1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a01791ff35dd0dac62ec378885d6e5a09dc0d28d87cb31b8a190dd893390bbe4
|
|
BLAKE2b-256 checksum How to use checksums |
3775316c8fbcaa4c3cb995196edd3fab4f94750664aaafccacebb4c421b4888b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1
|
Release files / zigcc-1.1.0-py3-none-any.whl
| Download URL | zigcc-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2324230c36f995b92e14ab6ef1d78a9f08301bcb4fd1b5487455da44c28a01c
|
|
BLAKE2b-256 checksum How to use checksums |
9901a50937782c93864510a4b05bc4dbe84dbd3d266cc59249638e1f4da03f50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1
|