35000 Commits

Author SHA1 Message Date
Alex Rønne Petersen
c8c3882380
std.crypto.ml_kem: disable some Kyber tests on LoongArch with LSX
LLVM miscompiles these.
2025-09-18 12:42:24 +02:00
Alex Rønne Petersen
9095a7fefd
test: respect -Dskip-translate-c in test-standalone 2025-09-18 12:42:24 +02:00
Alex Rønne Petersen
4e9b8aec2c
test: remove unnecessary @cImport usage in some standalone tests 2025-09-18 12:42:24 +02:00
Alex Rønne Petersen
abd73083e4
test: skip dumpCurrentStackTrace test on architectures with no unwind support 2025-09-18 12:42:24 +02:00
Alex Rønne Petersen
e06bcd74c3
test: re-enable test-std for loongarch64-linux 2025-09-18 12:42:24 +02:00
Alex Rønne Petersen
f90548e740
test: skip alternative constraints behavior test on LoongArch
https://github.com/llvm/llvm-project/issues/159200
2025-09-18 12:42:14 +02:00
Alex Rønne Petersen
e7f1624e6e
std.mem: work around LoongArch inline asm bug in doNotOptimizeAway()
https://github.com/llvm/llvm-project/issues/159200
2025-09-18 10:08:38 +02:00
Alex Rønne Petersen
c547a05b65
langref: runtime_shrExact_overflow does not work as expected on LoongArch
https://github.com/ziglang/zig/issues/24304
2025-09-18 10:08:38 +02:00
Andrew Kelley
d6b4e1918b
Merge pull request #25195 from blblack/netdefs
std: Add several sockopt-related constants and structs
2025-09-17 21:43:23 -07:00
Silver
65a6bf1267
fix handling of comptime-only union fields in Type.getUnionLayout (#25182)
Fixes #25180
2025-09-17 21:39:47 -07:00
Andrew Kelley
220c679523
Merge pull request #25197 from rootbeer/24380-flaky-sigset-test
Re-enable std.posix "sigset_t bits" test
2025-09-17 21:19:01 -07:00
Jacob Young
09bc118c9f Elf: implement linksection
Closes #24330
2025-09-17 21:16:23 -07:00
Andrew Kelley
8e9f2f02d2
Merge pull request #25201 from jacobly0/x86_64-addsat
x86_64: fix strictness edge cases in `+|`
2025-09-17 21:15:03 -07:00
Andrew Kelley
d2e4ad613b
Merge pull request #25217 from blblack/setsiderr
std.os.linux.setsid(): return raw syscall0 result
2025-09-17 21:14:08 -07:00
Andrew Kelley
0df89cd0e1
Merge pull request #25225 from Justus2308/darwin-fixes
std.*.ptrace: support more platforms and features more correctly
2025-09-17 21:11:28 -07:00
Ryan Liptak
c330d2bdde mem.replace: Document that input/output cannot overlap 2025-09-17 20:12:03 -07:00
rohlem
92223ad36f langref: mention union support of @fieldParentPtr 2025-09-17 20:07:30 -07:00
Andrew Kelley
b782cdb9b3
Merge pull request #25249 from jedisct1/siv
std.crypto: add AES-SIV and AES-GCM-SIV
2025-09-17 20:05:23 -07:00
Frank Denis
4406127cca
std.crypto: add Ascon-AEAD, Ascon-Hash, Ascon-CHash (#25239)
Ascon is the family of cryptographic constructions standardized by NIST
for lightweight cryptography.

The Zig standard library already included the Ascon permutation itself,
but higher-level constructions built on top of it were intentionally
postponed until NIST released the final specification.

That specification has now been published as NIST SP 800-232:
https://csrc.nist.gov/pubs/sp/800/232/final

With this publication, we can now confidently include these constructions
in the standard library.
2025-09-17 19:59:55 -07:00
Frank Denis
6dd0270a19
std.sort.pdq: fix out-of-bounds access in partialInsertionSort (#25253)
* std.sort.pdq: fix out-of-bounds access in partialInsertionSort

When sorting a sub-range that doesn't start at index 0, the
partialInsertionSort function could access indices below the range
start. The loop condition `while (j >= 1)` didn't respect the
arbitrary range boundaries [a, b).

This changes the condition to `while (j > a)` to ensure indices
never go below the range start, fixing the issue where pdqContext
would access out-of-bounds indices.

Fixes #25250
2025-09-17 19:54:15 -07:00
marko
4314c9653a use block break instead of return 2025-09-17 19:45:33 -07:00
Alex Rønne Petersen
ae00a2a84d
Merge pull request #25257 from linusg/bump-macos-headers
libc: Update macOS headers to SDK 26.0
2025-09-17 15:35:48 +02:00
Frank Denis
8e8a143d62
Avoid logic where we return success in case of an error (#25251)
In ed25519.zig, we checked if a test succeeds, in which case we
returned an error. This was confusing, and Andrew pointed out that
Zig weights branches against errors by default.
2025-09-17 12:09:35 +02:00
Alex Rønne Petersen
9819f53453
Some miscellaneous test suite cleanups (#25256)
* test: remove test-compare-output and test-asm-link tests

These were low value and unfocused tests. We already have coverage of the
important aspects of these tests elsewhere. Additionally, there was really no
need for these to have their own test harness.

* test: rename issue_8550 standalone test to compile_asm

* test: rename backend=stage2 to backend=selfhosted, and add backend=auto

backend=auto (now the default if backend is omitted) means to let the compiler
pick whatever backend it wants as the default. This is important for platforms
where we don't yet have a self-hosted backend, such as loongarch64.

Also purge a bunch of redundant target=native.

* test: delete old stage1 compile_errors tests

generic_function_returning_opaque_type.zig was salvaged as it's still worth
having.

* test: pull tests in test/cases/llvm/ up to test/cases/

There is nothing inherently LLVM-specific about any of these.

* test: remove @cImport usage in interdependent_static_c_libs

* test: move glibc_compat from link to standalone tests

This is not really testing the linker.

* build: -Dskip-translate-c now implies -Dskip-run-translated-c

* build: skip test-cimport when -Dskip-translate-c is given
2025-09-17 08:11:41 +02:00
Alex Rønne Petersen
aae90762cc
build: skip test-cimport when -Dskip-translate-c is given 2025-09-16 23:39:29 +02:00
Alex Rønne Petersen
d12aed5f14
build: -Dskip-translate-c now implies -Dskip-run-translated-c 2025-09-16 23:39:29 +02:00
Alex Rønne Petersen
a5bb7108a9
test: move glibc_compat from link to standalone tests
This is not really testing the linker.
2025-09-16 23:39:29 +02:00
Alex Rønne Petersen
ab1946de92
test: remove @cImport usage in interdependent_static_c_libs 2025-09-16 23:39:29 +02:00
Alex Rønne Petersen
4dba253cd2
test: pull tests in test/cases/llvm/ up to test/cases/
There is nothing inherently LLVM-specific about any of these.
2025-09-16 23:39:29 +02:00
Alex Rønne Petersen
589e564f16
test: delete old stage1 compile_errors tests
generic_function_returning_opaque_type.zig was salvaged as it's still worth
having.
2025-09-16 23:39:29 +02:00
Alex Rønne Petersen
2e3fac3626
test: rename backend=stage2 to backend=selfhosted, and add backend=auto
backend=auto (now the default if backend is omitted) means to let the compiler
pick whatever backend it wants as the default. This is important for platforms
where we don't yet have a self-hosted backend, such as loongarch64.

Also purge a bunch of redundant target=native.
2025-09-16 23:39:26 +02:00
Frank Denis
b1b2cd7ef8 Parallelize deriveKeys 2025-09-16 23:13:58 +02:00
Frank Denis
5eb7610112 Import crypto/aes_gcm_siv.zig 2025-09-16 23:01:16 +02:00
Linus Groh
93218eacaa libc: Update macOS headers to SDK 26.0 2025-09-16 21:15:13 +01:00
Linus Groh
70715ced95 tools: Update fetch_them_macos_headers.zig for macOS 26 2025-09-16 21:13:38 +01:00
mlugg
580b6d1fad llvm: fix tagged union payload size in debug info
Resolves: #24415
2025-09-16 18:55:19 +01:00
Alex Rønne Petersen
d5c73a44b7
test: rename issue_8550 standalone test to compile_asm 2025-09-16 14:51:29 +02:00
Alex Rønne Petersen
fc20677fde
test: remove test-compare-output and test-asm-link tests
These were low value and unfocused tests. We already have coverage of the
important aspects of these tests elsewhere. Additionally, there was really no
need for these to have their own test harness.
2025-09-16 14:51:03 +02:00
Frank Denis
dd46e07fb9 std.crypto: add AES-SIV and AES-GCM-SIV
The Zig standard library lacked schemes that resist nonce reuse.

AES-SIV and AES-GCM-SIV are the standard options for this.

AES-GCM-SIV can be very useful when Zig is used to target embedded
systems, and AES-SIV is especially useful for key wrapping.

Also take it as an opportunity to add a bunch of test vectors to
modes.ctr and make sure it works with block ciphers whose size is
not 16.
2025-09-16 12:45:08 +02:00
George Huebner
496313a1bd bpf: use bitCast instead of intCast in ld_imm_impl
Any 32 bit immediate is allowed in a BPF instruction, including those
greater than the largest positive i32 value.
2025-09-15 15:24:30 +02:00
mlugg
8744865425 frontend: fix reference tracking through coerced function bodies
This bug was manifesting for user as a nasty link error because they
were calling their application's main entry point as a coerced function,
which essentially broke reference tracking for the entire ZCU, causing
exported symbols to silently not get exported.

I've been a little unsure about how coerced functions should interact
with the unit graph before, but the solution is actually really obvious
now: they shouldn't! `Sema` is now responsible for unwrapping
possibly-coerced functions *before* queuing analysis or marking unit
references. This makes the reference graph optimal (there are no
redundant edges representing coerced versions of the same function) and
simplifies logic elsewhere at the expense of just a few lines in Sema.
2025-09-15 11:29:31 +01:00
database64128
377a8b2a3b std.net.Ip6Address: format numerical scope id 2025-09-15 10:45:35 +01:00
mlugg
32a1aabff7 std.math.big.int: normalize zero result for small multiplications
Resolves: #25221
2025-09-13 17:13:27 +01:00
Justus Klausecker
1b4508cfb3 std.os.linux.ptrace: add PTRACE_EVENT_* and PTRACE_O_* values 2025-09-13 14:43:15 +02:00
Justus Klausecker
9b4cae4750 std.posix.ptrace: support more platforms more correctly 2025-09-13 14:35:19 +02:00
Brandon Black
6dbfba526f linux: Doc and check retval for no-fail pid calls
The switch from @bitCast() to @intCast() here safety-checks
Linux's assertion that these 3 calls never return errors (negative
values as pid_t).  getppid() can legally return 0 if the parent is
in a different pid namespace, but this is not an error.
2025-09-12 07:20:08 -05:00
Brandon Black
04071d64bb std.os.linux.setsid(): return raw syscall0 result
When not linking libc on 64-bit Linux and calling posix.setsid(),
we get a type error at compile time inside of posix.errno().  This
is because posix.errno()'s non-libc branch expects a usize-sized
value, which is what all the error-returning os.linux syscalls
return, and linux.setsid() instead returned a pid_t, which is only
32 bits wide.

This and the other 3 pid-related calls just below it (getpid(),
getppid(), and gettid()) are the only Linux syscall examples here
that are casting their return values to pid_t. For the other 3
this makes sense: those calls are documented to have no possible
errors and always return a valid pid_t value.

However, setsid() actually can return the error EPERM, and
therefore needs to return the raw value from syscall0 for
posix.errno() to process like normal.

Additionally, posix.setsid() needs an @intCast(rc) for the success
case as a result, like most other such cases.
2025-09-12 07:19:01 -05:00
Brandon Black
a0ec4e270e std.os.linux.socketpair(): switch to unsigned args
We need std.os.linux and std.c to agree on the types here, or else
we'd have to pointlessly cast across the difference up in the
std.posix wrapper.  I ran into this as a type error the first time
I tried to compile my code that calls posix.socketpair() on Linux
without libc.

All of our existing socket calls with these kinds of arguments in
std (including the existing c.socketpair as well as
os.linux.socket in this same file) use unsigned for all of these
parameters, and so this brings linux.socketpair() into alignment
with everything else.
2025-09-12 07:01:04 +02:00
Alex Rønne Petersen
4972c987fd compiler-rt: export __aeabi_read_tp for arm-freebsd
FreeBSD normally provides this symbol in libc, but it's in the
FBSDprivate_1.0 namespace, so it doesn't get included in our abilists file.
Fortunately, the implementation is identical for Linux and FreeBSD, so we can
just provide it in compiler-rt.

It's interesting to note that the same is not true for NetBSD where the
implementation is more complex to support older Arm versions. But we do include
the symbol in our abilists file for NetBSD libc, so that's fine.

closes #25215
2025-09-11 23:28:26 +02:00
Sardorbek Imomaliev
6b8cef8107
Fix standalone test simple/cat/main.zig after Writergate update (#25188)
* Make cat in test/standalone/simple working again

- Fixes:
    zig/0.15.1/lib/zig/std/Io/Writer.zig:939:11: 0x1049aef63 in sendFileAll (nclip)
        assert(w.buffer.len > 0);
- because we are no using non zero buffers for stdout - "do not forget to flush"

* replace std.fs with fs because we are already importing it
2025-09-11 16:43:11 +00:00