0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
Commit graph

37,426 commits

Author SHA1 Message Date
Andrew Kelley
d5bfa657c4 Merge pull request 'fix several fuzzing bugs' (#31470) from gooncreeper/zig:fuzzing-fixes into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31470
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 20:25:02 +01:00
kanpura
eff332fd04 std.os.uefi.protocol: do not reference errors via the error set(uefi.Status.Error)
closes #31456
2026-03-12 15:19:29 +01:00
Hila Friedman
80d84537f7 allow packed union comparisons in std.meta.eql (#31479)
#31464 implemented equality testing for `packed union`s - this PR updates `std.meta.eql`'s implementation to accept them.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31479
Co-authored-by: Hila Friedman <red.black.liquorice@gmail.com>
Co-committed-by: Hila Friedman <red.black.liquorice@gmail.com>
2026-03-12 13:38:06 +01:00
Matthew Lugg
58d33f51ce
bootstrap.c: correct comment 2026-03-12 12:22:24 +00:00
Alex Rønne Petersen
d5a84b69a5
ci: bump aarch64-linux-debug timeout by 1 hour 2026-03-12 08:54:37 +01:00
Kendall Condon
9d1e47d220 fuzzer ui: remove wrong optimized float mode
Some of the stats used as denomenators may be at zero, especially if a
fuzz test is stuck in an infinite loop, so allowing float division by
zero is necessary.
2026-03-11 21:26:00 -04:00
Kendall Condon
5ecef2934a rerun fuzz tests from name instead of index
The indexes can change between recompilation due to conditional
compilation and compiler quirks. While unit test names are still not a
perfect solution, they are better than indexes.
2026-03-11 21:19:22 -04:00
Kendall Condon
bca057afd2 Smith.Weight: do not use of indexOfScalar
In larger fuzz tests this can cause the eval branch quota to be
exceeded.
2026-03-11 21:16:52 -04:00
Kendall Condon
c3e6ff7206 libfuzzer: use error.SkipZigTest 2026-03-11 21:14:46 -04:00
nektro
9c54603164 std: mem.SplitIterator.peek() can accept a const pointer 2026-03-12 01:35:43 +01:00
squidy239
d6632b1dd2 std.Io: added missing toMicroseconds and fromMicroseconds functions (#30099)
added toMicroseconds and fromMicroseconds functions to std.Io.Duration and toMicroseconds to std.Io.Timestamp

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30099
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: squidy239 <sachabarsayuracko@gmail.com>
Co-committed-by: squidy239 <sachabarsayuracko@gmail.com>
2026-03-12 01:34:40 +01:00
Kendall Condon
cc2d992e24 libfuzzer: make corpus inputs go through mmap 2026-03-11 20:28:13 -04:00
Kendall Condon
c3a417206a libfuzzer: check weights for bytes mutations 2026-03-11 20:23:23 -04:00
Andrew Kelley
58890066d9 Merge pull request 'Sema: Support peer type resolution for floats and small integers' (#30921) from jayschwa/zig:ptr-small-int-and-floats into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30921
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 00:41:05 +01:00
Andrew Kelley
109d01371e Merge pull request 'Sema: implement switch for packed structs/unions' (#31464) from justusk/zig:packed-switch into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31464
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 00:39:19 +01:00
Antonin Décimo
ea9d593455 Mach-O: accept and skip CIE augmentation string 'S' in .eh_frame
```
* thread #1, name = 'zig', stop reason = breakpoint 1.1
    frame #0: 0x00000000028387c3 zig`link.MachO.eh_frame.Cie.parse(cie=0x000000003cd62060, macho_file=0x000000003ca857c0) at eh_frame.zig:56:21
   53                       else => @panic("unexpected lsda encoding"), // TODO error
   54                   }
   55               },
-> 56               else => @panic("unexpected augmentation string"), // TODO error
                            ^
   57           };
   58       }
   59
(lldb) frame variable
(link.MachO.eh_frame.Cie *) cie = 0x000000003cd62060
(link.MachO *) macho_file = 0x000000003ca857c0
([]u8) data = "\x14\x00\x00\x00\x00\x00\x00\x00\x01zRS\x00\x01x\x1e\x01\x10\x0c\x1f\x00\x00\x00\x00"
([]u8) aug = "zRS"
(Io.Reader) reader = {
  vtable = 0x0000000005407ec0
  buffer = "\x01x\x1e\x01\x10\x0c\x1f\x00\x00\x00\x00"
  seek = 5
  end = 11
}
(unsigned char) ch = 'S'
```

zig supports RPL for augmentation strings, and finds zRS (though it
scans RS). It panics on S. Presumably the parser should just ignore
this at this stage. (found [this description][1], and a bit of code [here][2]
and [there][3]).

[1]: https://www.airs.com/blog/archives/460
[2]:
https://github.com/eliben/pyelftools/blob/main/elftools/dwarf/callframe.py#L287
[3]: https://sourceforge.net/p/elftoolchain/tickets/557/

> The character ‘S’ in the augmentation string means that this CIE
> represents a stack frame for the invocation of a signal
> handler. When unwinding the stack, signal stack frames are handled
> slightly differently: the instruction pointer is assumed to be
> before the next instruction to execute rather than after it.

Signed-off-by: Antonin Décimo <antonin.decimo@gmail.com>
2026-03-11 23:21:57 +01:00
Pavel Verigo
2802276091 stage2-wasm: address TODO in instruction selection code
This PR started as addressing the long-standing TODO above `buildOpcode`:

    /// TODO: deprecated, should be split up per tag.

The code around this area was written a long time ago and has effectively
become a legacy approach. When I started doing semi-occasional work for
bringing >128-bit integer operations to the wasm backend, which is
the last big missing piece of this backend, this design became annoying.

While thinking about how to support that work, and also how vector unrolling
should be handled (in cases where we do not rely purely on the legalize pass),
I decided to do some architectural changes were needed.

The first step is removing helpers like `intBinOp`, `floatBinOp`, `UnOp`, etc.
They do not really capture all operations and resulted in a lot of small
pieces of code trying to artificially unify different ops.

Instead, the direction taken here is similar to `Sema/arith.zig`,  introduce
backend-oriented helpers such as `int*Op*Scalar` and `float*Op*` that operate
purely in backend structures without referencing AIR at all.

Additionally, the idea of introducing dedicated `IntType` and `FloatType`
types was chosen. Using `Type` from Sema inside the backend is awkward,
especially when strange or temporary types are needed. Creating them through
`PerThread` is also undesirable since the backend strives to not modify
`InternPool`. This goal is not fully achieved yet, some parts still require
changes, and `InternPool` type formatting still requires `pt` for error
reporting.

This PR also enables legalize passes for some packed operations. The previous
code in this area was buggy, and given the current state of the backend,
relying on legalization is simpler.

Finally, this PR disables one behavior test: `atomicrmw` with floats. The test
seems to only run the non-concurrency path, because it would crash otherwise,
and since we do not currently run behavior tests for the self-hosted backend
with concurrency or atomics enabled, it does not provide meaningful coverage yet.

In summary, this refactor reworks instruction selection in the wasm backend
to simplify the code and make future work, especially adding big integer
support.
2026-03-11 22:46:58 +01:00
Andrew Kelley
3069917384 std.Io.Threaded: use AlertableSyscall for ws2_32 operations
closes #30865
2026-03-11 22:46:13 +01:00
Justus Klausecker
e91654b1e7 test: disable switch behavior test switching on type >64bits for cbe
workaround for #31467
2026-03-11 21:14:43 +01:00
Justus Klausecker
28886ca9ec Sema: implement switch for packed structs/unions
Since packed containers are now represented by `bitpack` and can't include
pointers anymore this has become a very easy change to make. This commit
largely just reuses the logic already in place for integers.

Also fixes a small bug where captures-by-ref of errors wouldn't cause a
compile error for regular switch statements. There was already an astgen
error in place for error handling switch statements (`switch_block_err_union`)
capturing their error by reference.
2026-03-11 21:04:04 +01:00
Jay Petacat
fcf64761d0
Sema: Support peer type resolution for floats and small integers
This builds on the changes in PR #30053 / commit 484cc15366.

Previously, peer type resolution would always result in a conflict for
fixed-width integer and float types. Now that small integer types can
coerce to floats, peer type resolution can take that into account. This
primarily benefits arithmetic with mixed float and integer operands. If
the integer operand can coerce to the float operand's type, it will do
so without requiring an explicit cast. If the integer type can't coerce,
there will be a compiler error; no float widening will occur. Explicit
casting will still be required to make it work.
2026-03-11 11:31:58 -06:00
Jay Petacat
89c98e2001
Sema: fix integer coercion to c_longdouble
This is a follow-up to PR #30053 / commit 484cc15366.

The code previously did not handle `c_longdouble`, whose size depends on
the target. A `floatSignificandBits` helper function and a smoke test
were added.

Also added the missing max int value to the exhaustive `f16` test cases.
2026-03-11 10:24:42 -06:00
Justus Klausecker
be9b42d707 compiler: allow equality comparisons for packed unions
This was already possible in practice by just wrapping a packed union into
a packed struct. Now it's also possible without doing that.
2026-03-11 16:44:08 +01:00
Andrew Kelley
b4ffb402c0 translate-c build step: handle system libraries
closes #31450
2026-03-11 04:57:25 +01:00
rpkak
77d7686902 std.zig.putAstErrorsIntoBundle: support zon 2026-03-11 03:01:35 +01:00
Andrew Kelley
a388b88ed4 Merge pull request 'std.heap.ArenaAllocator: add fuzz test + some optimizations' (#31407) from justusk/zig:fuzz-arena into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31407
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-11 03:00:07 +01:00
FnControlOption
c01b9b1ab5 langref: replace std.meta.Int with @Int 2026-03-11 02:37:05 +01:00
Techatrix
1a8ed9a658 checkAllAllocationFailures: provide result type to 'extra_args' 2026-03-11 02:32:29 +01:00
Techatrix
acde20a148 fetch: fix incorrect error about unneeded lazy dependency in system mode 2026-03-11 02:31:19 +01:00
Kendall Condon
6e5a95bd7c implement proper deflate flush semantics
To end a flate stream, `finish` must now be called. `flush` now follows
regular semantics and byte-aligns the stream.

Byte-aligning the stream is done with empty fixed or store blocks. To
implement flush, a variable history length was added and it is tracked
if the final bytes of history have been hashed yet.
2026-03-11 02:28:19 +01:00
Andrew Kelley
c2587582c8 Merge pull request 'libzigc: Implement coshf & cosh' (#31434) from mihael/zig:libzigc/implement-coshf-cosh into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31434
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-11 02:10:56 +01:00
Andrew Kelley
5d9660972d Merge pull request 'fix: use cmpxchgStrong in Io.Mutex' (#31441) from GasInfinity/zig:io-mutex-cmpxchg-strong into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31441
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-11 01:56:56 +01:00
Meghan Denny
bd5dc75068 std: remove GeneralPurposeAllocator alias 2026-03-11 01:55:49 +01:00
Alex Rønne Petersen
6015192fb6
test-libc: disable pthread_cond_wait-cancel_ignored.c
It's flaky under heavy load: https://codeberg.org/ziglang/zig/actions/runs/2208/jobs/20/attempt/1
2026-03-10 23:36:22 +01:00
mlugg
3edaef9e01 Merge pull request 'compiler: rework type resolution' (#31403) from lets-get-typing into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31403
2026-03-10 22:06:05 +01:00
GasInfinity
d70bd0b37e
fix: use cmpxchgStrong in std.atomic.Mutex
* same reason as 048e38624e
2026-03-10 20:27:10 +01:00
Ryan Liptak
b80abf0296 Merge pull request 'Add a few fs test cases from otherwise obsoleted PRs' (#31437) from squeek502/zig:fs-test-cases into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31437
2026-03-10 19:39:18 +01:00
Alex Rønne Petersen
502cab9ae3
test_runner: actually print the error that caused a runner failure
part of the Stop Throwing Away Useful Information initiative
2026-03-10 11:28:36 +00:00
Matthew Lugg
79e7b719a3
bootstrap: disable strict aliasing
The C backend has always gleefully violated C's strict aliasing rules,
and I just got bitten by it for the first time when bootstrapping on
macOS. This probably hasn't been helping with some of the weird
bootstrap-related CI failures we've seen. So, update `bootstrap.c` and
`CMakeLists.txt` to tell GCC/Clang to disable type-based alias analysis.

No change is needed to the MSVC flags because MSVC does not, and never
has, implemented TBAA.
2026-03-10 11:28:36 +00:00
Matthew Lugg
57114044db
Revert "ci: disable incremental tests"
Since we don't know what causes the various flaky test-incremental
failures we've seen, and this branch changes a bunch of incremental
stuff, let's try turning these back on... maybe they'll magically work
now!

This reverts commit 953ca759c2.
2026-03-10 11:28:36 +00:00
Matthew Lugg
a3d2f2999f
tests: add new tests
Some for bugs which have been fixed, some for language changes.
2026-03-10 11:28:36 +00:00
Matthew Lugg
f92b998f9f
behavior: disable some tests under the C backend targeting MSVC
The bugs here actually exist on master branch too, but they are being
caught by the new static assertions which check type size and alignment.
It turns out that MSVC's struct/union "pack" pragma and its "align"
declspec interact in undocumented ways which are extremely problematic
for generated code. Solving this will require changing how the C backend
lowers various types; the disabled tests are all tagged unions, but
there are also issues with structs with underaligned fields which the
behavior tests just happen to not currently be triggering.
2026-03-10 10:38:51 +00:00
Matthew Lugg
1293f080fd
build.zig: bump max_rss values 2026-03-10 10:38:50 +00:00
Matthew Lugg
34d780f4bb
langref: update for language changes 2026-03-10 10:38:50 +00:00
Matthew Lugg
ce1f28a749
behavior: update for std.builtin.Type changes 2026-03-10 10:38:50 +00:00
Matthew Lugg
5ec3a0cd54
std: update for language changes
Now that zig1.wasm is updated, apply the matching standard library
changes.

The main one is in `std.builtin.Type`, where `alignment` fields now have
type `?usize` rather than `comptime_int`.

Additionally, we need to add explicit backing integers to some packed
unions, because (due to https://github.com/ziglang/zig/issues/24714)
they need explicit backing integers to be used in `extern` contexts.
This change could not happen before now, because prior to this branch,
packed unions did not allow explicit backing integer types (that is,
this branch implemented https://github.com/ziglang/zig/issues/25350).
2026-03-10 10:38:50 +00:00
Matthew Lugg
793fa93d9f
stage1: update zig1.wasm
Generated using a compiler bootstrapped from the merge base of this
branch, and wasm-opt version 118.

Signed-off-by: Matthew Lugg <mlugg@mlugg.co.uk>
2026-03-10 10:38:21 +00:00
Matthew Lugg
4a310ce7c1
Sema: expect 'alignment' fields in 'std.builtin.Type' to be '?usize'
This is a language change which works nicely alongside some of the other
changes in this branch. It will help to resolve the remaining couple of
failures in the std and behavior tests.

The actual std.builtin change is not in this commit, because we must
update zig1.wasm first.
2026-03-10 10:26:15 +00:00
Matthew Lugg
a5219cd288
bootstrap: work around GCC bug
GCC bug 119085, which affects versions 13.0--15.1, is being triggered by
the C backend, resulting in a (small but critical) miscompilation in
zig2. Unfortunately, we can't really work around that bug without a
command-line flag, because the bug is sensitive to things like the order
in which `struct` types are defined.

Therefore, I have added an option to `bootstrap.c` which causes it to
pass the appropriate flag to `gcc` to disable the optimization pass in
question. This flag can likely be removed in future, once the affected
GCC versions become less common.

At least one of our x86_64-linux CI machines is using an affected GCC
version, so I also updated the relevant CI script to pass this flag when
testing no-LLVM bootstrap.

CMakeLists also has a workaround, but no user intervention is required
there: the GCC version range is automatically detected by CMakeLists.
2026-03-10 10:26:15 +00:00
Matthew Lugg
c73db56b45
compiler: small optimizations
With these optimizations in place, this branch is faster than master in
ReleaseFast, and... not too much slower than master in ReleaseSafe.
2026-03-10 10:26:15 +00:00