Commit Graph

596 Commits

Author SHA1 Message Date
689b6b901d fmt 2026-02-20 10:30:47 +02:00
eaab079bd6 always build with valgrind 2026-02-19 20:58:30 +00:00
149e611688 Fix test-zig0 cache invalidation on every commit
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>
2026-02-19 20:22:51 +00:00
905ea3a3f7 Remove unimplemented InternPool dump stubs
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>
2026-02-19 18:32:46 +00:00
2516d3a46a Replace text-based Air comparison with raw array memcmp
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>
2026-02-19 16:52:58 +00:00
00a6cb4fd4 Replace structural Air/IP comparison with text-based dumpers
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>
2026-02-19 14:48:40 +00:00
42afa9a451 build: split zig0 test into compile + link to fix caching
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>
2026-02-19 11:59:43 +00:00
4ebbc9047f stages_test: add Zig InternPool cross-check for pre-interned entries
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>
2026-02-19 06:19:39 +00:00
0b041e0c70 stage0: add Sema data structures (Phase A)
Create header files and minimal .c stubs for the Sema pipeline:
- intern_pool.h/c: InternPool types, pre-interned indices (0-123),
  SimpleType/SimpleValue enums, Key tagged union, init/deinit
- air.h/c: AIR instruction tags (X-macro), Ref encoding (MSB tag),
  InstData union, extra payload structs, init/deinit
- type.h/c: TypeIndex typedef, stub query functions
- value.h/c: ValueIndex typedef, conversion functions
- sema.h/c: Sema/Block/InstMap/Merges structs, init/deinit/analyze stubs

Wire up build.zig and integrate sema step into zig0.c pipeline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-17 19:42:24 +00:00
9d438d5674 cppcheck: remove all suppressions, fix all warnings
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>
2026-02-17 18:13:52 +00:00
d3d76d59a6 astgen: fix ptrTypeExpr addrspace, do_err_trace check, switchExpr capture, blockExprStmts heap alloc
- ptrTypeExpr: use addBuiltinValue + RL_COERCED_TY for addrspace (matching
  AstGen.zig:3880-3881) instead of RL_NONE_VAL
- do_err_trace: check ag->fn_block != NULL instead of ag->fn_ret_ty != 0 in
  ifExpr, orelseCatchExpr, switchExprErrUnion (matching Zig semantics)
- switchExpr: don't reset capture for underscore discards (AstGen.zig:7870)
- nodeIsTriviallyZero: handle prefixed zero forms (0b0, 0o0, 0x0, with
  underscores)
- blockExprStmts: heap-allocate scope arrays sized to stmt_count instead of
  fixed 128, fixing compile errors on large blocks (e.g. scalar.zig)
- build.zig: increase default test timeout from 10s to 300s
- Remove debug fprintf counters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 05:30:35 +00:00
d2c301cc95 astgen: fix cppcheck warnings for err_scope_used and param_insts
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>
2026-02-15 19:50:05 +00:00
3f315398fc simplify zig0 test setup: single test module, remove zig0_test.zig
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>
2026-02-14 14:19:15 +00:00
82e0d9a445 move module up 2026-02-14 10:53:08 +02:00
df78083c0f build: fix valgrind zig0 tests by disabling all AVX-512 features
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>
2026-02-14 08:28:24 +00:00
7875cc66f4 bump version 2026-02-14 01:48:19 +02:00
ae5da9de14 bump to dev 2026-02-14 01:33:42 +02:00
8756145090 Merge tag '0.15.2' into zig0-0.15.2
Release 0.15.2
2026-02-14 01:33:08 +02:00
069d61d239 stage0-specific changes 2026-02-14 00:03:26 +02:00
Andrew Kelley
409b194d6d start the 0.15.2 release cycle 2025-08-19 16:21:17 -07:00
Andrew Kelley
f54f061fb3 start the 0.15.1 release cycle 2025-08-19 16:01:09 -07:00
Andrew Kelley
749f10af49 std.ArrayList: make unmanaged the default 2025-08-11 15:52:49 -07:00
Alex Rønne Petersen
7ee6dab39f Revert "Sema: Stop adding Windows implib link inputs for extern "..." syntax."
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.
2025-08-06 06:15:13 +02:00
Alex Rønne Petersen
bcaae562d6 build: add -Dskip-compile-errors option
Skips tests in test/cases/compile_errors.
2025-08-02 09:34:55 +02:00
Andrew Kelley
0e37ff0d59 std.fmt: breaking API changes
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
2025-07-07 22:43:51 -07:00
Andrew Kelley
a59c35cbf8 build.zig: bump maxrss for behavior tests 2025-07-07 13:39:16 -07:00
Alex Rønne Petersen
b461d07a54 Sema: Stop adding Windows implib link inputs for extern "..." syntax.
Closes #23971.
2025-07-06 01:00:18 +02:00
Alex Rønne Petersen
9ef4bdf234 test: Respect various test skip options in test-cases 2025-07-03 22:18:12 +02:00
Jacob Young
917640810e Target: pass and use locals by pointer instead of by value
This struct is larger than 256 bytes and code that copies it
consistently shows up in profiles of the compiler.
2025-06-19 11:45:06 -04:00
Jacob Young
16d78bc0c0 Build: add install commands to --verbose output 2025-06-19 11:45:06 -04:00
Andrew Kelley
5a52da1b7a CI: skip llvm backend tests in the script for testing x86 backend 2025-06-06 23:42:15 -07:00
Andrew Kelley
125a9aa82b restore debug llvm CI coverage
and reduce redundant coverage in slow runs to save time
2025-06-06 23:42:15 -07:00
Jacob Young
5986bdf868 Compilation: enable the x86_64 backend by default for debug builds
Closes #22257
2025-06-06 23:42:14 -07:00
Jacob Young
6a63c8653a build: bump behavior max_rss 2025-06-01 11:58:58 -04:00
Alex Rønne Petersen
d000e53b29 Merge pull request #23923 from alexrp/compiler-rt-symbols
Use hidden visibility in compiler-rt and libzigc except when testing
2025-05-20 07:48:35 +02:00
Alex Rønne Petersen
846571ce4e build: Bump max_rss for test-behavior to 2488843878. 2025-05-19 00:22:03 +02:00
mlugg
6d7c89cb40 build.zig: use correct module graph for compiler unit tests 2025-05-18 17:10:04 +01:00
Alex Rønne Petersen
e63e3f7a7c test: Add test-llvm-ir step and harness for testing generated LLVM IR. 2025-05-12 17:07:50 +02:00
Alex Rønne Petersen
9352f379e8 Merge pull request #23529 from alexrp/2879-groundwork
Introduce libzigc for libc function implementations in Zig
2025-04-12 18:14:17 +02:00
Andrew Kelley
4e700fdf8e Merge pull request #22516 from Jan200101/PR/build_id_option
std.Build: add build-id option
2025-04-11 16:37:46 -04:00
Alex Rønne Petersen
1f896c1bf8 Introduce libzigc for libc function implementations in Zig.
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.
2025-04-11 17:12:31 +02:00
Alex Rønne Petersen
1bfc71d4da build: Set LLVM_BUILD_STATIC/CLANG_BUILD_STATIC when linking statically.
This is needed since LLVM 20, particularly for Windows.
2025-04-09 10:11:52 +02:00
Alex Rønne Petersen
f2f36c49c8 compiler: Switch default code model for loongarch64 to medium.
LLVM 21 will change the default, but we're making the change now to make
building Zig for loongarch64 less painful.

https://github.com/llvm/llvm-project/pull/132173
2025-04-07 21:36:56 +02:00
Alex Rønne Petersen
7c5412c7a4 build: Rename -Dtest-slow-targets to -Dtest-extra-targets.
This can be used more broadly for targets that aren't quite ready to be tested
by default yet.
2025-04-04 06:08:10 +02:00
Alex Rønne Petersen
c712f18d74 build: Update to LLVM/Clang 20. 2025-04-04 06:08:08 +02:00
Alex Rønne Petersen
2b57f6b717 Merge pull request #23378 from alexrp/build-zig-cleanup 2025-03-27 17:12:17 +01:00
Alex Rønne Petersen
dc66f4384f build: increase test-std max rss 2025-03-27 04:36:27 +00:00
Alex Rønne Petersen
f71590d4c4 build.zig: Statically link LLVM libraries for experimental targets if requested. 2025-03-27 00:31:11 +01:00
Alex Rønne Petersen
2489b5fd74 build.zig: Stop setting _WIN32_WINNT=0x601 (Windows 7) when targeting MinGW.
Our default minimum version for Windows has been Windows 10 for a while.
2025-03-26 23:12:55 +01:00
Alex Rønne Petersen
ccffc7f108 build.zig: Don't disable LTO when targeting MinGW.
We stopped building mingw32.lib with LTO recently, so this is no longer needed.
2025-03-26 22:46:27 +01:00