Commit Graph
16665 Commits
Author SHA1 Message Date
Andrew Kelley 29717fefb8 start code: flatten and improve missing pub fn main message
better error message when the programmer omits `main` or fails to make
it public.

closes #37113
2026-10-15 09:47:43 -07:00
Andrew Kelley da32e05a1c Merge pull request '--fork fixes' (#37241) from fix-fork into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37241
2026-10-15 18:39:10 +02:00
mlarouche cb7a773ab8 ZON: Fix parsing from a specific node with fromZoir() (#37193)
Fix parsing a specific node with fromZoir() method by passing the wanted node to the inner functions.

Also added a test to make sure the use case gets tested.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37193
Reviewed-by: Mason Remaley <masonremaley@noreply.codeberg.org>
2026-10-15 15:07:27 +02:00
Mason Remaley 38dd6a68b7 Remove trailing newline after diagnostics
resolves #37071
2026-10-15 15:04:40 +02:00
Frank Denis bb5ba74ab1 Remove dead code in kangarootwelve
KeccakPlanes is not used any more in the current implementation.
2026-10-15 10:09:06 +02:00
Frank Denis b1ccf7eb1e Add core.keccak to the crypto.zig tests
The Keccak tests only ran indirectly via the sha3 functions,
but having that in the crypto.zig tests is convenient for
individual testing.
2026-10-15 10:09:06 +02:00
Frank Denis db5aa6cff7 crypto.keccak_p: allow arbitrary round numbers (still <= 24)
Round numbers that were not a multiple of 3 caused an OOB.

Nothing in the standard library uses a number of round that is
not 12 or 24, and these are the only values used in current
specifications.

But we should be future proof and we already provide an API
that's expected to work with any number of rounds, so honor that.
2026-10-15 10:09:06 +02:00
Frank Denis 23e2b25ca2 std.crypto: update fiat-crypto generated code
Zig was the first programming language to ship with field arithmetic
generated by fiat-crypto.

This is great! But since then, two things happened:
- We manually modified the generated code to deal with changes in Zig
- Fiat-crypto evolved, including its Zig backend
- Barriers turned out to be necessary to avoid memory loads depending
  on a secret selector. What we ship in Zig didn't had them.

So, reconciliate everything and update the code we ship with what
fiat now produces.

As a bonus, point multiplication on NIST curves gets ~10% faster.
2026-10-15 10:08:02 +02:00
Frank Denis 6f4477ffdc crypto.ecdsa: fix edge cases in DER encoding/decoding
An all-zero r or s component would try to encode an empty slice,
and panic. Not great.

When decoding, we accept integers shorter than the encoding
and pad them with zeros. Problem it that to check the sign,
we were always looking at the first byte, which in that case
was padding instead of the actual sign byte. This is now fixed.

And also reject integers with unnecessary leading zeros.

For example 02 02 00 01 was accepted, but the canonical
representation is 02 01 01. We should be strict and only accept
the canonical representation.
2026-10-15 10:05:32 +02:00
Frank Denis 5d5711e6fa crypto.ascon: fix incremental processing
In Ascon-AEAD128, we forgot a padding-only block after the AD.

And for the hash/XOF moes, we should keep track of the offset
between update() and squeeze() calls to make them equivalent to
a single-shot call, as in other hash functions/XOFs.
Otherwise the construction is not insecure, but the output
doesn't match the specification either.
2026-10-15 10:04:30 +02:00
Frank Denis 3ba52a1741 crypto.ml_dsa: reject invalid encodings of small secret polynomials
Packed coefficients have a limited valid range:
- With `eta = 2` (ML-DSA-44 and ML-DSA-87), 3-bit values must be
0...4. Values `5` through `7` are reserved.
- With `eta = 4` (ML-DSA-65), 4-bit must be values 0...8. Values
9 through 15 are reserved.

We were previously accepting reserved values, allowing malformed
secret key encodings.

This is not a security issue (secret keys are trusted anyway),
and the specification doesn't require these coefficients to be
checked. In fact, most implementations including the reference
implementations currently don't do it.

But:
1) the Zig crypto implementations generally try to be strict for
validation
2) the checks are very cheap
3) this makes sure the invariants are enforced
4) SecretKey.fromBytes() already allows returning an error, so
this is not really an API change
5) OpenSSL, BoringSSL and Go reject these encodings.
2026-10-15 10:03:55 +02:00
Andrew Kelley 9343d0fe4b std.Build.Cache: fix cache miss when metadata changes
adds test for "changed metadata of input file but same digest causes hit"

closes #37200
2026-10-15 08:17:27 +02:00
Andrew Kelley f6a00a4751 Maker: guard project id construction with have_manifest 2026-10-14 19:00:42 -07:00
Andrew Kelley 6cecad145d Maker: fix use case when --fork matches 2 or more pkgs
Previously this always caused a compilation failure because it would
correctly substitute multiple packages with the provided forked package,
however, this ends up constructing a zig build-exe command line for the
configurer that included multiple differnt modules that used the same
files.

Closes #31677
2026-10-14 17:42:15 -07:00
Andrew Kelley 5b4e91bc39 Maker: --print-tree supports paths and forks 2026-10-14 17:42:15 -07:00
Andrew Kelley 35c2541cf9 Maker: exempt forked packages from validateFingerprints
because they intentionally override multiple packages hashes to have the
forked contents.
2026-10-14 17:42:15 -07:00
Andrew Kelley 4a0cadf85b Fetch: slightly more helpful debug log when forking 2026-10-14 17:42:15 -07:00
Elaine Gibson d893812013 Maker: fix build when Watch.have_impl is false 2026-10-14 20:49:25 +02:00
John Benediktsson ea7667f5a5 compiler_rt: fix fma rounding and add regression tests 2026-10-14 09:24:42 +02:00
Andrew Kelley c22d99a3b2 Merge pull request 'std.Io.Threaded: handle unsupported renamePreserveLinux' (#37210)
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37210
2026-10-14 09:21:35 +02:00
Andrew Kelley cdd6e545cc std.Io.Threaded: handle unsupported renamePreserveLinux
with link/unlink fallback. closes #31960
2026-10-13 13:26:23 -07:00
Andrew Kelley 32534ecae6 Merge pull request 'package management: --help enhancement, --print-tree, and validate package hash consistency' (#37214) from build-print-tree into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37214
2026-10-13 20:45:10 +02:00
Andrew Kelley 0c54ae3c0e zig build: validate package hash consistency
Any time the same package (based on fingerprint) appears in the
dependency tree, if the semantic version compares equal, the hash must
be identical, otherwise one of three things has gone wrong and the
maintainer must address it.
2026-10-12 20:34:17 -07:00
Andrew Kelley 89ec7145f1 Maker: check for --fetch after --print-tree 2026-10-12 18:46:50 -07:00
Andrew Kelley 2551cf283f zig build: add --configure flag, change --fetch flag
--fetch is changed to mean:
> Fetch all dependencies including lazy ones; exit without configuration

--configure is introduced (replaces old `--fetch` semantics):
> Exit after the configuration phase
2026-10-12 18:28:07 -07:00
Andrew Kelley 2f60a88308 zig build: add --print-tree CLI option
for writing the current state of package dependencies to stdout, without
running configuration.
2026-10-12 18:05:37 -07:00
Andrew Kelley c8160b8a2e Maker: --help works even when configuration fails 2026-10-12 17:45:44 -07:00
Lateef Jackson 59f1471306 On Linux the system call of renameat2 return an INVAL error. This is not
a bug it should map to which should OperationUnsupported error is
a better fit to the system call response.
2026-10-12 22:10:54 +02:00
kernelnomad 85e2896e17 std.Io.net.Ip4Address: fix fromAny return type 2026-10-12 20:13:05 +02:00
Amilia MacIntyre 310a579efc std.http: improve tolerance of request-body edge cases 2026-10-12 20:08:17 +02:00
Alex Rønne Petersen faf8bbf5b1 std.Target: add standard dynamic linker paths for managarm 2026-10-12 14:59:18 +02:00
Alex Rønne Petersen 963d4466d5 std.Target: remove contiki OS tag
Contiki-NG is really more like a freestanding library for driving MCUs and
peripherals; it's not an OS with an ABI as such. So a dedicated OS tag isn't
really doing anything useful over `freestanding`.
2026-10-12 14:43:32 +02:00
Alex Rønne Petersen 7a7b944ef8 std.Target: remove hermit OS tag
Hermit is a unikernel with no stable syscall ABI; you must link its syscall
library statically to perform syscalls. Due to the way the project's build
system works, that means using Rust/Cargo. As such, it makes essentially zero
sense for Zig to support this target.
2026-10-12 14:35:23 +02:00
Alex Rønne Petersen 05671ced91 std.hash_map: fix compile error in removeByPtr() 2026-10-12 12:49:48 +02:00
Andrea Vaccaro 7aadd325d1 value from ptr is never modified 2026-10-12 11:16:34 +02:00
Guy Fischman 070276d8f1 compiler: add x86_64, aarch64, riscv, and loongarch preserve_most calling convention support 2026-10-12 10:49:23 +02:00
Alex Rønne Petersen ccdb1afa6e Merge pull request 'compiler-rt: ELF static TLS fixes' (#37186) from alexrp/zig:tls-fixes into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37186
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-10-12 10:27:24 +02:00
Alex Rønne Petersen 993c758456 Merge pull request 'Elf2: more SPARC relocations' (#37191) from alexrp/zig:elf2-sparc into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37191
2026-10-12 10:26:39 +02:00
Frank Denis bfb20fe216 crypto.ff: specialize full-width Montgomery multiplication
When the modulus takes its full limb capacity, we can take
advantage of the fact that this is a comptime value to get
specialized code with better vectorization.

Also avoid expensive copies.

This is all internal; no changes to the public APIs.
2026-10-12 09:55:45 +02:00
Frank Denis a1363b3b5a crypto.ff: avoid code duplication
Modular addition uses the same code in plain and Montgomery
representations, so factor it.

Computation of m0inv can also be in a dedicated function.

This improves clarity, but this is also something that we'll need
for working with a secret modulus, so that will avoid code
duplication as well.
2026-10-12 09:54:52 +02:00
Andrew Kelley eee0e6d70e Merge pull request 'Io.Threaded: a few Windows stat fixes' (#37174) from squeek502/zig:misc-windows-fixes into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37174
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-10-11 19:43:20 +02:00
Alex Rønne Petersen 72e0d1cd27 std.debug.cpu_context: signal context conversion for sparc*-netbsd/openbsd 2026-10-11 15:00:48 +02:00
Alex Rønne Petersen 6c3be9e0e7 compiler_rt.elf.tls: fix a couple of bugs in __tls_get_addr() and __tls_get_offset()
* We need to add current_dtv_offset in __tls_get_addr() because we aren't
  reading the actual DTV entry (where that value would be baked in).
* In both __tls_get_addr() and __tls_get_offset(), we need to subtract
  area_info.abi_tcb.offset rather than area_info.block.size because we apply
  align_factor to the block size when computing the area layout.
2026-10-11 10:45:45 +02:00
Alex Rønne Petersen 19e06b06dd compiler_rt.elf.tls: add __m68k_read_tp() which is used by compilers 2026-10-11 10:45:45 +02:00
Alex Rønne Petersen dae7c7c466 compiler_rt.elf.tls: add ___tls_get_addr() which is used by 32-bit x86
As per usual, we have GNU to thank.
2026-10-11 10:10:15 +02:00
Alex Rønne Petersen c692aced23 compiler_rt.elf.tls: fix potential underflow if PT_TLS p_align is zero
Very unlikely with any sane linker, but technically allowed.
2026-10-11 10:10:04 +02:00
Alex Rønne Petersen 8b06537d92 compiler_rt.elf.tls: fix AbiTcb for arc and csky
Also simplify the logic since it turns out to really just depend on the variant.
2026-10-11 09:23:44 +02:00
Jonathan Marler 9276a56e3c std.Io.Threaded: map LOCAL_DISCONNECT to ConnectionResetByPeer on Windows
netReadWindows and netWriteWindows returned error.Unexpected when AFD
reported STATUS_LOCAL_DISCONNECT. I was able to produce this error in
both the read and write paths locally.

Partial fix of #31956
2026-10-10 20:00:54 +02:00
Andrew Kelley 9449bac422 Merge pull request 'Io.Uring fixes & updates' (#37172) from sinon/zig:iouring-fixes into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37172
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-10-10 19:47:29 +02:00
Giuseppe Cesarano 44e5319107 Remove extern from Io.Mutex (#37081)
An `Io.Mutex` is bound to the Io implementation used to lock and unlock it: having it cross Io implementations could already be an abuse of the API. C code is even further removed, since it has no `Io` at all and could never meaningfully interact with an `Io.Mutex`, so making it `extern` doesn't buy us anything. The only thing we actually gain is less boilerplate when the user needs to protect a struct that is also used from C, where the C side doesn't need the synchronization. I would argue that's not a strong enough reason to keep it `extern`, since the same behavior can be achieved with composition.

Being `extern` also conflicts with adding safety features to the implementation: their size would change with the compilation configuration, which defeats the purpose of `extern`.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/37081
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-10-10 19:11:35 +02:00