Commit graph

34243 commits

Author SHA1 Message Date
Andrew Kelley
8703053296 std.crypto: support for hashes without options 2025-07-30 17:22:42 -07:00
Andrew Kelley
18bc688471 std.crypto.Sha1: make it a Writer 2025-07-30 16:23:22 -07:00
Jackson Wambolt
eb1a4970da
Sema: check min/max operand types 2025-07-30 20:48:38 +00:00
Matthew Lugg
389ccf692a
Merge pull request #24278 from gooncreeper/atomic-fixes
atomic fixes and clarification
2025-07-30 21:30:29 +01:00
Krzysztof Wolicki
3d639481d9
Sema: disallow tags on non-auto unions when reifying (#23488) 2025-07-30 18:18:49 +00:00
Andrew Kelley
cf7a28febb std.Io.Reader: introduce readVec back into the VTable
simplifies and fixes things

addresses a subset of #24608
2025-07-30 09:26:34 -07:00
Alex Rønne Petersen
a9773944dc compiler: disable self-hosted x86_64 backend on OpenBSD
Same as 97ecb6c551 for NetBSD.
2025-07-30 17:17:22 +02:00
Justus Klausecker
6ec275ebd8 Sema: remove incorrect safety check for saturating left shift 2025-07-30 10:15:48 +01:00
Kurt Wagner
135a34c963 Update doc comment for ptr_type and ptr_type_bit_range to data of .extra_and_node
The other pointer types are `.opt_node_and_node` but `ptr_type` and `ptr_type_bit_range` contain `.extra_and_node` in their `data` field
2025-07-30 10:02:41 +01:00
Kendall Condon
cbe6e5b7fe langref: clarify allowed atomic types
Floats are not allowed in @cmpxchg

Packed structs are allowed for all atomic builtins
2025-07-30 09:56:38 +01:00
Kendall Condon
b0d6c227d3 Sema: catch error sets in atomic operations
also fix the struct test
2025-07-30 09:56:38 +01:00
Kendall Condon
f7dc9b50ab llvm: fix atomic widening of packed structs
Additionally, disable failing big-endian atomic test

also improve test paramaters to catch this when condition is removed

also some other cleanups
2025-07-30 09:56:38 +01:00
Techatrix
4a1594fbde update zig env to respect ZIG_LIB_DIR and support wasi 2025-07-30 09:45:03 +01:00
Andrew Kelley
1fcaf90dd3 std.Io.Reader: make fillUnbuffered respect prexisting buffer
addresses only one usage pattern in #24608
2025-07-29 23:10:50 -07:00
Matthew Lugg
8414638fb8
Sema: fixes (#24617)
* Sema: remove redundant comptime-known initializer tracking

This logic predates certain Sema enhancements whose behavior it
essentially tries to emulate in one specific case in a problematic way.
In particular, this logic handled initializing comptime-known `const`s
through RLS, which was reworked a few years back in 644041b to not rely
on this logic, and catching runtime fields in comptime-only
initializers, which has since been *correctly* fixed with better checks
in `Sema.storePtr2`. That made the highly complex logic in
`validateStructInit`, `validateUnionInit`, and `zirValidatePtrArrayInit`
entirely redundant. Worse, it was also causing some tracked bugs, as
well as a bug which I have identified and fixed in this PR (a
corresponding behavior test is added).

This commit simplifies union initialization by bringing the runtime
logic more in line with the comptime logic: the tag is now always
populated by `Sema.unionFieldPtr` based on `initializing`, where this
previously happened only in the comptime case (with `validateUnionInit`
instead handling it in the runtime case). Notably, this means that
backends are now able to consider getting a pointer to an inactive union
field as Illegal Behavior, because the `set_union_tag` instruction now
appears *before* the `struct_field_ptr` instruction as you would
probably expect it to.

Resolves: #24520
Resolves: #24595

* Sema: fix comptime-known union initialization with OPV field

The previous commit uncovered this existing OPV bug by triggering this
logic more frequently.

* Sema: remove dead logic

This is redundant because `storePtr2` will coerce to the return type
which (in `Sema.coerceInMemoryAllowedErrorSets`) will add errors to the
current function's IES if necessary.

* Sema: don't rely on Liveness

We're currently experimenting with backends which effectively do their
own liveness analysis, so this old trick of mine isn't necessarily valid
anymore. However, we can fix that trivially: just make the "nop"
instruction we jam into here have the right type. That way, the leftover
field/element pointer instructions are perfectly valid, but still
unused.
2025-07-30 04:04:06 +01:00
mlugg
08f1d63be1
disable more failing tests
Wow, *lots* of backends were reliant on Sema doing the heavy lifting for
them. CBE, Wasm, and SPIR-V have all regressed in places now that they
actually need to, like, initialize unions and such.
2025-07-29 22:44:01 +01:00
mlugg
0d482775cc
Sema: don't rely on Liveness
We're currently experimenting with backends which effectively do their
own liveness analysis, so this old trick of mine isn't necessarily valid
anymore. However, we can fix that trivially: just make the "nop"
instruction we jam into here have the right type. That way, the leftover
field/element pointer instructions are perfectly valid, but still
unused.
2025-07-29 15:52:19 +01:00
mlugg
d0bc5efba4
Sema: remove dead logic
This is redundant because `storePtr2` will coerce to the return type
which (in `Sema.coerceInMemoryAllowedErrorSets`) will add errors to the
current function's IES if necessary.
2025-07-29 15:52:19 +01:00
mlugg
b1dcf2b149
Sema: fix comptime-known union initialization with OPV field
The previous commit uncovered this existing OPV bug by triggering this
logic more frequently.
2025-07-29 15:52:19 +01:00
mlugg
a8888afcc0
Sema: remove redundant comptime-known initializer tracking
This logic predates certain Sema enhancements whose behavior it
essentially tries to emulate in one specific case in a problematic way.
In particular, this logic handled initializing comptime-known `const`s
through RLS, which was reworked a few years back in 644041b to not rely
on this logic, and catching runtime fields in comptime-only
initializers, which has since been *correctly* fixed with better checks
in `Sema.storePtr2`. That made the highly complex logic in
`validateStructInit`, `validateUnionInit`, and `zirValidatePtrArrayInit`
entirely redundant. Worse, it was also causing some tracked bugs, as
well as a bug which I have identified and fixed in this PR (a
corresponding behavior test is added).

This commit simplifies union initialization by bringing the runtime
logic more in line with the comptime logic: the tag is now always
populated by `Sema.unionFieldPtr` based on `initializing`, where this
previously happened only in the comptime case (with `validateUnionInit`
instead handling it in the runtime case). Notably, this means that
backends are now able to consider getting a pointer to an inactive union
field as Illegal Behavior, because the `set_union_tag` instruction now
appears *before* the `struct_field_ptr` instruction as you would
probably expect it to.

Resolves: #24520
Resolves: #24595
2025-07-29 15:52:19 +01:00
Jacob Young
3fbdd58a87 aarch64: implement scalar @mod 2025-07-28 22:23:19 -07:00
Kendall Condon
ecd3ea9bd2 DeprecatedReader.Adapted: fix EndOfStream handling 2025-07-28 21:41:19 -07:00
Silver
147a852806 Update zig init help with new -m arg
This was forgotten in #24555
2025-07-28 21:46:44 +01:00
Jacob Young
c334956a54 aarch64: workaround some optional/union issues 2025-07-28 09:03:17 -07:00
Ivan
dea3ed7f59
build: fix error in standalone test when using --release
Co-authored-by: Carl Åstholm <carl@astholm.se>
2025-07-28 08:10:23 +01:00
Andrew Kelley
bb29846732 std.compress.xz: eliminate dependency on std.Io.bitReader 2025-07-27 22:08:52 -07:00
Andrew Kelley
89cd42ee80
Merge pull request #24600 from jacobly0/aarch64
aarch64: continued progress
2025-07-27 11:42:09 -07:00
Jacob Young
b26e732bd0 aarch64: fix error union constants 2025-07-27 08:01:07 -04:00
Jacob Young
771523c675 aarch64: implement var args 2025-07-27 06:59:38 -04:00
Andrew Kelley
da408bd6fc
Merge pull request #24585 from jacobly0/aarch64
aarch64: more progress
2025-07-27 00:17:19 -07:00
A cursed quail
e12dc4947c std.zig: fmtId returns a FormatId
Changes fmtId to return the FormatId type directly, and renames the
FormatId.render function to FormatId.format, so it can be used in a
format expression directly.

Why? Since `render` is private, you can't create functions that wrap
`fmtId` or `fmtIdFlags`, since you can't name the return type of those
functions outside of std itself.

The current setup _might_ be intentional? In which case I can live with
it, but I figured I'd make a small contrib to upstream zig :)
2025-07-26 21:53:23 -07:00
Andrew Kelley
04614d6ea1 std.Io.Reader: add rebase to the vtable
This eliminates a footgun and special case handling with fixed buffers,
as well as allowing decompression streams to keep a window in the output
buffer.
2025-07-26 20:00:25 -07:00
Andrew Kelley
de39c5f67f
Merge pull request #24587 from jacobly0/x86_64
x86_64: fix some bugs
2025-07-26 18:41:29 -07:00
Jacob Young
7894703ee7 aarch64: implement more optional/error union/union support 2025-07-26 21:39:50 -04:00
Jacob Young
69abc945e4 aarch64: implement some safety checks
Closes #24553
2025-07-26 17:31:04 -04:00
Jacob Young
1274254c48 aarch64: implement stack probing 2025-07-26 16:08:40 -04:00
Jacob Young
7c349da49c aarch64: implement complex switch prongs 2025-07-26 16:08:40 -04:00
Matthew Lugg
a51cdf3b24
Merge pull request #22587 from castholm/deprecate-compile-apis
std.Build: Deprecate `Step.Compile` APIs that mutate the root module
2025-07-26 18:03:33 +01:00
mlugg
c9ce1debe7 Sema: exclude sentinel from source array length in pointer cast to slice
Resolves: #24569
2025-07-26 14:54:04 +01:00
Jacob Young
3194a4d22b x86_64: fix dst create alloc reg clobbering src
Closes #24390
2025-07-26 07:44:12 -04:00
Jacob Young
68cfa736df x86_64: fix switch on mod result
Closes #24541
2025-07-26 06:24:03 -04:00
Carl Åstholm
154bd2fd05 Migrate from deprecated Step.Compile APIs 2025-07-26 12:06:43 +02:00
Carl Åstholm
413179ccfc std.Build: Deprecate Step.Compile APIs that mutate the root module
Not only are `Step.Compile` methods like `linkLibC()` redundant because
`Module` exposes the same APIs, it also might not be immediately obvious
to users that these methods modify the underlying root module, which can
be a footgun and lead to unintended results if the module is exported to
package consumers or shared by multiple compile steps.

Using `compile.root_module.link_libc = true` makes it more clear to
users which of the compile step and the module owns which options.
2025-07-26 12:06:42 +02:00
Andrew Kelley
fc4b7c968a
Merge pull request #24564 from ziglang/terminal-progress-bar
std.Progress: support progress bar escape codes
2025-07-25 21:49:25 -07:00
Andrew Kelley
66e49d93b7
Merge pull request #24559 from ziglang/zstd
std: rework zstd for new I/O API
2025-07-25 20:02:53 -07:00
Andrew Kelley
9e11727c7c
Merge pull request #23340 from castholm/pass-null-to-b-dependency
Add support for passing null, string literals, enum lists and more to `b.dependency()`
2025-07-25 18:00:46 -07:00
Andrew Kelley
b22b9ebfe0 std.Progress: introduce Status 2025-07-25 17:33:11 -07:00
Andrew Kelley
799206a3ad std.Progress: support progress bar escape codes 2025-07-25 16:00:19 -07:00
Andrew Kelley
733b208256 std.posix.ftruncate: handle NonResizable properly 2025-07-25 14:15:33 -07:00
Andrew Kelley
8752d80c84 std.compress.zstd.Decompress: fix bytes_written tracking 2025-07-25 14:15:33 -07:00