Skip to main content

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:

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.

Install

pip3 install -U zigcc

This will install three executables:

  • zigcc, used for CC
  • zigcxx, used for CXX
  • zigcargo can used to replace cargo, it will automatically set
    • CC CARGO_TARGET_<triple>_LINKER to zigcc
    • CXX to zigcxx

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_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 flags zig cc don't support, such as -Wl,-dylib otherwise you could see errors below

    note: error: unsupported linker arg: -dylib
    
  • ZIGCC_VERBOSE Set to 1 enable 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)

Source distribution for zigcc 1.1.0
File Size Uploaded
zigcc-1.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zigcc 1.1.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page