8318 Commits

Author SHA1 Message Date
Matthew Lugg 21b42af5aa tests: update for accepted language change
`@sizeOf` and `@bitSizeOf` are now more restricted: they are not allowed
on comptime-only or NPV (uninstantiable) types. This is because there is
no correct way to actually use the returned ABI size (e.g. you cannot
copy a comptime-only type by copying all of its runtime bits), so having
a non-zero return value had no benefit and was simply confusing.
2026-03-10 10:26:10 +00:00
Matthew Lugg f9183edf08 tests: update for accepted language change
`packed struct`s and `packed union`s can no longer contain pointer
fields. There are a few reasons for this, but in particular, binary
formats do not typically support the relocation types we would need to
lower such values into static memory. See the proposal at
https://github.com/ziglang/zig/issues/24657 for details.
2026-03-10 10:26:10 +00:00
Matthew Lugg da2006a38c tests: unions without fields need not store their tag at runtime
...because the union semantically has no possible value so cannot be
stored to or loaded from memory anyway.
2026-03-10 10:26:10 +00:00
Matthew Lugg 4f7344dec0 tests: update for accepted language change
Unions with no fields are now "uninstantiable" types, which work like
`noreturn` in that values of this type cannot exist. Enums with no
fields are different because they are currently considered `extern`
types, though https://github.com/ziglang/zig/issues/19855 will change
this in the future.
2026-03-10 10:26:10 +00:00
Matthew Lugg 96d6b22067 tests: update for accepted language change
'comptime_int' is no longer considered a valid backing type for an enum.
In other words, 'enum(comptime_int)' is a compile error. This change is
accepted to simplify the language.
2026-03-10 10:26:09 +00:00
Matthew Lugg 1826ba69d8 compiler: make dependency loop errors good 2026-03-10 10:26:09 +00:00
Andrew Kelley 80625990d5 std: different mechanism for disabling network dependency
On Windows, it is sometimes problematic to depend on ws2_32.dll. Before,
users of std.Io.Threaded would have to call ioBasic() rather than io()
in order to avoid unnecessary dependencies on ws2_32.dll. Now, the
application can disable networking with std.Options.

This change is necessary due to moving networking functionality to
be based on Io.Operation, which is a tagged union.
2026-03-08 19:20:34 -07:00
Ryan Liptak 6be202f466 Io: Add processSetCurrentPath
The logic used to allow providing a path for setting the CWD of a child process in https://codeberg.org/ziglang/zig/pulls/31090 applies here as well:

- Windows must provide a path when setting the CWD, so the path of an `Io.Dir` must be resolved before actually calling RtlSetCurrentDirectory_U
- A directory handle may have multiple paths associated with it, so providing the CWD as a string retains a legitimate use case in cases where the precise path matters
2026-03-09 03:19:11 +01:00
Alex Rønne Petersen 5a176d57b6 test/llvm_targets.zig: fix a typo 2026-03-08 02:01:26 +01:00
Justus Klausecker 933bfd4282 tests: pass on -Dsanitize-thread to unit tests 2026-03-06 10:09:06 +01:00
Alex Rønne Petersen f75e4027bd test: disable an error trace test on optimized aarch64-netbsd 2026-03-02 15:08:37 +01:00
Alex Rønne Petersen bf13b6b41d test: partially disable cmakedefine standalone test
https://codeberg.org/ziglang/zig/issues/31368
2026-03-01 11:53:05 +01:00
Alex Rønne Petersen b781615e09 test: disable an error trace test on optimized aarch64-freebsd 2026-02-27 08:49:27 +01:00
Andrew Kelley e0173c2ce0 Merge pull request 'rework fuzz testing to be smith based' (#31205) from gooncreeper/zig:integrated-smith into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31205
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-02-25 20:23:36 +01:00
Justus Klausecker 360bc28c96 fix cmpxchg behavior test
This has to be a `@cmpxchgStrong` instead of a `@cmpxchgWeak` otherwise
this test will fail spuriously on LL/SC architectures like PowerPC.
2026-02-23 21:13:26 +01:00
Kendall Condon 5d58306162 rework fuzz testing to be smith based
-- On the standard library side:

The `input: []const u8` parameter of functions passed to `testing.fuzz`
has changed to `smith: *testing.Smith`. `Smith` is used to generate
values from libfuzzer or input bytes generated by libfuzzer.

`Smith` contains the following base methods:
* `value` as a generic method for generating any type
* `eos` for generating end-of-stream markers. Provides the additional
  guarantee `true` will eventually by provided.
* `bytes` for filling a byte array.
* `slice` for filling part of a buffer and providing the length.

`Smith.Weight` is used for giving value ranges a higher probability of
being selected. By default, every value has a weight of zero (i.e. they
will not be selected). Weights can only apply to values that fit within
a u64. The above functions have corresponding ones that accept weights.
Additionally, the following functions are provided:
* `baselineWeights` which provides a set of weights containing every
  possible value of a type.
* `eosSimpleWeighted` for unique weights for `true` and `false`
* `valueRangeAtMost` and `valueRangeLessThan` for weighing only a range
  of values.

-- On the libfuzzer and abi side:

--- Uids

These are u32s which are used to classify requested values. This solves
the problem of a mutation causing a new value to be requested and
shifting all future values; for example:

1. An initial input contains the values 1, 2, 3 which are interpreted
as a, b, and c respectively by the test.

2. The 1 is mutated to a 4 which causes the test to request an extra
value interpreted as d. The input is now 4, 2, 3, 5 (new value) which
the test corresponds to a, d, b, c; however, b and c no longer
correspond to their original values.

Uids contain a hash component and type component. The hash component
is currently determined in `Smith` by taking a hash of the calling
`@returnAddress()` or via an argument in the corresponding `WithHash`
functions. The type component is used extensively in libfuzzer with its
hashmaps.

--- Mutations

At the start of a cycle (a run), a random number of values to mutate is
selected with less being exponentially more likely. The indexes of the
values are selected from a selected uid with a logarithmic bias to uids
with more values.

Mutations may change a single values, several consecutive values in a
uid, or several consecutive values in the uid-independent order they
were requested. They may generate random values, mutate from previous
ones, or copy from other values in the same uid from the same input or
spliced from another.

For integers, mutations from previous ones currently only generates
random values. For bytes, mutations from previous mix new random data
and previous bytes with a set number of mutations.

--- Passive Minimization

A different approach has been taken for minimizing inputs: instead of
trying a fixed set of mutations when a fresh input is found, the input
is instead simply added to the corpus and removed when it is no longer
valuable.

The quality of an input is measured based off how many unique pcs it
hit and how many values it needed from the fuzzer. It is tracked which
inputs hold the best qualities for each pc for hitting the minimum and
maximum unique pcs while needing the least values.

Once all an input's qualities have been superseded for the pcs it hit,
it is removed from the corpus.

-- Comparison to byte-based smith

A byte-based smith would be much more inefficient and complex than this
solution. It would be unable to solve the shifting problem that Uids
do. It is unable to provide values from the fuzzer past end-of-stream.
Even with feedback, it would be unable to act on dynamic weights which
have proven essential with the updated tests (e.g. to constrain values
to a range).

-- Test updates

All the standard library tests have been updated to use the new smith
interface. For `Deque`, an ad hoc allocator was written to improve
performance and remove reliance on heap allocation. `TokenSmith` has
been added to aid in testing Ast and help inform decisions on the smith
interface.
2026-02-13 22:12:19 -05:00
Kendall Condon 5b9bb0a404 add -Dfuzz-only
Runs only one configuration suitable for fuzzing.
2026-02-13 17:58:09 -05:00
kj4tmp@gmail.com 3dc2a1f9ac zig libc: acosf 2026-02-13 11:30:14 -08:00
Andrew Kelley 0de7668c01 test harness: refmt for readability 2026-02-12 13:14:51 -08:00
GasInfinity a6f64096a1 chore(test/standalone): test linking libc in a shared library 2026-02-11 15:48:18 +01:00
Jacob Young b5bd494606 std.Threaded: replace more kernel32 functions with ntdll 2026-02-07 00:02:50 -05:00
Ryan Liptak bcb5218a2b Environ: reinstate null return on = in environment variable keys
Changes an assert back into a conditional to match the behavior of `getPosix`, see https://codeberg.org/ziglang/zig/pulls/31113#issuecomment-10371698 and https://github.com/ziglang/zig/issues/23331.
Note: the conditional has been updated to also return null early on 0-length key lookups, since there's no need to iterate the block in that case.

For `Environ.Map`, validation of keys has been split into two categories: 'put' and 'fetch', each of which are tailored to the constraints that the implementation actually relies upon. Specifically:
- Hashing (fetching) requires the keys to be valid WTF-8 on Windows, but does not rely on any other properties of the keys (attempting to fetch `F\x00=` is not a problem, it just won't be found)
- `create{Posix,Windows}Block` relies on the Map to always have fully valid keys (no NUL, no `=` in an invalid location, no zero-length keys), which means that the 'put' APIs need to validate that incoming keys adhere to those properties.
The relevant assertions are now documented on each of the Map functions.

Also reinstates some test cases in the `env_vars` standalone test. Some of the reinstated tests are effectively just testing the Environ.Map implementation due to how `Environ.contains`, `Environ.getAlloc`, etc are implemented, but that is not inherent to those functions so the tests are still potentially relevant if e.g. `contains` is implemented in terms of `getPosix`/`getWindows` in the future (which is totally possible and maybe a good idea since constructing the whole map is not necessary for looking up one key).
2026-02-05 20:24:31 +01:00
Andrew Kelley 2a193a3987 std: move GetFinalPathNameByHandle to Io.Threaded
unfortunately this function calls NtCreateFile so it has to participate
in cancelation
2026-02-04 16:27:13 -08:00
Jacob Young ffc6da29e3 std.Io.Threaded: implement and cleanup windows codepaths 2026-02-04 14:15:41 -05:00
Alex Rønne Petersen fce7878a91 test: disable hexagon-linux-musl C ABI tests for now
https://gitlab.com/qemu-project/qemu/-/issues/3291
2026-02-04 11:11:39 +01:00
Alex Rønne Petersen 2fce12b42a test: improve logic for generating stack trace test combinations 2026-02-03 20:19:15 +01:00
Ryan Liptak 05346e123b Add process.Child.Cwd, use it for cwd and remove cwd_dir field
The user must now explicitly choose between inheriting the current CWD, passing a path for the CWD, or passing a Dir for the CWD.
2026-02-02 01:41:35 -08:00
Jeff Anderson 379d128cba libzigc: roundf 2026-01-31 18:18:29 -08:00
Jeff Anderson 69a95571ed libzigc: round 2026-01-31 17:26:17 -08:00
kj4tmp@gmail.com e60ba21114 libzigc: roundl 2026-02-01 00:59:35 +01:00
Andrew Kelley b1d1806fef std.process: currentDir -> currentPath
In Zig standard library, Dir means an open directory handle. path
represents a file system identifier string. This function is better
named after "current path" than "current dir". "get" and "working" are
superfluous.
2026-01-29 18:47:58 -08:00
Andrew Kelley 649aaf4814 std: migrate getcwd to Io
progress towards #30150
2026-01-29 18:40:55 -08:00
Andrew Kelley 9b415761dd std.os.windows: delete unused APIs
Intention is to go through std.Io for these things.
2026-01-30 03:39:46 +01:00
Andrew Kelley 5571c08e66 add behavior test for i96 operations 2026-01-29 19:57:36 +01:00
Andrew Kelley 4d6f4e9cfd behavior: add coverage for extern struct field overalignment 2026-01-29 19:56:46 +01:00
Ryan Liptak 1655a666d5 windows_resources standalone test: Load a resource and check its data
Just a potential way to catch regressions and to ensure the resources actually make it into the binary correctly.
2026-01-27 20:48:59 +01:00
Alex Rønne Petersen e437efd601 test: enable thumb-windows-gnu module tests
We use long calls for these just like thumb*-linux-* to prevent range issues as
the binaries grow larger over time.

We also need function and data sections due to the many __stack_chk_guard
references within the std test binary; without these options, the linker is not
able to insert range thunks in between functions because the std binary just has
one giant .text section that's opaque to the linker.

closes https://codeberg.org/ziglang/zig/issues/30923
2026-01-23 21:16:03 +01:00
Alex Rønne Petersen 200fb7c2ac test-libc: disable raise-race.c 2026-01-21 18:51:02 +01:00
Alex Rønne Petersen 34aa1bb94f test-libc: enable loongarch64-linux-muslsf 2026-01-21 17:53:38 +01:00
Alex Rønne Petersen eb3f16db5e test: clarify that self_exe_symlink fails on NetBSD due to bad F_GETPATH
closes https://codeberg.org/ziglang/zig/issues/30841
2026-01-21 16:42:17 +01:00
Adrià Arrufat 77919ee735 Sema: allow @round, @floor, @ceil, and @trunc to coerce to integer types
This effectively renders @intFromFloat redundant, as it is semantically
equivalent to @trunc when used in a context expecting an integer.
2026-01-21 12:23:50 +09:00
Mathias Lafeldt 2207c62bb5 MachO: fix dynamic lookup of undefined symbols at runtime
Ensures `MH_NOUNDEFS` is not set when dynamic lookup is enabled for
undefined symbols via `linker_allow_shlib_undefined`.
2026-01-21 00:31:21 +01:00
rpkak e6ac1b77f0 libzigc: test and fix acos 2026-01-20 18:02:15 +01:00
Alex Rønne Petersen ac793232ee test: skip non-libc module tests for targets that require or default to libc
We were just creating duplicate work and breaking -Dskip-libc.
2026-01-19 13:16:25 +01:00
Alex Rønne Petersen b1b234daa0 test: disable self_exe_symlink standalone test on NetBSD
https://codeberg.org/ziglang/zig/issues/30841
2026-01-19 13:16:16 +01:00
Alex Rønne Petersen 016255ad09 test: disable an error trace test on optimized x86_64-netbsd 2026-01-19 13:16:11 +01:00
Vladislav Shabanov 63f345a75a link.MachO: support sdata4 pointer encoding (#30846)
Fixes https://codeberg.org/ziglang/zig/issues/30669

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30846
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Vladislav Shabanov <vshabanov88@gmail.com>
Co-committed-by: Vladislav Shabanov <vshabanov88@gmail.com>
2026-01-15 19:48:16 +01:00
Justus Klausecker 044ba3e0b0 Sema: fix single-range switch prong capture (for real this time)
e2338edb47 didn't *quite* do it, the call sites of all switch prong related
functions now have to do their part too and be a little more precise about
what kind of prong they're currently analyzing.

Also removes some unused/unnecessary stuff.
2026-01-13 06:03:07 +01:00
Justus Klausecker e2338edb47 Sema: fix single-range switch prong capture
This kind of capture cannot always be comptime-known, assuming so caused
access of undefined memory during payload capture analysis!
2026-01-11 20:22:32 +01:00
Matthew Lugg 01546e68cd compiler: handle switch rewrite review feedback 2026-01-11 14:37:28 +00:00