Commit Graph

37691 Commits

Author SHA1 Message Date
Matthew Lugg 240e5eab0e Sema: push to error trace when returning from inline function
There is no reason `inline fn`s should not be subject to error tracing:
they are still functions! So, push to the error trace when we return
from one, and add a test checking that inline functions do appear in
error traces.

This also changes how we emit error trace pushes: we no longer duplicate
the AIR `ret` instruction in the "error" and "non-error" code paths. I
suspect this will lead to slightly better unoptimized codegen, but I may
be wrong---I'll take some performance measurements before I merge this.
2026-04-07 08:28:39 +02:00
Alex Rønne Petersen a38c6bbcc4 test: disable incremental tests on x86_64-windows-selfhosted
https://codeberg.org/ziglang/zig/issues/31773
2026-04-06 23:04:14 +02:00
Techatrix be878b87c2 std.EnumSet: add back deprecated initialization functions 2026-04-06 15:54:47 +02:00
Samuel Fiedler 5ec8e45f3d Io: add failing io (Io.failing) 2026-04-06 14:25:44 +02:00
glowsquid fd2718f82a fix positional reader discarding (#31593)
closes #30151
closes #30126

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31593
Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>
Co-authored-by: glowsquid <sachabarsayuracko@gmail.com>
Co-committed-by: glowsquid <sachabarsayuracko@gmail.com>
2026-04-06 02:03:11 +02:00
Andrew Kelley 8bd0af5eb9 std.http.Client.receiveHead: avoid poisioning pool
closes #30165
2026-04-05 15:02:00 +02:00
Andrew Kelley 9292ded5a3 std.Io.Batch: fix add function
closes #31730
closes #31757
2026-04-05 02:17:53 -07:00
nektro e73257dec2 lib/std: BitSet,EnumSet: replace initEmpty/initFull with decl literals (#31469)
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31469
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: nektro <hello@nektro.net>
Co-committed-by: nektro <hello@nektro.net>
2026-04-05 05:12:13 +02:00
Pavel Verigo ad7a028228 stage2-wasm: pass incremental tests
This PR enables all incremental tests under the `test/incremental` directory, except one: `change_exports`, which is currently ignored as it requires a non-trivial amount of work on the linker, since we do not currently support exporting data symbols.

To enable the other tests, the following fixes were needed:

1. `src/link/Wasm.zig`: instead of chasing function type through Nav, get it directly.
2. `src/target.zig`: `.panic_fn` appears to work fine with the wasm backend.
3. `src/codegen/wasm/CodeGen.zig`: there was a liveness related bug that caused some `ArenaAllocator` code to crash the backend.

More info on (3), the liveness and local reuse code in the backend for years in unfinished state. For example there is currently no branch merging and reuse happens only when inst die in same block level. I initially considered doing a large refactor to implement everything correctly, but aborted due to its sheer size and currently! no clear idea about how to do this efficiently.

Instead, I fixed the bug with minimal changes and removed useless code, keeping the old solution otherwise intact.
2026-04-04 15:21:35 +02:00
Saurabh Mishra 65fe99e18a priority queue and dequeue: use *const Self in read-only methods and fix deinit (#31712)
Read-only methods `peek` in priority queue, and `peekMin` and `peekMax` in priority dequeue use `self: *const Self` instead of `self: *Self`.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31712
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Saurabh Mishra <saurabh.m@proton.me>
Co-committed-by: Saurabh Mishra <saurabh.m@proton.me>
2026-04-03 22:20:46 +02:00
Andrew Kelley 842b74d7ea Merge pull request 'libc: remove some redundant files' (#31748) from rpkak/zig:libc-remove-some-functions into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31748
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2026-04-03 22:18:03 +02:00
rpkak b5fbed986b musl,wasi-libc: remove unused exp_data and pow_data 2026-04-03 15:26:18 +02:00
rpkak 208a74a5c5 libc: remove duplicates of some functions
mingw,musl,wasi-libc: remove c files, that only provide functions already included in zigc

mingw: remove c files, that only provide functions, which are in ucrt

mingw: do not include mingw files/zigc functions on targets on which they in ucrt
2026-04-03 15:26:09 +02:00
rpkak 90ccd6051c test-libc: do not skip search_hsearch on wasi-libc
emmalloc is not used anymore
2026-04-03 13:28:33 +02:00
Kendall Condon d8ba173e5e multiprocess fuzzing
- New Features

-- Multiprocess Fuzzing

The fuzzer now is able to utilize multiple cores. This is controllable
with the `-j` build option. Limited fuzzing still uses one core.

-- Fuzzing Infinite Mode

When provided multiple tests, the fuzzer now switches between them and
prioritizes the most effective and interesting ones. Over time already
explored tests will become barely run compared to tests yielding new
inputs.

-- Crash Dumps

Crashing inputs are now saved to a file indicated by the crash message.
It is recommended to use these files to reproduce the crash using
`std.testing.FuzzInputOptions.corpus` and @embedFile.

- Design

Each fuzzing process is assigned an instance id which has the following
uses:
* In conjunction with the pc hash and running test index, they uniquely
  identify input files in the case of a crash.
* It is combined with the test seed for a unique rng seed.
* Instance 0 is solely responsible for syncing the filesystem corpus.

When new inputs are found, they are sent to the build server. It then
distributes the new input to the other instances. Each instance has a
concurrent poller managed by the test runner which sends received
inputs to libfuzzer. (note that this is affected by #31718 and so can
(rarely) deadlock)

For fuzzing infinite mode, the test runner now receives a list of tests
from the build server. The fuzzer runs tests in batches of one second,
approximated in cycles by the previous batch's run speed. Tests finding
new inputs or with few runs are given a higher run chance. The baseline
run chance is based off the recency of the last find and the number of
pcs the test has hit.
2026-04-03 12:27:34 +02:00
Andrew Kelley d34b868bcf Merge pull request 'libzigc: Implement 12 more math functions' (#31604) from mihael/zig:libzigc/more-math-functions-2 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31604
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-03 12:04:32 +02:00
mihael 4ccac1de41 compiler_rt: Make long double trig impls non-generic 2026-04-02 23:54:20 +02:00
mihael ad10c76007 compiler_rt: Stop using dunders for trig functions names
Additionally, use `std.math.pi / 4.0` for `pi/4` in `trig.zig`
instead of hardcoding the value.
2026-04-02 23:54:20 +02:00
mihael 61161132b6 compiler_rt: Dissolve math_utils.zig into long_double.zig & trig.zig
The closest namespace the pi/4 constant could belong to is `trig.zig` since
it's used across trig function implementations. On the other hand, chucking
`long double` bit slicing functions into `trig.zig` seems a little more
awkward, so they're put into their own namespace.
2026-04-02 23:54:20 +02:00
mihael f6ac1a6e05 compiler_rt: Symbolically link cosl & sinl impl to __cosl & __sinl
Some of the functions (e.g., `lgammal`) depended on the `__sinl` and
`__cosl`
functions being present.
2026-04-02 23:54:20 +02:00
mihael 9a53be5fb4 libzigc/math: Implement more precise sincosl in compiler_rt
The changes were tested by running:
```bash
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=sincosl -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```

Additionally, I've added unit tests for `sincos`.
2026-04-02 23:54:20 +02:00
mihael a6d6af947d libzigc/math: Implement more precise cosl in compiler_rt
The implementation was ported from `musl`. Unit tests for `f80` and `f128` were also added.
`__cosl` was already implemented in `trig.zig` while working on `sinl`.

The changes were tested by running:
```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter='math.cosl' -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```
2026-04-02 23:54:20 +02:00
mihael b5ec3e597e libzigc/math: Implement more precise sinl in compiler_rt
The implementation was ported from `musl`. Unit tests for `f80` and `f128` were also added.

The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=sinl -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```
2026-04-02 23:54:20 +02:00
mihael ffd6f6cc6e libzigc/math: Implement more precise tanl in compiler_rt
The logic was more or less ported from `musl`, with small adjustments
where it was convenient. The 'internal' `__tanl` function was implemented
in the `trig.zig` module along with other 'internal' trigonometric functions.

Now, the `tanl` implementation is precise enough to pass all the relevant `libc-test` suite tests:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=tanl -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```

The unit tests were also extended to include cases for `f80` and `f128`, and they're passing.
2026-04-02 23:54:20 +02:00
mihael c76644caf3 libzigc/math: Port rem_pio2l from musl to compiler_rt
Additionally, add helper functions for fetching the sign+exponent
and top 16 bits of a f80/f128's mantissa.

We'll need these functions to implement `cosl`, `sinl`, `tanl`, and,
transitively, `sincosl`.
2026-04-02 23:54:20 +02:00
mihael 19334f95c1 libzigc/math: Implement lrintf
This was checked by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=lrintf -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-04-02 23:54:20 +02:00
mihael bd1dc8948f libzigc/math: Remove straggler rint file in vendored MinGW
Seems like it was missed when implementing `rint`.

This was checked by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=rint -fqemu -fwasmtime --summary line
Build Summary: 2209/2209 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 245c160a7b libzigc/math: Implement rintf
The implementation was ported from `musl` to Zig code, and the `rint`
unit tests were generalized so they could be used for `rintf` as well.

This was checked both through unit tests and running `libc-test` suite:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=rintf -fqemu -fwasmtime --summary line
Build Summary: 1657/1657 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 811bada06d libzigc/math: Implement lrint
The changes were tested by running:
```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=lrint -fqemu -fwasmtime --summary line
Build Summary: 737/737 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael e15d8dd3d2 libc-test/math: Enable rint tests
The `rint` tests were commented out when added along with other functions to
the `libc-test` runner, presumably because they were failing. In the meantime,
we moved to using a Zig-implemented `rint` and I found that the tests are now
passing. To celebrate, I'm putting them back into commission.

Having these tests in a working state is nice because functions like `lrint`,
`llrint`, and `nearbyint` depend on `rint` implementation being correct.

Results:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=rint -fqemu -fwasmtime --summary line
Build Summary: 2209/2209 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 2cbd6980e5 libzigc/math: Implement finite, finitef
The behaviour of `libc` `finite` functions is the same as Zig std's, so
the function basically delegates to `math.isFinite` and no new tests were
added. These functions are obsolete, but still part of `musl`.

No results are attached in this case as `libc-test` doesn't have tests for them.
2026-04-02 23:54:19 +02:00
mihael db1e649575 libzigc/math: Implement frexpl
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexpl -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael 521a093334 libzigc/math: Implement frexpf
The `frexp` implementation was generalized so it can be used for `f32`
and `c_longdouble` types as well.

The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexp -fqemu -fwasmtime --summary line
Build Summary: 737/737 steps succeeded

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexpf -fqemu -fwasmtime --summary line
Build Summary: 369/369 steps succeeded
```
2026-04-02 23:54:19 +02:00
mihael dcffee0672 libzigc/math: Implement frexp
The changes were tested by running:

```
$ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib

$ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=frexp -fqemu -fwasmtime --summary line
Build Summary: 737/737 steps succeeded
```

The tests were passing even when it was a straightforward calling of Zig
std library, but I wanted the `x is NaN` special case to match the
behaviour described in `libc` manpages, and for it to be consistent
with how infinities as arguments are handled in Zig.
2026-04-02 23:54:19 +02:00
mihael ba4af7aa8a libzigc/math: Switch to compiler_rt impl of tanl 2026-04-02 23:54:19 +02:00
mihael a8b710697e libzigc/math: Switch to compiler_rt impl of sincosl 2026-04-02 23:54:19 +02:00
Justus Klausecker ce3f254526 std.heap.ArenaAllocator: do not cmpxchg in hot path when it would be a noop
The cmpxchg is there to recover alignment padding that isn't needed (which
can only be determined after the fetch-and-add that reserves it as allocated
memory). As cmpxchg tends to be a very expensive operation, it is actually
faster to introduce an additional branch here that checks if the cmpxchg
would be a noop (because all of the reserved alignment padding was in fact
necessary) and skips it if that's the case.

This does not measurably regress performance if the arena is only accessed
by a single thread and yields slight performance benefits for multi-threaded
usage. If the arena is commonly used for unaligned allocations, the perf
benefits are quite significant.

Co-authored-by: Jacob Young <amazingjacob@gmail.com>
2026-04-02 23:00:26 +02:00
Alex Rønne Petersen 7f3c1329f8 libc-test: disable pthread_cond-smasher.c
Prone to flaky timeouts under heavy load.
2026-04-02 20:53:45 +02:00
Andrew Kelley e9df86aed0 Merge pull request 'std.heap.ArenaAllocator: decrease fuzz test workload per run' (#31596) from justusk/zig:fuzz-arena-2 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31596
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-02 15:57:41 +02:00
Andrew Kelley 43d84420f3 Merge pull request 'std: add mem.absorbSentinel(), fix sentinel handling in Allocator interface' (#31611) from ifreund/zig:absorb-sent into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31611
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-02 15:55:21 +02:00
Pavel Verigo 557caecaaa stage2-wasm: start big int support 2026-04-02 15:48:43 +02:00
Andrew Kelley 3e0f55fcc7 Merge pull request 'add an ast smith' (#31635) from gooncreeper/zig:ast-smith into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31635
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-02 15:41:05 +02:00
johan0A 022c76fc89 std.Build.Module: fix dangling slice in dynamic linker arg 2026-04-02 15:19:14 +02:00
Josh Megnauth 56507ecf98 libzigc: stropts/isastream
`isastream` is an old, deprecated function for the STREAMS framework.
Linux doesn't even support this natively, and so the musl implementation
just returns 0 (not a STREAMS file) for valid file descriptors or -1
(for bad file descriptors).
2026-04-02 15:13:39 +02:00
Hila Friedman 746dd51faf Simplify std.ArrayList.replaceRange and std.ArrayList.replaceRangeAssumeCapacity (#31710)
The implementations of `std.ArrayList.replaceRange` and `std.ArrayList.replaceRangeAssumeCapacity` were needlessly complicated, called `@memcpy` too many times, and left the structure in a semi-modified state in OOM conditions. This commit fixes that.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31710
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Hila Friedman <red.black.liquorice@gmail.com>
Co-committed-by: Hila Friedman <red.black.liquorice@gmail.com>
2026-04-02 15:11:24 +02:00
Jonathan Marler f4eecf8d7d handle EROFS in create/open file
I hit an unexpected errno 30 on macos attempting to call createFile on a
directory in PATH.  errno 30 is EROFS, this change propagates that error
as error.ReadOnlyFileSystem.
2026-04-02 15:05:31 +02:00
badayvedat 6cdd576d41 libzigc: fdim 2026-04-02 14:50:19 +02:00
Jacob Young 28ae5d4158 llvm: fix missing return attributes
Closes #31636
2026-04-02 14:31:12 +02:00
Jacob Young 4059242f44 x86_64: use correct alias for register constraints stored in registers
Closes #31722
2026-04-02 14:29:40 +02:00
Alex Rønne Petersen dd10d3fb52 libc-test: disable pthread_cancel-points.c
This test is racey if multiple instances of it run concurrently.
2026-04-02 12:33:19 +02:00