Skip to main content

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:

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 for CC{.verbatim}
  • zigcxx{.verbatim}, used for CXX{.verbatim}
  • zigcargo{.verbatim} can used to replace cargo{.verbatim}, it will automatically set
    • CC{.verbatim} CARGO_TARGET_<triple>_LINKER{.verbatim} to zigcc{.verbatim}
    • CXX{.verbatim} to zigcxx{.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 flags zig 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 to 1{.verbatim} enable verbose logs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zigcc-0.1.0.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distribution

zigcc-0.1.0-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

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