13847 Commits

Author SHA1 Message Date
Alex Rønne Petersen e949341b70 Revert "std.os.linux: fix kernel_timespec.nsec to be isize"
This reverts commit af88310caf.

I conflated __kernel_timespec with __kernel_old_timespec. i64 is correct.
2026-06-20 11:12:45 +02:00
Ali Cheraghi 3a48f4bb40 spirv: drive capability and extension emission from target features
- Emitting `OpCapability` and `OpExtension` from assembly is no longer allowed (tbh it never was because we silently ignored them).
  They now `fail` with a message pointing users at `-mcpu`.

- `tools/gen_spirv_spec.zig` now also emits `Extension` and the `Capability.dependencies()`.
  Also To keep the feature set a reasonable size, the generator filters to an allowlist of `KHR` and `EXT` entries.
  We can decide which vendors to allow later if a use-case is found.

- `tools/update_cpu_features.zig` now uses the generated `spec.zig` and emits a  feature for every
  capability and extension, with the capability's `.deps` populated from `Capability.dependencies()`.

- `Module.finalize`, `Module.entryPoints`, `Module.addCapability`, `Module.addExtension`
  and `sections.capabilities`/`sections.extensions` are deleted.

- Linker now verifies that an `.spv` object declares the `Linkage` capability
2026-06-20 09:38:20 +02:00
Alex Rønne Petersen ae3ab88153 std.os.linux.x32: fix read of stack slot containing ctid in clone()
It's a 32-bit pointer and passed on the stack; the upper 32 bits of the stack
slot are garbage. This means that we ask the kernel to write to some random
64-bit location, which it will just silently fail to do (the process is in x32
mode; nothing can be mapped up there), and consequently, the thread's child_tid
field will never be populated, causing a later join() to hang.
2026-06-19 08:25:49 +02:00
Alex Rønne Petersen eed6464426 std.os.linux.x32: use 64-bit time_t 2026-06-19 06:02:24 +02:00
Alex Rønne Petersen fe9f2c7d1a std.os.linux: use kernel_timespec on x32 2026-06-19 06:02:24 +02:00
Alex Rønne Petersen af88310caf std.os.linux: fix kernel_timespec.nsec to be isize
Only kernel_timespec.sec should be unconditionally i64.
2026-06-19 05:59:21 +02:00
Leon Lombar 84f84267c7 std.Target: add PSX
Adds target info for the PSX. Builds fine with the following:
```zig
const target = b.resolveTargetQuery(.{
    .os_tag = .psx,
    .cpu_arch = .mipsel,
});
```
the only "problem" being that it spits out an error from LLVM even
though generating an object file succeeds:
```sh
❯ zig build
install
└─ install generated to main.o
   └─ compile obj obj Debug mipsel-psx failure
error: warning: MIPS-I support is experimental
```
2026-06-19 04:22:55 +02:00
Ali Cheraghi 65e74dfbda @extern: add flat decoration 2026-06-18 13:38:58 +02:00
Ali Cheraghi c9ca79fb48 std.spirv: add Scope, MemorySemantics, and barrier primitives
Exposes OpControlBarrier and OpMemoryBarrier so compute kernels do not
need to hand-roll inline asm for workgroup synchronisation. Scope and
MemorySemantics mirror the SPIRV-Headers unified1 grammar bit-for-bit;
workgroupBarrier() matches the semantics of GLSL barrier().

Co-authored-by: Quint Daenen <quint@daenen.email>
2026-06-18 13:38:58 +02:00
Alex Rønne Petersen cfeab92587 Merge pull request 'add full support for libc-less x86_64-linux-x32 and mips64(el)-linux-abin32' (#35828) from alexrp/zig:x32-n32 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35828
2026-06-18 12:45:27 +02:00
Alex Rønne Petersen 49f8996e1e std.os.linux.mipsn32: fix oversized loads in clone() 2026-06-18 04:29:24 +02:00
Alex Rønne Petersen 2681d4abc3 std.debug.Dwarf.expression: fix a couple of failing tests on x32/n32
The upper half of the register was left undefined on these ABIs, causing an
@intCast inside the stack machine to fail.
2026-06-18 03:59:15 +02:00
Alex Rønne Petersen 6aaea5af41 std.Target: add abin32 and x32 Abi tags
We only had gnu/musl variants of these previously.
2026-06-18 02:37:52 +02:00
rpkak ea73defb5c Writer.writeBytePreserve: preserve only 'preserve -| 1' already buffered bytes 2026-06-18 02:31:42 +02:00
Alex Rønne Petersen 18d5cd67ce std.Target: default to gnu ABI for alpha, or1k, sparc, sparc64
There's no musl port for any of these.
2026-06-18 01:37:52 +02:00
carmooo 4f72106c85 Add zip.extractTo test cases (#35748)
Co-authored-by: carmooo <joao.carmo@paddle.com>
Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35748
Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>
2026-06-17 23:22:55 +02:00
Jari Vetoniemi 7255f3e724 std.debug: add TargetInfo function which returns the default SelfInfo
If one overrides `SelfInfo` in their `root.debug`, it is no longer possible
to refer to the default `SelfInfo` that the std.debug uses.

This allows the developer to still refer to the std's default without
copying the SelfInfo zig files to their project.
2026-06-17 23:17:01 +02:00
ARandomOSDever eedf7d9299 std.Target: add wiiu OS tag 2026-06-17 22:45:00 +02:00
Alex Rønne Petersen dab794394f Merge pull request 'std.Io.Threaded: only use llseek() on Linux if @sizeOf(syscall_arg_t) == 4' (#35820) from alexrp/zig:x32-n32-llseek into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35820
2026-06-17 22:37:40 +02:00
Ryan King a3da3eea8f wasm: add externref and funcref address spaces (#35813)
closes https://codeberg.org/ziglang/zig/issues/31190

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35813
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2026-06-17 22:36:19 +02:00
Alex Rønne Petersen 386153612e std.Io.Threaded: only use llseek() on Linux if @sizeOf(syscall_arg_t) == 4
The x32/n32 ABIs do not make this syscall available.

closes https://codeberg.org/ziglang/zig/issues/35819
2026-06-17 16:28:18 +02:00
Alex Rønne Petersen 002ee8e6d3 std.os.linux: make errno() accept u64 instead of usize
lseek() on x32/n32 returns u64 despite usize == u32.
2026-06-17 16:28:14 +02:00
Ryan Liptak 12815e2223 flate: Correct math when calculating number of available bits
Before this fix, integer overflow would be hit later on, after this function would fail to report that `n` bits were not available.

Fixes https://codeberg.org/ziglang/zig/issues/35789
2026-06-17 09:15:17 +02:00
Alex Rønne Petersen 3f956f9890 std.os.linux: fix lseek() for x32/n32
This is the one syscall that returns a u64 despite usize == u32 in these ABIs.
Rather than huge API churn for all return types in std.os.linux just to benefit
these incredibly niche ABIs, just special-case this particular syscall, as we do
with a few others depending on arch.
2026-06-17 07:22:07 +02:00
Meghan Denny 54537285ca std.Io.Threaded: remove trailing slash from default_PATH entry
previously this would have spawnPosix to try launching eg `/bin//foo`
2026-06-17 06:29:31 +02:00
Meghan Denny adf590d58c std.Io.Threaded: fix off-by-one in netLookup for '.localhost' detection
under this condition, `name[name.len - localhost.len]` will always be 'l'
move back one more to observe the dot
this minus is safe because this branch is only reachable if `name.len > localhost.len`
2026-06-17 01:41:22 +02:00
Jacob Young b23404af3d DynLib: fix elf loading
The comment was just bogus given that these are private (COW) mappings.
This code will need extra logic for handling multiple load segments
overlapping the same page, but the deleted logic was not even close.

Closes #30966
2026-06-16 22:48:18 +02:00
Alex Rønne Petersen b64ce08c99 Merge pull request 'std.debug.Dwarf: fix unwinding when address size is smaller than register size' (#35807) from alexrp/zig:std-debug-ilp32 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35807
Reviewed-by: mlugg <mlugg@noreply.codeberg.org>
2026-06-16 21:24:05 +02:00
Justus Klausecker 9ff926bb1e frontend: guarantee references to dereference expressions to be single-item pointers
AstGen doesn't emit a `ref` ZIR inst if it encounters a dereference `.*`
with a reference result location (`ref`/`ref_coerced_ty`/`ref_const`),
since the operand of the dereference expression already is a reference.

This caused some problems as Zig allows `.*` on both single-item *and* C
pointers, but most logic in Sema assumes that everything with a reference
rl is always a single-item pointer. This largely didn't cause any issues
since C pointers can do everything single-item pointers can, but it caused
Sema to mistake `&p.*[0]` with `@TypeOf(p) == [*c][n]T` for an index into
a many-item pointer `[*][n]T` instead of a single-item pointer `*[n]T`.

To avoid such problems in the future, a pointer obtained from `&p.*` is
now always turned into a proper single-item pointer. This is achieved by
introducing two new ZIR instructions, `deref` and `ref_deref`:

For `ptr.*`:
```
%1 = validate_deref(%ptr)
%2 = load(%ptr)
```
vvv
```
%1 = deref(%ptr)
```

For `&ptr.*`:
```
%1 = validate_deref(%ptr)
// use %ptr directly
```
vvv
```
%1 = ref_deref(%ptr)
// use %1
```

This makes `validate_deref` superfluous, so it's been removed.

Also fixes `node_offset_deref_ptr` source location to actually point to
the pointer being dereferenced and uses it to provide better source locs
for `deref` and `ref_deref`.
2026-06-16 12:58:34 +02:00
Diego Peña y Lillo f3607c75cc Handle TERM=dumb for stdout/stderr (#35767)
fix: #35760
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35767
Reviewed-by: Justus Klausecker <justusk@noreply.codeberg.org>
2026-06-16 12:23:04 +02:00
Alex Rønne Petersen 038698738f std.debug.SelfInfo.Elf: enable unwind support on x32/n32
closes https://codeberg.org/ziglang/zig/issues/32056
2026-06-16 12:13:04 +02:00
Alex Rønne Petersen 4261825766 std.debug.Dwarf: fix unwinding when address size is smaller than register size 2026-06-16 12:12:05 +02:00
Alex Rønne Petersen cf13ecab29 std.debug.cpu_context: always declare a Gpr type on Native 2026-06-16 12:09:31 +02:00
Alex Rønne Petersen a3ae499dc2 Merge pull request 'fix struct field alignment for big ints on s390x + fix VaList for hexagon and s390x' (#35780) from alexrp/zig:s390x-stuff into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35780
2026-06-16 00:55:35 +02:00
Alex Rønne Petersen 37595b7a1d std.Target: update Linux max version to 7.1 2026-06-15 14:57:10 +02:00
Alex Rønne Petersen c92a955c7c std.os.linux: update syscalls to 7.1 2026-06-15 14:57:10 +02:00
Alex Rønne Petersen 47e208e554 std.lang: fix accidentally swapped VaList layouts for hexagon and s390x
contributes to https://codeberg.org/ziglang/zig/issues/35523
2026-06-15 14:36:39 +02:00
Ali Cheraghi 88d2961df4 spirv: codegen and linker fixes for logical-addressing
A handful of changes to get the regressed behavior tests running again.

- Replace `decorateBlockOffsets` with a recursive function `decorateLayout`
  that walks arrays, vectors, structs, unions, optionals, and error unions,
  emitting `ArrayStride` and member `Offset` decorations at every
  level. Previously we weren't handling nested types.
- Restrict `Block` decoration to struct types with
  `uniform`, `push_constant`, `storage_buffer` storage classes.
  Previously we decorated through every pointer, contaminating the cached struct
  type so the same shape used as a stack local also picked up `Block`.
- Lower `ptr_slice_ptr_ptr` and `ptr_slice_len_ptr`
- No longer emit a redundant `**T` typed `OpVariable` for function parameters.
  Logical addressing also forbids such variables.
- Eliminate dead code from invocation globals unreachable from any entry point.
  Reverting the workaround in `lib/std/start.zig`.
2026-06-14 09:11:59 +02:00
Ali Cheraghi 281991328e std: rename gpu.zig to spirv.zig 2026-06-14 09:11:59 +02:00
Ali Cheraghi e2d11ff76b spirv: set execution mode via cc info
Execution modes (e.g. `LocalSize`, `OriginUpperLeft`) were previously set
via `gpu.executionMode()`, which used inline assembly to emit `OpExecutionMode`.
The SPIR-V assembler now rejects this instruction and retrieves execution mode information
from function cc, deleting `gpu.executionMode()` entirely.

Two new `spirv_task` and `spirv_mesh` calling conventions are also added
and `PackedCallingConvention.unpack()` now takes a trailing data slice.
2026-06-14 09:11:59 +02:00
Jacob Young 3deb86bafd AstGen: make local align expression implicitly comptime
Closes #35730
2026-06-13 17:58:37 +02:00
l1yefeng 783a9df0b8 Zip.Entry.extractTo (#35232)
`Entry.extractTo` writes output using a given writer instead of to a destination dir. `extract` now calls `extractTo`.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35232
2026-06-13 00:30:11 +02:00
EJ c11d6e716d std.Io.Dir: support renamePreserve on Darwin systems (#35358)
Related to #35340.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35358
2026-06-12 23:30:44 +02:00
Carl Åstholm e636825f01 std.Build.Step.Fmt: dupe lazy path lists 2026-06-11 16:48:13 +02:00
Justus Klausecker ffac200e66 AstGen: move check for primitive integer type with leading zero
Identifiers like `u0_` should be legal but were previously rejected because
they were spuriously interpreted as primitive integer type identifiers.
Now the integer is first parsed and only if that succeeds it's checked for
a leading zero.
2026-06-11 12:08:45 +02:00
Andrew Kelley 4ea1aaf798 std.Io.net: use the appropriate error code
Previous commit fixed the crash but used this error code:

```
/// The interface name is longer than the host operating system supports.
NameTooLong,
```

More appropriate error code based on the documentation is:

```
/// If this is returned, more detailed diagnostics can be obtained by
/// calling the `Parsed.init` function.
ParseFailed,
```
2026-06-10 21:32:44 -07:00
Christoffer Lerno e7a418e131 std.Io.net: fix ipv6 parsing of overlong iface 2026-06-10 21:31:50 -07:00
Lukas Lalinsky 041ae87b98 Avoid error.Canceled swallowing in `std.debug.* 2026-06-11 06:05:18 +02:00
Mason Remaley 60e4f56b69 Adds missing handling for E.ACCESS 2026-06-11 06:01:32 +02:00
Andrew Kelley b28460b499 Merge pull request 'Rename usages of all deprecated ArrayHashMapUnmanaged to array_hash_map' (#35470) from kada49/zig:array_hash_map_deprecation_rename into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35470
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-06-11 05:59:44 +02:00