Add verbose_air.c/h implementing a human-readable AIR printer for
debugging the C sema, ported from src/Air/print.zig. Types print as
human-readable names (u32, *const u8, fn (...) noreturn) instead of
raw IP indices. Add --verbose-air flag to zig0 CLI and a `zig build
zig0` target for building the standalone executable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The git-describe version string (including commit hash) was passed via
exe_options to zig_internals_mod, causing verbose_dumper to recompile
(~7 min) after every commit. Create separate zig0_exe_options with a
fixed version "0.15.2-zig0-dev" for test-zig0/all-zig0 targets.
Also verify matched_count against c_func_count in Air comparisons to
catch spurious extra functions from the C pipeline.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both zig_dump_intern_pool and c_dump_intern_pool were unimplemented stubs
with no callers. InternPool correctness is validated by unit tests and Air
comparison.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Export raw Air arrays (tags, datas, extra) from the Zig compiler via a
RawAirCallback on Compilation, and memcmp them against C-produced arrays
instead of comparing formatted text output. This is more robust (catches
any byte-level divergence) and eliminates the need for the C-side text
formatter.
- Add RawAirCallback type and field to Compilation
- Rewrite src/verbose_air.zig: raw array export instead of text capture
- Update stage0 tests to use compareAir with expectEqualSlices
- Delete stage0/verbose_air.{c,h} (no longer needed)
- Remove verbose_air.c/h from build.zig file lists
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove all @import("zig_internals") from stage0/ so that test_obj
compilation is independent of the Zig compiler (~6min). The sema
comparison now uses text-based dumpers:
- Zig side (src/verbose_air.zig): compiles source through the full Zig
pipeline, captures verbose_air output, exports zig_dump_air() as a C
function. Compiled as a separate dumper_obj that is cached
independently.
- C side (stage0/verbose_air.c): formats C Air structs to text in the
same format as Zig's Air/print.zig.
Changing stage0 code no longer triggers Zig compiler recompilation:
C compile + cached test_obj + cached dumper + link = seconds.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The zig test step previously compiled Zig code and linked C objects in
a single invocation. Since the Zig compiler hashes all link inputs
(including .o file content) into one cache key, changing -Dzig0-cc or
editing any C file invalidated the 6-minute Zig compilation cache.
Split into two steps: emit the Zig test code as an object (cached
independently of C objects), then link it with the C objects in a
separate executable step. Manually set up the test runner IPC protocol
via enableTestRunnerMode() to preserve build summary integration.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire src/test_exports.zig through build.zig so zig0 tests can import
the real Zig InternPool. Add a test that initializes both the C and Zig
InternPools and compares all 124 pre-interned entries index by index.
Also add rule to skill file: never run `zig build test` or bare
`zig build` (they test upstream Zig and take ages).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split cppcheck into per-file checks (warning,style,performance,portability)
and a combined unusedFunction check across all C files. Remove dead code
(addExtraU32, rvalueDiscard, wipMembersNextDecl, wipMembersBodiesAppend,
findNextContainerMember, NodeContainerField). Wire up zig0Run to actually
call astParse/astGen and print stats, eliminating unusedFunction warnings
for the public API.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use memset initialization to satisfy cppcheck's data flow analysis:
- err_scope_used: cppcheck can't track writes through is_used_or_discarded pointer
- param_insts: cppcheck warns about potentially uninitialized array elements
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Consolidate the two separate test modules (test_mod via
lib/std/zig/zig0_test.zig + astgen_test_mod via stage0_test_root.zig)
into a single test module rooted at stage0_test_root.zig.
The zig0_test.zig bridge approach ran std's parser/tokenizer tests with
C comparison enabled, but the stage0/ test files already do the same
C-vs-Zig comparison directly via @cImport. The only "lost" tests are an
unnamed root test block and a Zig-only fuzz test — no zig0 coverage lost.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Valgrind doesn't support AVX-512 instructions (EVEX prefix 0x62).
The zig CC generates them for large struct copies on native x86_64
targets even at -O0 (e.g. vmovdqu64 with zmm registers).
Previously only avx512f was subtracted, which was insufficient —
the .evex512 feature (and other AVX-512 sub-features) also need
to be disabled to prevent EVEX-encoded 512-bit instructions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This reverts commit b461d07a54.
After some discussion in the team, we've decided that this is too disruptive,
especially because the linker errors are less than helpful. That's a fixable
problem, so we might reconsider this in the future, but revert it for now.
added adapter to AnyWriter and GenericWriter to help bridge the gap
between old and new API
make std.testing.expectFmt work at compile-time
std.fmt no longer has a dependency on std.unicode. Formatted printing
was never properly unicode-aware. Now it no longer pretends to be.
Breakage/deprecations:
* std.fs.File.reader -> std.fs.File.deprecatedReader
* std.fs.File.writer -> std.fs.File.deprecatedWriter
* std.io.GenericReader -> std.io.Reader
* std.io.GenericWriter -> std.io.Writer
* std.io.AnyReader -> std.io.Reader
* std.io.AnyWriter -> std.io.Writer
* std.fmt.format -> std.fmt.deprecatedFormat
* std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape
* std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape
* std.fmt.fmtSliceHexLower -> {x}
* std.fmt.fmtSliceHexUpper -> {X}
* std.fmt.fmtIntSizeDec -> {B}
* std.fmt.fmtIntSizeBin -> {Bi}
* std.fmt.fmtDuration -> {D}
* std.fmt.fmtDurationSigned -> {D}
* {} -> {f} when there is a format method
* format method signature
- anytype -> *std.io.Writer
- inferred error set -> error{WriteFailed}
- options -> (deleted)
* std.fmt.Formatted
- now takes context type explicitly
- no fmt string
This lays the groundwork for #2879. This library will be built and linked when a
static libc is going to be linked into the compilation. Currently, that means
musl, wasi-libc, and MinGW-w64. As a demonstration, this commit removes the musl
C code for a few string functions and implements them in libzigc. This means
that those libzigc functions are now load-bearing for musl and wasi-libc.
Note that if a function has an implementation in compiler-rt already, libzigc
should not implement it. Instead, as we recently did for memcpy/memmove, we
should delete the libc copy and rely on the compiler-rt implementation.
I repurposed the existing "universal libc" code to do this. That code hadn't
seen development beyond basic string functions in years, and was only usable-ish
on freestanding. I think that if we want to seriously pursue the idea of Zig
providing a freestanding libc, we should do so only after defining clear goals
(and non-goals) for it. See also #22240 for a similar case.