Commit Graph

36606 Commits

Author SHA1 Message Date
Matthew Lugg 49f17237b0 compiler,std: remove a handful of redundant discards
I'm embarrassed to say I didn't realise until a few days ago that you
could omit the `_` capture for `if`/`while` on `E!void`...
2025-12-22 11:54:57 +00:00
Alex Rønne Petersen aa0249d74e Merge pull request 'std.ascii: rename indexOf functions to find' (#30101) from adria/zig:indexof-find into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30101
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
Reviewed-by: mlugg <mlugg@noreply.codeberg.org>
2025-12-22 12:50:46 +01:00
Doug Coleman 6b9125cbe6 build_runner: fix race condition in dispatch_deps capacity reservation
Move ensureUnusedCapacity inside the mutex call to prevent
a race condition where other worker threads could append to
memory_blocked_steps between checking the length and iterating.

repro branch: https://codeberg.org/erg/zig/src/branch/fix-30014-repro
check out that branch, and depending on if you have the fix-30014 patch or not,
it will either race condition or succeed

Fixes #30014
2025-12-21 20:11:05 -06:00
mlugg 8c5f731afb Merge pull request 'Some std.Io goodies' (#30235) from std.Io-misc into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30235
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
2025-12-21 14:50:58 +01:00
Matthew Lugg 67eed99550 std.Io.Queue: introduce closure and fix a bug
Queues can now be "closed". A closed queue cannot have more elements
appended with `put`, and blocked calls to `put` will immediately unblock
having failed to append some elements. Calls to `get` will continue to
succeed as long as the queue buffer is non-empty, but will then never
block; already-blocked calls to `get` will unblock.

All queue get/put operations can now return `error.Closed` to indicate
that the queue has been closed. For bulk get/put operations, they may
add/receive fewer elements than the minimum requested *if* the queue was
closed or the calling task was canceled. In that case, if any elements
were already added/received, they are returned first, and successive
calls will return `error.Closed` or `error.Canceled`.

Also, fix a bug where `Queue.get` could deadlock because it incorrectly
blocked until the given buffer was *filled*.

Resolves: #30141
2025-12-21 13:07:04 +00:00
Matthew Lugg fa7e818e14 std.Io: add new cancelation APIs
Also, better document how cancelation actually works.
2025-12-21 13:07:04 +00:00
Matthew Lugg 9bf65f6e05 std.Io.Threaded: replace ResetEvent with Io.Event 2025-12-21 13:07:04 +00:00
Matthew Lugg 0649f96da3 std.Io: introduce Event implemented using futex 2025-12-21 13:07:03 +00:00
Matthew Lugg b4ee54b580 std.Io: reimplement Mutex and Condition atop futex
This work was partially cherry-picked from Andrew's WIP std.fs branch.
However, I also analyzed and simplified the Mutex and Condition
implementations, and brought them in line with modern Zig style.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-12-21 13:07:03 +00:00
Matthew Lugg 6ed5b62050 std.Io: introduce futex primitives
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-12-21 13:07:03 +00:00
Matthew Lugg 330e295bc4 mailmap: add some addresses used by the Codeberg UI 2025-12-21 13:07:03 +00:00
Matthew Lugg 5611779f39 Sema: fix nested error union coercions
Previously, `E1!void` failed to coerce to `E2!E1!void` because it tried
to coerce the `E1` error to an `E2` if comptime-known and refused to
attempt any other coercion. This is a strange language rule with no
clear justification, and breaks real use cases (such as calling `getOne`
on an `Io.Queue(E!T)`). Instead, only error *sets* should try to coerce
to an "error" value of an error union type.
2025-12-21 13:07:03 +00:00
Matthew Lugg 3f08073f7d x86_64: hack around more OPV bugs
I would just fix this in Sema if it were easy to do so, but this is more
like a (minor) AIR data design issue than a straightforward Sema bug.
2025-12-21 13:07:00 +00:00
Alex Rønne Petersen b27bdd5af0 libc: add back freebsd bsm headers
Accidentally removed in #30135.
2025-12-21 03:54:17 +01:00
Prokop Randáček 442592855c change placeholder pattern in deduplicated type errors 2025-12-20 08:06:59 +01:00
Andrew Kelley 5fa7f13082 Merge pull request 'Windows: Avoid ever-expanding DeviceIoControl error set, handle NOT_A_REPARSE_POINT in ReadLink' (#30186) from squeek502/zig:win-deviceiocontrol into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30186
2025-12-19 18:50:27 +01:00
Alex Rønne Petersen f9419c81cf build: bump test-c-abi max_rss to 2_389_779_251 on x86_64-linux 2025-12-18 13:01:35 +01:00
Alex Rønne Petersen a6c22c5edb std.os.linux.test: disable fallocate on mips64*-linux-*abin32
https://codeberg.org/ziglang/zig/issues/30220
2025-12-18 12:56:28 +01:00
Alex Rønne Petersen 6b77bb3f91 build: bump test-compiler-rt max_rss to 978_463_129 on x86_64-linux 2025-12-18 11:42:42 +01:00
Alex Rønne Petersen 0437decca9 std.http.test: disable redirect to different connection on mips*-linux w/o libc
https://codeberg.org/ziglang/zig/issues/30216
2025-12-18 01:46:31 +01:00
Mick Sayson fc78a61c4c Prevent register clobbering on x86_64 threadlocal access
On the x86_64 self hosted backend, thread locals are accessed through
__tls_get_addr on PIC. Usually this goes through a fast path which does
not lose any registers, however in some cases (notably any dlopened
library on my machine) this can take a slow path which calls out to C
ABI functions

Catch this case and backup registers as necessary

Fix a few other ones while we're here. Credit to mlugg

Fixes #30183
2025-12-17 15:33:10 +01:00
Alex Rønne Petersen b9eefe17af test: fix up c3ee8078b4
Oops, accidentally didn't run the tests for 32-bit powerpc.
2025-12-16 09:01:51 +01:00
Alex Rønne Petersen 00903d35b1 std.Target: openbsd's landisk port is only little endian 2025-12-16 06:27:25 +01:00
Alex Rønne Petersen 447d6a0dd3 test: remove some nonsensical openbsd targets from llvm_targets 2025-12-16 06:25:32 +01:00
Alex Rønne Petersen b675223eb5 std: disable tests that depend on getFdPath on openbsd 2025-12-16 06:25:27 +01:00
Alex Rønne Petersen 215b250e6b std.posix.test: fix sigset tests on openbsd (no rt signals) 2025-12-16 06:25:21 +01:00
Alex Rønne Petersen da9733d441 compiler-rt: implement __clear_cache() for arm/mips64-openbsd 2025-12-16 06:25:15 +01:00
Alex Rønne Petersen 914005105e std.fs: fix build error in selfExePath() on openbsd 2025-12-16 06:25:10 +01:00
Alex Rønne Petersen 707e389f38 std.Io.Threaded: apply netbsd todo hacks to openbsd
https://codeberg.org/ziglang/zig/issues/30063
2025-12-16 06:25:07 +01:00
Alex Rønne Petersen 18db762bb8 std.c: openbsd does not have SIGRTMIN/SIGRTMAX 2025-12-16 06:24:58 +01:00
Alex Rønne Petersen 56add8374c std.c: remove comptime asserts of siginfo_t size
These serve no purpose other than to verify that the compiler is doing layout
correctly, and this is clearly not the place for that.
2025-12-16 06:24:54 +01:00
Alex Rønne Petersen 672ce9e919 compiler-rt: export __stack_chk_fail as __stack_smash_handler on openbsd 2025-12-16 06:24:49 +01:00
Alex Rønne Petersen 0564f83978 std.zig.target: remove two unused consts 2025-12-16 06:24:24 +01:00
Alex Rønne Petersen 00220a5ea1 build: add max_rss values observed on powerpc64le-linux 2025-12-16 06:23:20 +01:00
Alex Rønne Petersen 9f58931193 std.http: disable all tests on non-Debug powerpc64
https://github.com/llvm/llvm-project/issues/171879
2025-12-16 06:23:14 +01:00
Alex Rønne Petersen 647866dd63 std.math: disable hypot tests on non-Debug powerpc64
https://github.com/llvm/llvm-project/issues/171869
2025-12-16 06:23:11 +01:00
Alex Rønne Petersen 423d117251 test: skip bitcast nan float does not modify signaling bit on powerpc
This fails on a pwr10 machine.
2025-12-16 06:23:06 +01:00
Alex Rønne Petersen c3ee8078b4 test: skip some C ABI vector tests on powerpc
These fail on a pwr10 machine.
2025-12-16 06:23:01 +01:00
Alex Rønne Petersen eaae3f936b test: limit invalid_tail_call to x86_64-linux
Targets that don't support tail calls will see:

    /home/ci/zig/.zig-cache/o/35dbe82c8e4d49ae5b7d630329568133/tmp.zig:5:5: error: unable to perform tail call: compiler backend 'stage2_llvm' does not support tail calls on target architecture 'powerpc64le' with the selected CPU feature flags

So just run this test on a known-good target.
2025-12-16 06:22:51 +01:00
Alex Rønne Petersen f36949ead3 test: disable an error trace test on optimized powerpc64le 2025-12-16 06:22:46 +01:00
Alex Rønne Petersen d5e3c8a2aa compiler-rt: disable extenddftf2 test on powerpc
This fails on a pwr10 machine.
2025-12-16 06:22:40 +01:00
Alex Rønne Petersen 9373a963a1 langref: work around powerpc LLVM miscompilation in runtime_shrExact_overflow
https://github.com/ziglang/zig/issues/24304
2025-12-16 06:22:33 +01:00
Andrew Kelley 80b5917fad Merge pull request 'Bigint improvements' (#30100) from unplanned/zig:bigint-improvements into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30100
Reviewed-by: jedisct1 <jedisct1@noreply.codeberg.org>
2025-12-15 01:05:50 +01:00
Linus Groh 648c1c5d28 libc: Update macOS headers to SDK 26.2 2025-12-14 20:35:07 +00:00
Ryan Liptak 36cb5ea5f4 windows.ReadLink: handle NOT_A_REPARSE_POINT and add test 2025-12-14 07:12:38 -08:00
Ryan Liptak ea7512084b Make windows.DeviceIoControl return NTSTATUS instead of a Zig error
The number of possible errors in the theoretical error set of this function is very large, while each individual call to the function is only concerned with a (potentially small) subset of those errors that are specific to the control code being used. This commit makes the callers determine which statuses they are interested in to avoid an ever-ballooning error set and ever-growing switch cases at each call site that throw away most of those errors.
2025-12-14 07:12:38 -08:00
Alex Rønne Petersen 2f2b097576 Merge pull request 'Linux: Nuke Stat bits in favour of Statx' (#30122) from The-King-of-Toasters/zig:statx into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30122
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2025-12-14 05:25:29 +01:00
Stephen Gregoratto aec7bfb092 Linux: Dedupe generic decls
Commit #fc7a5f2 moved many of the `_t` types up a level, but didn't
remove them from arch_bits. Since `Stat` is gone, all but `time_t` can
be removed.
2025-12-14 01:41:47 +01:00
Stephen Gregoratto 6216922a9d Linux: Nuke Stat bits in favour of statx
Maintaining the POSIX `stat` bits for Zig is a pain. The order and
bit-length of members differ between all architectures, and int types
can be signed or unsigned. The libcs deal with this by introducing the
own version of `struct stat` and copying the kernel structure members to
it. In the case of glibc, they did it twice thanks to the largefile
transition!

In practice, the project needs to maintain three versions of `struct
stat`:
- What the kernel defines.
- What musl wants for `struct stat`.
- What glibc wants for `struct stat64`. Make sure to use `fstatat64`!

This isn't as simple as running `zig translate-c`. In #21440 I had to:
- Compile toolchains for each arch+glibc/musl combo.
- Create a test `fstat` program with/without `FILE_OFFSET_BITS=64`.
- Dump the value for `struct stat`.
- Stare at `std.os.linux`/`std.c` and cry.
- Add some missing padding.

The fact that so many target checks in the `linux` and `posix` tests
exist is most likely due to writing to padding bits and failing later.

The solution to this madness is `statx(2)`:
- It takes a single structure that is the same for all arches AND libcs.
- It uses a custom timestamp format, but it is 64-bit ready.
- It gives the same info as `fstatat(2)` and more!
- Unlike `fstatat(2)`, you can request a subset of the info required
  based on passing a mask.

It's so good that modern Linux arches (e.g. riscv) don't even implement
`stat`, with the libcs using a generic `struct stat` and copying from
`struct statx`.

Therefore, this commit rips out all the `stat` bits from `std.os.linux`
and `std.c`. `std.posix.Stat` is now `void`, and calling
`std.posix.*stat` is an compile-time error. A wrapper around `statx` has
been added to `std.os.linux`, and callers have been upgraded to use it.
Tests have also been updated to use `statx` where possible.

While I was here, I converted the mask and file attributes to be packed
struct bitfields. A nice side effect is checking that you actually
recieved the members you asked for via `Statx.mask`, which I have used
by adding `assert`s at specific callsites.
2025-12-14 01:41:47 +01:00
Stephen Gregoratto ff3fd950a7 Linux: Update Statx structure
Also removes the blank lines between members, and a comptime sizeOf
check.
2025-12-14 01:41:47 +01:00