Skip to content

proposal: x/build: add a CI runner with CC="zig cc" for linux/amd64 #59666

Description

@motiejus

Short Summary

Add a CI worker that runs Go's unit tests with CC="zig cc" on linux/amd64.

About zig cc

On Linux, zig cc is a wrapper on top of LLVM and LLD. Main benefits compared to other popular compilers:

  • Cross-compilation out of the box via a command-line flag.
  • Can dynamically link to a specified glibc version via a command-line flag (i.e. it generates a libc.so.6 on the fly before linking, no need to ship one).

For example:

CC="zig cc -target aarch64-linux-gnu.2.17" go build .

Will (cross-)compile the current package for linux/arm64 and link to glibc 2.17. Read this to learn more about zig cc.

Zig also has it's own Mach-O linker, making it possible to cross-compile to OS X. This is not in scope for this proposal, but may be considered as a next step. cc @kubkon who expressed interest in this.

Logistics

Initial changes:

  1. Add a linux/amd64 worker that lack any C/C++ compiler (i.e. make sure gcc/ld are not installed).
  2. Install zig v0.11 (to be released in May) to the worker.
  3. Run all Golang's unit tests with CC="zig cc".

Upkeep:

  1. The CI worker will have ReleaseSafe+Debug build, so, in case Zig crashes or trips an assertion, there will be decent information about the crash right in the logs. Refs Proposal: change nightlies from ReleaseFast to ReleaseSafe+debug ziglang/zig#15194.
  2. The worker should have Zig upgraded when a new Zig version is released. This can be coordinated by Uber's Go team (cc @linzhp @sywhang) or Zig folks (cc @kubkon @andrewrk).

Why is this important?

As of writing a few companies are known to use zig cc to compile C/C++ (via this toolchain) and bundle it with Go code. My employer Uber uses zig cc to compile+link it's Go Monorepo for linux/amd64 and linux/arm64. During the last 4 months that we have been using zig cc in production (which included an upgrade to Go 1.20) we have encountered some issues in a released Go version that would have been caught in dev versions should zig cc worker be present:

Since Go unit tests is a decent "integration" test, we believe it is a worth-while exercise to have this in CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions