Skip to content

Add CI for Zig compiler support#3142

Open
justsmth wants to merge 4 commits intoaws:mainfrom
justsmth:zig-support
Open

Add CI for Zig compiler support#3142
justsmth wants to merge 4 commits intoaws:mainfrom
justsmth:zig-support

Conversation

@justsmth
Copy link
Copy Markdown
Contributor

@justsmth justsmth commented Apr 7, 2026

Description of changes:

Adds CI to build and test AWS-LC using the Zig compiler toolchain (zig cc / zig c++). The Zig compiler is Clang-based and is increasingly popular for cross-compilation and as an alternative C/C++ toolchain. This PR validates that AWS-LC builds and passes tests when compiled with Zig across five platform configurations:

Runner Arch OS
ubuntu-latest x86_64 Linux
ubuntu-24.04-arm aarch64 Linux
windows-latest x86_64 Windows
windows-11-arm aarch64 Windows
macos-latest aarch64 Darwin

Zig doesn't accept a few GCC/Clang flags that our build emits, so this PR includes thin wrapper scripts (util/zig-cc, util/zig-c++) that translate them before forwarding to zig cc/zig c++. The Windows variants (.cmd) are shims that call the bash scripts through Git Bash.

Call-outs:

There are three platform-specific workarounds, all documented inline:

  1. macOS linking: Zig's self-hosted MachO linker segfaults (ziglang/zig#25451, ziglang/zig#23704), so the toolchain falls back to the system compiler (/usr/bin/cc) for linking only. Zig still handles all compilation.

  2. Windows SSL_peek tests: The Peek-*-Server SSL runner tests hang when bssl_shim is compiled with Zig. These are disabled via a shim config file (zig_windows_config.json). A small CMake change plumbs the -DSSL_RUNNER_SHIM_CONFIG option through to the runner's -shim-config flag.

  3. Windows SEH unwind tests: Zig's LLD linker produces .pdata/.xdata (SEH unwind metadata) that is incompatible with the RtlVirtualUnwind-based unwind tester, causing STATUS_ACCESS_VIOLATION in ABITest.SanityCheck. The non-unwind ABI register-preservation tests pass fine — only the single-step unwind verification crashes. A -no-unwind-tests flag was added to all_tests.go (following the existing SDE pattern) and is used for the Windows Zig targets.

Testing:

CI across the five matrix configurations listed above. All tests pass.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

justsmth added 3 commits April 7, 2026 10:58
Zig's LLD linker produces .pdata/.xdata (SEH unwind data) that is
incompatible with the RtlVirtualUnwind-based unwind tester, causing
STATUS_ACCESS_VIOLATION (0xc0000005) in ABITest.SanityCheck.

Add a -no-unwind-tests flag to all_tests.go and use it for the Zig
Windows CI targets. This follows the same pattern used for SDE builds.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.97%. Comparing base (9ce727c) to head (6e94f28).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3142      +/-   ##
==========================================
+ Coverage   77.96%   77.97%   +0.01%     
==========================================
  Files         689      689              
  Lines      122536   122537       +1     
  Branches    17071    17070       -1     
==========================================
+ Hits        95535    95550      +15     
+ Misses      26104    26090      -14     
  Partials      897      897              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@justsmth justsmth requested review from WillChilds-Klein, geedo0 and nhatnghiho and removed request for WillChilds-Klein April 8, 2026 14:18
shell: bash
run: |
cat <<EOF > ./toolchain.cmake
set(CMAKE_C_COMPILER ${ZIGCC})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why these didn't go into CMakeLists.txt or a toolchain.${target_system}.cmake with a flag to enable them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants