GitHub Action
ZigCC
v1.0.1
Latest version
Util scripts aimed at simplifying the use of zig cc
for compiling C, C++, Rust, and Go programs.
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 cc
throw errors, hopefully this will make compile successfully, WIP.
pip3 install -U zigcc
This will install three executables:
zigcc
, used forCC
zigcxx
, used forCXX
zigcargo
can used to replacecargo
, it will automatically setCC
CARGO_TARGET_<triple>_LINKER
tozigcc
CXX
tozigcxx
Adding a step to your workflow like this:
- name: Install zigcc
uses: jiacai2050/zigcc@v1
with:
zig-version: master
Then you can invoke zigcc
zigcxx
zigcargo
in following steps.
There some are env variable to config zigcc:
ZIGCC_FLAGS
, space separated flags, pass to zig cc.ZIGCC_ENABLE_SANITIZE
By default Zig will pass-fsanitize=undefined -fsanitize-trap=undefined
to 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
1
to re-enable it.ZIGCC_BLACKLIST_FLAGS
, space separated flags, used to filter flagszig cc
don’t support, such as-Wl,-dylib
otherwise you could see errors belownote: error: unsupported linker arg: -dylib
ZIGCC_VERBOSE
Set to1
enable verbose logs.