A util script that aims to ease use `zig cc` to compile C/C++/Rust/Go programs.
Project description
zigcc
https://img.shields.io/pypi/v/zigcc
A util script that aims to ease use zig cc
{.verbatim} to compile
C/C++/Rust/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 cc
{.verbatim} throw errors, hopefully this will make compile successfully, WIP.
Install
pip install -U zigcc
This will install three executables:
zigcc
{.verbatim}, used forCC
{.verbatim}zigcxx
{.verbatim}, used forCXX
{.verbatim}zigcargo
{.verbatim} can used to replacecargo
{.verbatim}, it will automatically setCC
{.verbatim}CARGO_TARGET_<triple>_LINKER
{.verbatim} tozigcc
{.verbatim}CXX
{.verbatim} tozigcxx
{.verbatim}
Use in GitHub Action
Adding a step to your workflow like this:
- uses: jiacai2050/zigcc@main
with:
zig-version: master
Then you can invoke zigcc
{.verbatim} zigcxx
{.verbatim}
zigcargo
{.verbatim} in following steps.
Config
There some are env variable to config zigcc:
-
ZIGCC_FLAGS
{.verbatim}, space separated flags, pass to zig cc. An example is set this to-fno-sanitize=undefined
{.verbatim} to disable sanitize since they may break your programs. See Catching undefined behavior with zig cc -
ZIGCC_BLACKLIST_FLAGS
{.verbatim}, space separated flags, used to filter flagszig cc
{.verbatim} don't support, such as-Wl,-dylib
{.verbatim} otherwise you could see errors below= note: error: unsupported linker arg: -dylib
-
ZIGCC_VERBOSE
{.verbatim} Set to1
{.verbatim} enable verbose logs.
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.