Commit Graph

36542 Commits

Author SHA1 Message Date
Andrew Kelley 1b56686012 test-standalone: update cases to new main API 2026-01-04 00:27:08 -08:00
Andrew Kelley f2cf7b538f std.Io.Threaded: fix the child process error fd mechanism 2026-01-04 00:27:08 -08:00
Andrew Kelley 0ca83dd9d2 start: fix compilation with -lc on windows 2026-01-04 00:27:08 -08:00
Andrew Kelley 85fe35d246 compiler: fix -Denable-llvm compilation failures 2026-01-04 00:27:08 -08:00
Andrew Kelley f28802a9c6 zig libc: fix subcommand
This branch regressed the child process "run" mechanism because it
didn't pass the correct stdin, stdout, stderr values to process.spawn

Fixed now.
2026-01-04 00:27:08 -08:00
Andrew Kelley 960c512efd compiler: update std lib API usage 2026-01-04 00:27:08 -08:00
Andrew Kelley a6f519c20f std.process.Args: make toSlice require arena allocation
this simplifies the implementation, allows specializing it, and allows
deleting the corresponding free function. In practice this is how it is
always used anyway.
2026-01-04 00:27:08 -08:00
Andrew Kelley 1ccc87363a std: fixes for WASI 2026-01-04 00:27:08 -08:00
Andrew Kelley 50e185b718 start: tweak allocator choice
Favor DebugAllocator in Debug mode, even when linking libc. Prevent use
of smp_allocator when single_threaded
2026-01-04 00:27:08 -08:00
Andrew Kelley 0362d9f321 start: make leaks into warnings
I think it will be less confusing if memory leak checking doesn't change
the return code of the process.
2026-01-04 00:27:08 -08:00
Andrew Kelley 60447ea97c std: fix windows compilation errors 2026-01-04 00:27:08 -08:00
Andrew Kelley 08447ca47e std.fs.path: make relative a pure function
Instead of querying the operating system for current working directory
and environment variables, this function now accepts those things as
inputs.
2026-01-04 00:27:08 -08:00
Andrew Kelley b64491f2d6 compiler_rt: ensure no std.Io used when not testing 2026-01-04 00:27:08 -08:00
Andrew Kelley f9585ad01f update tests and tools to new main API 2026-01-04 00:27:08 -08:00
Andrew Kelley 9009ab2495 std.Io.Threaded: make environ init non-optional
and argv0 on systems that need it too.

fixes surprising behavior for applications that forget to initialize the
environment field.
2026-01-04 00:27:08 -08:00
Andrew Kelley de8c4cd64e compiler: update to new std.process APIs 2026-01-04 00:27:08 -08:00
Andrew Kelley f612464331 compiler: delete DarwinPosixSpawn
if this is reintroduced it will need to be part of the std.Io
implementation
2026-01-04 00:27:08 -08:00
Andrew Kelley 69d07472a1 std lib tests passing on linux 2026-01-04 00:27:08 -08:00
Andrew Kelley 3e6d6150d9 std.process.Environ: fix compile errors on POSIX 2026-01-04 00:27:08 -08:00
Andrew Kelley 384bfc5f99 std.Progress: go through Io interface for parent IPC mechanism
and fix start code
2026-01-04 00:27:08 -08:00
Andrew Kelley 42988fc5f4 std.process.Environ.Block: enhance type safety 2026-01-04 00:27:08 -08:00
Andrew Kelley b85524d0c8 std.process.Environ: fix contains function 2026-01-04 00:27:08 -08:00
Andrew Kelley 32af0f6154 std: move child process APIs to std.Io
this gets the build runner compiling again on linux

this work is incomplete; it only moves code around so that environment
variables can be wrangled properly. a future commit will need to audit
the cancelation and error handling of this moved logic.
2026-01-04 00:27:08 -08:00
Andrew Kelley d6a1e73142 std: start wrangling environment variables and process args
this commit is unfinished. It marks a spot where I wanted to start
moving child process stuff below the std.Io.VTable
2026-01-04 00:27:07 -08:00
Rue04 86a9a9048e std.MultiArrayList: add *Bounded variants and initCapacity
Because I accidentially squished two commit and can't figure out how to separate them
again, this also
- standardizes some doc-comments
- makes a slight change to `std.ArrayList`'s `initCapacity`'s doc-comment
2026-01-04 03:05:34 +01:00
Matthew Lugg 0cbaaa5eb9 std.Thread: stop clobbering syscall args
TL;DR: "r" considered harmful.

If LLVM chose registers badly, the inline asm which cleans up a thread
on Linux could, on all architectures other than x86_64, clobber either
`munmap` argument with the other argument *or* with the syscall number.
This would cause munmap to return EINVAL, and we would literally *never*
free the thread memory, which isn't ideal.

As it turns out, this was happening on MIPS, and was the cause of the
failures we've recently been seeing for that target: QEMU genuinely was
running out of memory (or at least, the virtualized address space was
getting too fragmented to map many contiguous pages). I've therefore
re-enabled a test which was disabled due to that flakiness.

This bug was accidentally fixed for x86_64 back in 2022 (see 59e33b447),
which probably helped it to go unnoticed for as long as it did!

Resolves: https://codeberg.org/ziglang/zig/issues/30216
2026-01-04 01:35:27 +01:00
Andrew Kelley a0a982f0ea std.crypto.kangarootwelve: disable flaky test
tracked by #30676
2026-01-03 16:27:09 -08:00
mlugg 8226d706e2 Merge pull request 'std.Io.Threaded: performance enhancements, bugfixes, and better Windows and NetBSD support' (#30634) from std.Io.Threaded-groups-2 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30634
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
Resolves: https://codeberg.org/ziglang/zig/issues/30049
2026-01-03 21:33:46 +01:00
Matthew Lugg 4de33579d8 incr-check: make sure to always show the target
Change the log implementation to prepend the current target and update
to all logs which happen during an update.

Makes progress on https://github.com/ziglang/zig/issues/22510, but does
not fully resolve it.
2026-01-03 15:45:11 +00:00
Matthew Lugg b3c498454b codegen.wasm: fix 64-bit saturating shl
Previously, 64-bit '<<|' operations were emitting 64-bit shifts with one
64-bit operand and one 32-bit operand, which is illegal. Instead, as in
the lowering for regular shifts, we need to cast the RHS in this case.
2026-01-03 15:45:11 +00:00
Matthew Lugg f7f0b9d28f std.http.test: fix memory leaks on OOM 2026-01-03 15:45:11 +00:00
Matthew Lugg 3bb2f7b84e std.Io.net: don't swallow 'error.Canceled'
This was missed when updating to the new group cancelation API, and
caused illegal behavior in many cases (the condition was simply that a
DNS query returned a second result before a connection was successfully
established).
2026-01-03 15:45:11 +00:00
Matthew Lugg f306a9f84a std: rebase fixups and cancelation changes
This commit includes some API changes which I agreed with Andrew as a
follow-up to the recent `Io.Group` changes:

* `Io.Group.await` *does* propagate cancelation to group tasks; it then
  waits for them to complete, and *also* returns `error.Canceled`. The
  assertion that group tasks handle `error.Canceled` "correctly" means
  this behavior is loosely analagous to how awaiting a future works. The
  important thing is that the semantics of `Group.await` and
  `Future.await` are similar, and `error.Canceled` will always be
  visible to the caller (assuming correct API usage).

* `Io.Group.awaitUncancelable` is removed.

* `Future.await` calls `recancel` only if the "child" task (the future
  being awaited) did not acknowledge cancelation. If it did, then it is
  assumed that the future will propagate `error.Canceled` through
  `await` as needed.
2026-01-03 15:45:11 +00:00
Matthew Lugg b8a09bcbd9 std.Io.Group: tweak documentation and vtable API 2026-01-03 15:45:11 +00:00
Matthew Lugg 2c395e326f std.Io.Threaded: always use robust cancelation
As of this branch, the performance impact of robust cancelation is now
negligible (and in fact entirely unmeasurable in almost all cases), so
there is no good reason to not enable it in all cases. The performance
issues before were primarily down to a typo in the robust cancelation
logic which resulted in every canceled syscall potentially being sent
hundreds of signals in quick succession, because the delay between
signals started out at 1ns instead of 1us!
2026-01-03 15:45:10 +00:00
Matthew Lugg f27134d671 std.Io: more tests 2026-01-03 15:45:10 +00:00
Matthew Lugg e57c557ad4 std.Io.Threaded: hugely improve Windows and NetBSD support
The most interesting thing here is the replacement of the pthread futex
implementation with an implementation based on thread park/unpark APIs.
Thread parking tends to be the primitive provided by systems which do
not have a futex primitive, such as NetBSD, so this implementation is
far more efficient than the pthread one. It is also useful on Windows,
where `RtlWaitOnAddress` is itself a userland implementation based on
thread park/unpark; we can implement it ourselves including support for
features which Windows' implementation lacks, such as cancelation and
waking a number of waiters with 1<n<infinity.

Compared to the pthread implementation, this thread-parking-based one
also supports full robust cancelation. Thread parking also turns out to
be useful for implementing `sleep`, so is now used for that on Windows
and NetBSD.

This commit also introduces proper cancelation support for most Windows
operations. The most notable omission right now is DNS lookups through
`GetAddrInfoEx`, just because they're a little more work due to having
a unique cancelation mechanism---but the machinery is all there, so I'll
finish gluing it together soon.

As of this commit, there are very few parts of `Io.Threaded` which do
not support full robust cancelation. The only ones which actually really
matter (because they could block for a prolonged period of time) are DNS
lookups on Windows (as discussed above) and futex waits on WASM.
2026-01-03 15:45:10 +00:00
Matthew Lugg a1d4120fd9 std.Io.Threaded: update to new internal syscall API 2026-01-03 15:45:10 +00:00
Matthew Lugg 0da5d5f150 std.Io.Threaded: rework cancelation and groups
The goal of this internal refactor is to fix some bugs in cancelation
and allow group tasks to clean up their own resources eagerly. The
latter will become a guarantee of the `std.Io` interface, which is
important so that groups can be used to "detach" tasks.

This commit changes the API which POSIX system calls use internally (the
functions formerly called `beginSyscall` etc), but does not update the
usage sites yet.
2026-01-03 15:45:07 +00:00
Matthew Lugg 04226193cc Revert "Use mmap std.heap.page_allocator impl when compiling for Wasm + libc"
This reverts commit c9fa8e46df.

This commit was failing CI checks. This failure was unfortunately not
noticed before merge, due in part to the build runner bug fixed in the
last commit.
2026-01-03 14:52:17 +00:00
Matthew Lugg d024d9f005 std.Build: crashes in the test runner are fatal errors 2026-01-03 14:52:11 +00:00
Carl Åstholm c9fa8e46df Use mmap std.heap.page_allocator impl when compiling for Wasm + libc
When linking libc, it should be the libc that manages the heap. The main
Wasm memory might have been configured as non-growable, which makes
`WasmAllocator` a poor default and causes the common `DebugAllocator`
use case fail with OOM errors unless the user uses `std_options` to
override the default page allocator. Additionally, on Emscripten,
growing Wasm memory without notifying the JS glue code will cause array
buffers to get detached and lead to spurious crashes.
2026-01-02 16:55:11 -08:00
jedisct1 1bf29757d9 Merge pull request 'crypto.edwards25519: optimize rejectLowOrder' (#30650) from jedisct1/zig:ed25519rej into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30650
2026-01-02 23:37:12 +01:00
e820 4cee1f7b9a Forgo const qualifiers on register locals generated by asm (#30645)
See https://codeberg.org/ziglang/zig/issues/30637 for details.

Works around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86673

Co-authored-by: Laurin-Luis Lehning <65224843+e820@users.noreply.github.com>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30645
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
Co-authored-by: e820 <e820@noreply.codeberg.org>
Co-committed-by: e820 <e820@noreply.codeberg.org>
2026-01-02 23:16:08 +01:00
Meghan Denny 53ebfde6b4 std: use decl literals to improve endian ergonomics 2026-01-01 20:34:55 -08:00
hixuyuming 0c5f879b98 Fix: tryFindProgram fails when $PATH contains relative paths (#30619)
Fixes a issue in tryFindProgram where it would fail if the PATH environment variable contained relative paths, due to its incorrect assumption that the full_path argument is always absolute path.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30619
Co-authored-by: hixuyuming <hixuyuming@gmail.com>
Co-committed-by: hixuyuming <hixuyuming@gmail.com>
2026-01-02 02:51:16 +01:00
Frank Denis 1baa127c65 crypto.edwards25519: optimize rejectLowOrder
Reject low-order points by checking projective coordinates directly
instead of using affine coordinates.

Equivalent, but saves CPU cycles (~254 field multiplications total
before, 3 field multiplications after).
2026-01-01 23:56:20 +01:00
Rick Calixte 2bd02883c7 git.zig: Process data packets of all lengths, discarding unrecognized packets
This addresses the regression specific to GitHub's chunked transfer encoding
for larger repositories while leaving existing functionality intact.
2026-01-01 20:37:52 +01:00
Ben Krieger 4ad8bc3413 Make Io.Mutex an extern struct 2025-12-31 16:40:34 -05:00
Steeve Morin 9d497d0d77 Update posix.getRandomBytesDevURandom to use linux.statx
Fixes #30631
2025-12-31 20:20:51 +01:00