Commit Graph

37490 Commits

Author SHA1 Message Date
Meghan Denny b483ec28e3 tools: better detect '=' in clang options 2026-03-17 18:57:07 +01:00
Antonin Décimo 47d2e5de90 CLI: parse ld64 -w "suppress all warnings" option (#31545)
Apple's ld64 and LLVM's ld.ld64 both support a `-w` option to suppress all linker warnings. This option is used in OCaml's build system, parse it so that Zig may be used as a compiler to build an OCaml cross-compiler targeting aarch64-macos.

See also https://codeberg.org/ziglang/zig/issues/31210.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31545
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Antonin Décimo <antonin.decimo@gmail.com>
Co-committed-by: Antonin Décimo <antonin.decimo@gmail.com>
2026-03-17 09:24:30 +01:00
Techatrix bd89b61a21 lib: always pass process.Environ.Map as const pointer if applicable 2026-03-17 06:28:55 +01:00
Hila Friedman bfd2cc5a3f even tighter return type for std.math.sign (#31485)
The code in #31475 does not return the "smallest integer type that fits possible values" for very small integer types, namely `u0`, `i0`, and `i1` - which all end up with a return type one bit too long. Fixed in this commit.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31485
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Hila Friedman <red.black.liquorice@gmail.com>
Co-committed-by: Hila Friedman <red.black.liquorice@gmail.com>
2026-03-17 02:10:27 +01:00
Techatrix 097ca369d5 detect when switch on error shadows it's own switch case capture 2026-03-17 02:05:31 +01:00
Justus Klausecker 524345b635 Sema: handle containers as inline assembly output types correctly
Inline assembly now rejects output types that don't have a well-defined
in-memory layout and correctly resolves the layout of the ones that do.
2026-03-17 01:51:55 +01:00
Andrew Kelley 2d237da50b Merge pull request 'std.math.pow: fix wrong answer for large even exponents' (#31537) from TemariVirus/zig:master into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31537
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-16 23:40:43 +01:00
squidy239 8a8e4a1f04 add cancelable rwlock functions (#31497)
Added cancelable exclusive and shared locking to RwLock. I also added a canceling test for both.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31497
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: squidy239 <sachabarsayuracko@gmail.com>
Co-committed-by: squidy239 <sachabarsayuracko@gmail.com>
2026-03-16 23:05:00 +01:00
Nicholas McDaniel d3fcfb0581 linker: Don't copy protected visibility from shared object symbols
Resolves #30081
2026-03-16 23:01:55 +01:00
Leon Lombar badd252036 link(ELF): add ZSTD decompression support for compressed sections 2026-03-16 22:57:02 +01:00
kcbanner 125c1f3dd9 bit_set: specify the backing integer for IntegerBitSet, allowing it to be used in extern structs 2026-03-16 19:07:13 +01:00
TemariVirus e498550952 std.math.pow: organise and add special case tests
Added tests for special cases which were previously untested.
Updated comments to use the same language as IEEE 754-2008.
2026-03-16 15:42:35 +08:00
TemariVirus 06d9ab7121 std.math.pow: fix wrong answer for large even exponents 2026-03-16 15:32:09 +08:00
mlugg abd099e97f Merge pull request 'compiler: fix missing "local variable is never mutated" error' (#31534) from variable-not-mutated into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31534
2026-03-16 00:05:30 +01:00
pentuppup 2383709431 coerce assembly clobbers in sema 2026-03-15 22:37:38 +01:00
Jan200101 43d5bea7af test: use expectEqualStrings to check cmakedefine behavior
this has the added benefit of outputting the difference making it
easier to figure out why the test is flakey.

https://codeberg.org/ziglang/zig/issues/31368
2026-03-15 21:41:37 +01:00
Yanfeng Liu 584b8f281e zig fmt: remove dead functions
This drops a few dead functions in AutoIndentingStream.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2026-03-15 21:38:45 +01:00
Matthew Lugg 827a96b1ef compiler: fix missing "local variable is never mutated" error
This regressed back in https://github.com/ziglang/zig/pull/25154. I
didn't get around to fixing it until now, so a few instances of the
warning snuck into the repo over the past few months, which were fixed
in the previous commit. The regression has not appeared in a tagged
release though, so this is not a breaking change in 0.16.0.

Resolves: https://codeberg.org/ziglang/zig/issues/31049
2026-03-15 18:24:32 +00:00
Matthew Lugg 64f1c27332 compiler,std: fix never-mutated local variables 2026-03-15 18:22:13 +00:00
Matthew Lugg 5d215838a7 InternPool.Nav: fix race, refactor
I've realised that the cause of at least some of our weird CI flakiness
was a bug in how `Nav` values were resolved. Consider this scenario: the
frontend resolves the type of a `Nav`, and then sends a function to the
backend, which requires the backend to lower a pointer to that `Nav`.
The backend calls `InternPool.getNav` to determine the `Nav`'s type.
However, this races with the frontend resolving the *value* of that
`Nav`. This involves writing separately to two fields, `bits` and
`type_or_value`. If only one of these changes is observed, then the
backend will incorrectly interpret the type as the value or vice versa,
leading to a crash or even a miscompilation. (Of course, there's also
the straightforward issue that the racing loads were non-atomic, making
them illegal).

The only good solution to this was to make `Nav` 4 bytes bigger, giving
it separate `type` and `value` fields. In theory that's a quite small
change, but it ended up having a bunch of nice consequences which led to
this diff being a bit bulkier than expected:

* `Nav.Repr.Bits` was simplified, because it no longer has to track
  "resolution status": we can use `.none` for that. This frees up some
  bits to make things more consistent between the "type resolved" and
  "fully resolved" states.

* This consistency allowed the `Nav.status` union to be replaced with a
  simpler field `Nav.resolved`, which is a bit nicer to work with.

* Most of the "getter" functions were able to be removed from `Nav`
  because the state they were fetching had been moved to simple fields
  on `Nav.resolved`.

* There were still a handful of free bits in `Nav.Repr.Bits`, which
  could be used to represent the "const" and "threadlocal" flags rather
  than these being stored on `Key.Extern` and `Key.Variable`. This is a
  bit more convenient for linkers.

* With those bits gone, `Key.Variable` is a trivial wrapper around a
  type and an initial value, and the fact that a declaration is mutable
  can be represented solely through the "const" flag. Therefore,
  `Key.Variable` no longer served a purpose, and could be eliminated
  entirely in favour of storing the variable's initial value directly in
  the "value" field of the `Nav`.

So, I'm quite pleased with this refactor! But anyway, regarding the bug
fix which actually motivated this: if I've done my job correctly, this
should solve some crashes, such as these (which were what tipped me off
to this bug in the first place):

https://codeberg.org/ziglang/zig/actions/runs/2306/jobs/7/attempt/1
https://codeberg.org/ziglang/zig/actions/runs/2173/jobs/6/attempt/1

...and, who knows, perhaps even the random SIGSEGVs we've seen on some
targets! Probably not, but one can hope.
2026-03-15 11:47:14 +00:00
Guillaume 065c6e7946 std.Io.net.HostName: simplify validate logic (#30764)
Follow-up of efe649b13e

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30764
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Guillaume <guillaume.alabre@gmail.com>
Co-committed-by: Guillaume <guillaume.alabre@gmail.com>
2026-03-15 09:11:11 +01:00
Josh Megnauth aaba36ff76 libzigc: posix_{fadvise, fallocate}, fallocate
This commit removes `posix_fadvise`, `posix_fallocate`, and `fallocate`
from the bundled musl by forwarding to Zig's wrappers. `musl`'s
implemenation does not use `__syscall_cp`, so I assume trivially
replacing these functions is okay.

For `posix_fadvise`, `musl` notes that the arguments are reordered
for ARM and other architectures. Zig's wrapper already handles this
case.

Contributes toward: #30978
2026-03-14 22:04:43 +01:00
David Rubin 50cc3b91a5 Sema: coerce tail call result to immediate function 2026-03-14 05:23:13 -07:00
Brandon Freeman 22c4fbdf16 fix: chdir on uring 2026-03-14 07:11:08 +01:00
Alex Rønne Petersen c6cb5f691d Merge pull request 'link.Lld: pass --be8 to ld.lld for armeb/thumbeb for v6+' (#31489) from alexrp/zig:arm-be8 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31489
2026-03-14 06:19:00 +01:00
Andrew Kelley a7b686ac5e std: disable flaky test on Windows
tracked by #31499
2026-03-14 06:06:03 +01:00
Andrew Kelley d6402955d9 kernel32: another one bytes the dust 2026-03-14 06:06:03 +01:00
Alex Rønne Petersen e0d38561f0 std.crypto.argon2: disable flaky test kdf derived key length
https://codeberg.org/ziglang/zig/issues/31504
2026-03-14 05:55:24 +01:00
Matthew Lugg 5d71e30518 std: remove another kernel32 dependency
We can directly access this path string from the PEB (albeit with some
weirdness around addressing) and that ends up making the downstream code
simpler and more efficient. (Almost like the kernel32 API isn't very
good!)
2026-03-13 20:56:00 +01:00
Alex Rønne Petersen 05c059e563 link.Lld: pass --be8 to ld.lld for armeb/thumbeb v6+
BE32 is deprecated and only supported by older cores and some v6 cores. All
cores v6 or newer support BE8, so default to that for v6+.

closes https://codeberg.org/ziglang/zig/issues/31404
2026-03-13 14:58:12 +01:00
Alex Rønne Petersen bc67a49c5c std.zig.target: fix glibc triple for armeb-linux-gnueabi* to use be8 2026-03-13 14:58:12 +01:00
rpkak 090ae3042e Set link_libunwind to true for zig build-exe -lunwind 2026-03-13 13:24:33 +01:00
Andrew Kelley b15aa0540d Merge pull request 'add a fuzz test for zig fmt' (#30082) from gooncreeper/zig:fmt-fuzzing into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30082
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-13 08:43:19 +01:00
Andrew Kelley 2c61deaae2 Merge pull request 'std.Io.net: enable more tests + coverage for canceling accept' (#31468) from net-test-coverage into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31468
2026-03-13 08:27:14 +01:00
Alex Rønne Petersen ab1a4b26ec zig cc: link compiler-rt when given -lcompiler_rt even with -nostdlib
closes https://codeberg.org/ziglang/zig/issues/31460
2026-03-13 04:16:07 +01:00
Alex Rønne Petersen 26f2749c1e Merge pull request 'FreeBSD libc: guard ssp headers and definitions introduced in FreeBSD 15' (#31457) from kid/zig:fbsd-libc-guard into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31457
Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>
2026-03-13 04:07:26 +01:00
Andrew Kelley 314264ee7d std: windows isn't passing cancel accept yet
tracked by #30865
2026-03-12 15:42:13 -07:00
Andrew Kelley 9634e98357 std.Io.Threaded: fix missing calls to syscall.finish() 2026-03-12 15:41:00 -07:00
Andrew Kelley a50458777b std.Io.Threaded: NtTerminateProcess can return PROCESS_IS_TERMINATING 2026-03-12 15:40:59 -07:00
Andrew Kelley 8973c8a826 std.Io.Threaded.netWriteWindows: IO_PENDING is not unreachable 2026-03-12 15:40:59 -07:00
Andrew Kelley 1c9bd1d74c std.Io.net: enable all the tests
closes #18315
closes #25983
closes #31388
2026-03-12 15:40:59 -07:00
Kendall Condon 02e8339ca7 zig build fmt 2026-03-12 17:44:03 -04:00
Pablo Alessandro Santos Hugen 627f03af9d std.os.linux: add explicit backing type to packed structs in extern types 2026-03-12 22:33:03 +01:00
Kendall Condon 9632ee3eb0 zig fmt: remove dead function 2026-03-12 17:25:06 -04:00
Kendall Condon 2b6589bd3b zig fmt: fix error sets with empty line before comma 2026-03-12 17:25:01 -04:00
Kendall Condon 99fea4431b zig fmt: rewrite renderArrayInit
There were just too many bugs. This new implementation supports zig fmt:
on/off. It also puts expressions with unicode characters on their own
line, which avoids issues with aligning them.
2026-03-12 17:25:00 -04:00
Kendall Condon c477df98bb zig fmt: fix tracking of applied indentation 2026-03-12 17:23:24 -04:00
Kendall Condon 9014daedbb zig fmt: properly check escape sequences 2026-03-12 17:23:24 -04:00
Kendall Condon 409541bc77 zig fmt: canonicalize stray backslashes in identifiers 2026-03-12 17:23:23 -04:00
Kendall Condon bbc2e7a74d Ast: fix comptime wrapper for destructure 2026-03-12 17:23:23 -04:00