Skip to main content

Util scripts aimed at simplifying the use of `zig cc` for compiling C, C++, Rust, and Go programs.

Project description

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.

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-1.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zigcc-1.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file zigcc-1.1.0.tar.gz.

File metadata

  • Download URL: zigcc-1.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for zigcc-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a01791ff35dd0dac62ec378885d6e5a09dc0d28d87cb31b8a190dd893390bbe4
MD5 c7396b08fc2de2c70588355b0bf948fe
BLAKE2b-256 3775316c8fbcaa4c3cb995196edd3fab4f94750664aaafccacebb4c421b4888b

See more details on using hashes here.

File details

Details for the file zigcc-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: zigcc-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for zigcc-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2324230c36f995b92e14ab6ef1d78a9f08301bcb4fd1b5487455da44c28a01c
MD5 4af8279f3ef1a35fbfd19bcc52dab81e
BLAKE2b-256 9901a50937782c93864510a4b05bc4dbe84dbd3d266cc59249638e1f4da03f50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page