zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit ac0bb1eec55d8bda90cbc3114e91d3b0e9f12c8b (tree)
parent e3901a774afb6b97e583fd0c7ec77e80c1be6d23
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date:   Fri, 20 Feb 2026 07:22:20 +0000

verbose_air: enable emit_bin so exported functions produce AIR

With emit_bin=false, the compiler never queued functions for analysis,
making the verbose_air_callback a no-op — all corpus files produced 0
AIR functions on both C and Zig sides, so Stage 3 comparison was
vacuous.

Set emit_bin=true so that `export fn` and `@export` trigger function
analysis. Disable 5 compiler_rt corpus files that now expose the
Zig-vs-C mismatch (they use @export but C sema doesn't port zirFunc
yet). Add 3 skipped export-fn test tiers in sema_test.zig as targets
for incremental zirFunc porting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Diffstat:
Msrc/verbose_air.zig | 2+-
Mstage0/sema_test.zig | 18++++++++++++++++++
Mstage0/stages_test.zig | 10+++++-----
3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/verbose_air.zig b/src/verbose_air.zig @@ -168,7 +168,7 @@ fn zigCompileAirImpl( .output_mode = .Obj, .resolved_target = resolved_target, .have_zcu = true, - .emit_bin = false, + .emit_bin = true, .is_test = false, }); diff --git a/stage0/sema_test.zig b/stage0/sema_test.zig @@ -370,3 +370,21 @@ test "sema: Air raw C vs Zig comparison (empty)" { test "sema: Air raw C vs Zig comparison (const)" { try semaAirRawCheck("const x = 0;"); } + +// Tier 1-3: export fn tests — initially skipped until C sema ports zirFunc. +// Remove `return error.SkipZigTest;` as each tier is ported. + +test "sema air: empty void function" { + if (true) return error.SkipZigTest; + try semaAirRawCheck("export fn f() void {}"); +} + +test "sema air: return integer" { + if (true) return error.SkipZigTest; + try semaAirRawCheck("export fn f() u32 { return 42; }"); +} + +test "sema air: identity function" { + if (true) return error.SkipZigTest; + try semaAirRawCheck("export fn f(x: u32) u32 { return x; }"); +} diff --git a/stage0/stages_test.zig b/stage0/stages_test.zig @@ -97,11 +97,11 @@ const corpus_files = .{ "../lib/std/crypto/codecs.zig", // 165 "../lib/std/os/uefi/tables/table_header.zig", // 214 "../lib/std/zig/llvm.zig", // 247 - "../lib/compiler_rt/neghf2.zig", // 265 - "../lib/compiler_rt/negxf2.zig", // 265 - "../lib/compiler_rt/absvdi2.zig", // 311 - "../lib/compiler_rt/absvsi2.zig", // 311 - "../lib/compiler_rt/absvti2.zig", // 314 + //"../lib/compiler_rt/neghf2.zig", // 265 -- disabled: @export produces Zig AIR, C sema not yet ported + //"../lib/compiler_rt/negxf2.zig", // 265 -- disabled: @export produces Zig AIR, C sema not yet ported + //"../lib/compiler_rt/absvdi2.zig", // 311 -- disabled: @export produces Zig AIR, C sema not yet ported + //"../lib/compiler_rt/absvsi2.zig", // 311 -- disabled: @export produces Zig AIR, C sema not yet ported + //"../lib/compiler_rt/absvti2.zig", // 314 -- disabled: @export produces Zig AIR, C sema not yet ported //"../lib/compiler_rt/addhf3.zig", // 319 //"../lib/compiler_rt/addxf3.zig", // 323 //"../lib/compiler_rt/mulhf3.zig", // 323