38739 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
Justus Klausecker 36069a2a7d Sema: make dereferences of comptime-known null C pointers runtime-known
This allows `@TypeOf(@as([*c]T, null).*.x)` to (continue to) work.
In the long term these are probably not the semantics we want, unwrapping
a comptime-known `null` pointer should always result in `unreachable`.

Also adds missing runtime safety checks for loading null C pointers.
2026-06-20 09:45:38 +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
pentuppup f4462c0cd7 fix enabling incremental on compile steps without global incremental 2026-06-19 16:09:09 +02:00
David Rubin f7e6d757f2 Sema: correctly populate runtime_{cond,loop} for inline returns 2026-06-19 16:08:32 +02:00
Alex Rønne Petersen d004f775ce Merge pull request 'fix C ABI lowering for x32 + re-enable tests' (#35848) from alexrp/zig:x32-abi-tests into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35848
2026-06-19 15:29:53 +02:00
Alex Rønne Petersen 10083cc23e Merge pull request 'test: promote most x32/n32 module test targets to non-extra status' (#35836) from alexrp/zig:x32-n32-graduation into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35836
2026-06-19 12:34:40 +02:00
Alex Rønne Petersen e6d26bf962 test: re-enable C ABI tests for x86_64-linux-muslx32 2026-06-19 11:49:34 +02:00
Alex Rønne Petersen 513b395f7f llvm: fix C ABI lowering for x32
closes https://codeberg.org/ziglang/zig/issues/35838
2026-06-19 11:48:14 +02:00
Alex Rønne Petersen 6e001367a4 test: promote most x32/n32 module test targets to non-extra status
These ILP32 ABIs are now about as well supported as their LP64 counterparts.

mips64(el)-linux-muslabin32 with dynamic linking is still marked as extra, in
line with other dynamically-linked musl targets.
2026-06-19 08:26:05 +02:00
Alex Rønne Petersen f5e8338828 musl: fix read of stack slot containing ctid in x32 clone()
https://www.openwall.com/lists/musl/2026/06/19/4
2026-06-19 08:25:49 +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
Alex Rønne Petersen 787a2c9d7a test: remove psx-mipsel from llvm_targets for now
mq test-cases
        mq compile obj llvm_targets Debug mipsel-psx-eabi failure
    error: warning: MIPS-I support is experimental

This can be added back once this LLVM warning is removed.
2026-06-19 05:47:30 +02:00
Alex Rønne Petersen 3d604248e6 compiler-rt: delete workarounds for __int128 ABI on x86_64-windows
LLVM requires frontends to lower i128 to <2 x i64> in IR to get the correct
__int128 ABI on x86_64-windows; this is what Clang does. I'm guessing our LLVM
backend didn't do this in the past, which made these hacks necessary. But it
does do so now, so just get rid of this stuff.
2026-06-19 04:25:42 +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
David Rubin d5446652fa Sema: correctly copy pointer attributes for optional pointer payload 2026-06-18 22:42:42 +02:00
David Rubin e6686ae00d Sema: copy alignment flags to pointer of slice field 2026-06-18 22:40:04 +02:00
Alex Rønne Petersen 2db133b53f test: disable C ABI tests for x86_64-linux-muslx32
Lots of failures here; this target shouldn't have been in this list yet.
2026-06-18 16:31:32 +02:00
Ali Cheraghi 65e74dfbda @extern: add flat decoration 2026-06-18 13:38:58 +02:00
Ali Cheraghi 508cbec694 spirv: implement tuple types 2026-06-18 13:38:58 +02:00
Ali Cheraghi 4653794852 spirv: implement switch with ranges and loop_switch_br switch_dispatch 2026-06-18 13:38:58 +02:00
Ali Cheraghi a5fbbb8305 spirv: composite integers
composite integers (wider than usize) are represented in as `[N]u32` arrays.
however, no operations were implemented before.
following operations are implemented:

- bitwise (and, or, xor, not)
- comparison (eq/neq)
- add/sub/mul/shl/shr
- `@abs`, `@intCast`

this removes 36 SPIR-V behavior test skips.

also fixed `derivePtr` to use `OpAccessChain` instead of `OpBitcast`
for array pointer casts (e.g. `*[100]u8` to `*u8`) in logical addressing
mode, where pointer bitcasts are not valid.
2026-06-18 13:38:58 +02:00
Ali Cheraghi 93cd157da1 spirv: fix endianness in object read/write 2026-06-18 13:38:58 +02:00
Ali Cheraghi ca57b33ddd spirv: object file linking 2026-06-18 13:38:58 +02:00
Quint Daenen ecb627eb39 fix(spirv): convert composite_integer unreachables to cg.todo
Eleven arithmetic/comparison/reduce paths panicked on big-int
operands. Replace each with cg.todo so unsupported widths surface
as compile errors instead of crashes.
2026-06-18 13:38:58 +02:00
Quint Daenen cf950691cb fix(spirv): error cleanly on integer types wider than 64 bits
resolveType called Module.intType for any integer width, which
asserted backing_bits <= 64 for big-int types. Reject these widths
in resolveType with a fail() so users get a diagnostic instead of
a compiler panic.
2026-06-18 13:38:58 +02:00
Ali Cheraghi 7140d08334 spirv: int/bool fixes
- use logical ops for boolean bitwise instructions
- normalize strange-int results in airArithOp, airReduce, and airIntCast

Co-authored-by: Quint Daenen <quint@daenen.email>
2026-06-18 13:38:58 +02:00
Ali Cheraghi f4c4daec86 spirv: emit debug info for invocation globals 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
Ali Cheraghi c6d178f93d spirv: make codegen multi-threaded
The SPIR-V backend previously ran codegen single-threaded in the linker thread.
Now each codegen job creates an `Mir` like other self-hosted backends.

Other changes:
- Bring back `dedup_types.zig` and `prune_unused.zig` **ISel**s which were originaly
  removed because codegen was single-threaded at that time and therefor had no use
- Clean up `BinaryModule.zig`
- Remove `checkLogicalPtrOperation` from `elemPtrOneLayerOnly` in `Sema.zig`.
  Element access uses `OpAccessChain`, which works on all logical address spaces
  without `VariablePointers`. the check is only needed for pointer arithmetic.
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
Ryan Mehri 14bc6f5917 Sema: check for undefined values in zirArrayCat
Right now, when an undefined tuple value is passed to zirArrayCat, it
will call `elemValue`, which will incorrectly try to produce a undef
value of the child type (of which there is none) and then panics.

This adds a check for an undef value first to produce an undef elem
value of the correct resolved type.
2026-06-18 11:41:36 +02:00
Ryan Liptak 46a750a006 Merge pull request 'mingw: Only preprocess .def.in files' (#35829) from squeek502/zig:mingw-def-followup into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35829
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-06-18 10:54:11 +02:00
Ryan Liptak a851256a98 mingw: Only preprocess .def.in files
The .def files don't have any preprocessor commands so running them through the preprocessor is useless work.
2026-06-17 20:07:43 -07:00
Ryan Liptak a20f7a9dd6 mingw/Tokenizer: Delete unused function 2026-06-17 20:02:28 -07:00
Alex Rønne Petersen 7853cd1e00 test: add libc-less x32/n32 linux targets to module test matrix 2026-06-18 04:29:24 +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
Arthur Teixeira 0b22111bc9 MinGW: remove dependency on a C preprocessor for MinGW .def.in files (#35679)
closes #31955

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35679
Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>
2026-06-18 00:01:17 +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