Commit graph

13644 commits

Author SHA1 Message Date
Alex Rønne Petersen
94538d8dd2 std.pie: add missing clobbers on alpha and sparc
Also format all the assembly code in the file.
2025-11-14 12:19:38 +01:00
Alex Rønne Petersen
9ab7eec23e represent Mac Catalyst as aarch64-maccatalyst-none rather than aarch64-ios-macabi
Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct
OS target. Earlier, when DriverKit support was added to LLVM, it was represented
a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in
the target triple is beyond me. But this isn't the first time they've ignored
established target triple norms (see: armv7k and aarch64_32) and it probably
won't be the last.

While doing this, I also audited all Darwin OS prongs throughout the codebase
and made sure they cover all the tags.
2025-11-14 11:33:35 +01:00
0x4a61636f62
2e6f7d36b9 std.Io.net: fix off-by-one in HostName.expand
`HostName.expand` was including the null terminator in the slice passed to `HostName.init`, which caused `HostName.validate` to fail.
2025-11-13 21:04:21 -08:00
Andrew Kelley
813e8614bc
Merge pull request #25817 from castholm/windows-fetch
Fix TLS, `io.async()` and package fetching on Windows
2025-11-13 19:20:13 -08:00
Alex Rønne Petersen
375d873e1e libcxx: use compiler's _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION when set
closes #25911
2025-11-14 02:02:59 +01:00
xdBronch
071453d5b9 fix 'redundant comptime keyword' error source location and add tests 2025-11-13 19:47:36 +00:00
Matthew Lugg
181b25ce4f
Merge pull request #25772 from mlugg/kill-dead-code
compiler: rewrite some legalizations, and remove a bunch of dead code
2025-11-12 23:14:02 +00:00
Alex Rønne Petersen
dfd7b7f233 std.Target: remove Abi.cygnus
There is approximately zero chance of the Zig team ever spending any effort on
supporting Cygwin; the MSVC and MinGW-w64 ABIs are superior in every way that
matters, and not least because they lead to binaries that just run natively on
Windows without needing a POSIX emulation environment installed.
2025-11-12 22:39:04 +01:00
Matthew Lugg
92bc619c49 std.debug: allow fp unwind from context
It's easy to do FP unwinding from a CPU context: you just report the
captured ip/pc value first, and then unwind from the captured fp value.
All this really needed was a couple of new functions on the
`std.debug.cpu_context` implementations so that we don't need to rely on
`std.debug.Dwarf` to access the captured registers.

Resolves: #25576
2025-11-12 21:02:38 +00:00
Matthew Lugg
5df5e2ed26
zig.h: drop dependency on deleted compiler_rt functions
It turns out we did use these in the C backend. However, it's really
just as easy, if not easier, to replicate the logic directly in C.

Synchronizes stage1/zig.h to make sure the bootstrap doesn't depend on
these functions either. The actual zig1 tarball is unmodified because
regenerating it is unnecessary in this instance.
2025-11-12 16:00:16 +00:00
Matthew Lugg
20bd5e8018
compiler-rt: remove dead code
`__addosi4`, `__addodi4`, `__addoti4`, `__subosi4`, `__subodi4`, and
`__suboti4` were all functions which we invented for no apparent reason.
Neither LLVM, nor GCC, nor the Zig compiler use these functions. It
appears the functions were created in a kind of misunderstanding of an
old language proposal; see https://github.com/ziglang/zig/pull/10824.

There is no benefit to these functions existing; if a Zig compiler
backend needs this operation, it is trivial to implement, and *far*
simpler than calling a compiler-rt routine. Therefore, this commit
deletes them. A small amount of that code was used by other parts of
compiler-rt; the logic is trivial so has just been inlined where needed.
I also chose to quickly implement `__addvdi3` (a standard function)
because it is trivial and we already implement the `sub` parallel.
2025-11-12 16:00:16 +00:00
Techatrix
8887346b53 std.Io: fix calls on functions that return an array type 2025-11-11 01:11:51 +01:00
Carl Åstholm
cca2d09950 io: Correctly align async closure contexts
This fixes package fetching on Windows.

Previously, `Async/GroupClosure` allocations were only aligned for the
closure struct type, which resulted in panics when `context_alignment`
(or `result_alignment` for that matter) had a greater alignment.
2025-11-11 01:11:45 +01:00
Carl Åstholm
5f1392247d io: Redefine Clock.real to return timestamps relative to the POSIX/Unix epoch
`Clock.real` being defined to return timestamps relative to an
implementation-specific epoch means that there's currently no way for
the user to translate returned timestamps to actual calendar dates
without digging into implementation details of any particular `Io`
implementation. Redefining it to return timestamps relative to
1970-01-01T00:00:00Z fixes this problem.

There are other ways to solve this, such as adding a new vtable function
for returning the implementation-specific epoch, but in terms of
complexity this redefinition is by far the simplest solution and only
amounts to a simple 96-bit integer addition's worth of overhead on OSes
like Windows that use non-POSIX/Unix epochs.
2025-11-10 22:12:40 +01:00
Carl Åstholm
ed7f2588e4 io: Translate Windows Clock.real timestamps to the POSIX/Unix epoch
This fixes `std.http.Client` TLS certificate validation on Windows.
2025-11-10 22:12:39 +01:00
Alex Rønne Petersen
d182c7e3bc
Merge pull request #25886 from alexrp/kvx
beginnings of KVX target support (via CBE)
2025-11-10 16:38:23 +01:00
Matthew Lugg
966809862f
Merge pull request #25839 from Rexicon226/socket-bind-fix
Io.net: fix compile error in `receive` and `receiveTimeout`
2025-11-10 14:38:54 +00:00
Mateusz Poliwczak
d942f693c5 std.zig.AstGen: properly handle grouped_expression
This fixes an endless loop in the compiler.
2025-11-10 14:02:37 +00:00
Frank Denis
ce355e0ba5
Add ML-DSA post-quantum signatures (#25862)
ML-DSA is a post-quantum signature scheme that was recently
standardized by NIST.

Keys and signatures are pretty large, not making it a drop-in
replacement for classical signature schemes.

But if you are shipping keys that may still be used in 10 years
or whenever large quantum computers able to break ECC arrive,
it that ever happens, and you don't have the ability to replace
these keys, ML-DSA is for you.

Performance is great, verification is faster than Ed25519 / ECDSA.

I tried manual vectorization, but it wasn't worth it, the compiler
does at good job at auto-vectorization already.
2025-11-10 14:11:30 +01:00
Alex Rønne Petersen
f34b5ce288
std.Target.DynamicLinker: define standard paths for alpha, microblaze, sh on netbsd and openbsd 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
255fc44036
std.Target: fix toElfMachine() for arc/arceb 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
a382b7bfc5
std.simd: suggest 1024-bit vectors for kvx 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
39b5c8ee8a
std.debug.Dwarf: add kvx ip/fp/sp register mappings 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
94b6c7ce5f
std.debug.cpu_context: add kvx context implementation 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
80e567b6bd
std.pie: add kvx support 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
8fae6630c4
std.start: add kvx support 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
f5d31cff71
zig.h: add kvx support 2025-11-10 09:40:44 +01:00
Alex Rønne Petersen
350eaa5bac
std.builtin.assembly: add Clobbers for kvx 2025-11-10 09:40:42 +01:00
Alex Rønne Petersen
378eec95b8
std.Target: kvx requires 32-byte aligned stacks 2025-11-10 08:20:24 +01:00
Alex Rønne Petersen
2c470d24b3
std.Target: add Arch tag and info for kvx 2025-11-10 08:20:21 +01:00
Jacob Young
f3309a96a7
Merge pull request #25819 from jacobly0/elfv2-emit-obj 2025-11-10 00:10:17 -05:00
Mateusz Poliwczak
bdbfc7de3f std.zig.Zir: remove ref_start_index from enum fields of Index and OptionalIndex
This change removes the ref_start_index from the possible enum values of
Index and OptionalIndex. It is not really a index, but a constant that
tells the offset of static Refs, so lets move it where such constant
belongs i.e. to the Ref.
2025-11-09 10:45:14 +00:00
Jacob Young
57889cae80 posix: reduce the number of assumptions made by dl_iterate_phdr
Not yet fully compatible with the new linker, but still progress.

Closes #25786
2025-11-09 03:31:26 -05:00
Jacob Young
80c961159b Elf2: elide unused nodes when emitting objects 2025-11-09 03:31:26 -05:00
Ryan Liptak
b31a03f134 Let CRT take care of the entry point for wWinMain if libc is linked
Fixes #7852

Before, the modified test would fail with:

```
error: lld-link: undefined symbol: wWinMain
    note: referenced by C:\Users\Ryan\Programming\Zig\zig-x86_64-windows-0.15.1\lib\libc\mingw\crt\crtexewin.c:66
    note:               libmingw32.lib(ucrtexewin.obj):(wmain)
```
2025-11-08 17:11:12 -08:00
Ryan Liptak
be4eaed7c4
Merge pull request #25860 from squeek502/coalesce-to-std-zig
Move/coalesce `CompressDebugSections` and `RcIncludes` enums to `std.zig`
2025-11-08 02:34:44 -08:00
Petr Pučil
38d44404a5 Fix param name in doc comment for std.Io.Reader.peek()
The old doc comment mentioned a parameter `len` three times, but the
function does not accept such a parameter - it is actually called `n`.
2025-11-08 00:34:41 -08:00
Ryan Liptak
da77d306b6 Move/coalesce RcIncludes enum to std.zig.RcIncludes 2025-11-07 19:16:52 -08:00
Ryan Liptak
f587209e04 Move/coalesce CompressDebugSections enum to std.zig.CompressDebugSections 2025-11-07 19:15:55 -08:00
Ryan Liptak
74d2536715
Merge pull request #25158 from castholm/subsystem
Misc. Windows subsystem refactorings
2025-11-07 18:56:52 -08:00
Alex Rønne Petersen
bf15c791fa
Merge pull request #25820 from GiuseppeCesarano/process
Child.start_suspended ported to posix
2025-11-07 23:17:55 +01:00
Lukas Lalinsky
852a1f718a Fix kqueue definitions on NetBSD
EVFILT_USER and NOTE_TRIGGER were wrong.

Added missing ones along the way.
2025-11-07 22:23:46 +01:00
Giuseppe Cesarano
f4159eff92
std.Child: start_suspended ported to posix 2025-11-07 08:53:43 +01:00
Giuseppe Cesarano
5c0309a9e5
std.posix: implemented getpid and getppid 2025-11-07 08:52:35 +01:00
Frank Denis
4b593a6c24
std.crypto: improve KT documentation, use key_length for B3 key length (#25807)
It was not obvious that the KT128/KT256 customization string can be
used to set a key, or what it was designed to be used for at all.

Also properly use key_length and not digest_length for the BLAKE3
key length (no practical changes as they are both 32, but that was
confusing).

Remove unneeded simd_degree copies by the way, and that doesn't need
to be in the public interface.
2025-11-07 08:20:04 +01:00
marximimus
2e8f8afc83
Base64DecoderWithIgnore.calcSizeUpperBound cannot return an error (#25834)
* std: Base64DecoderWithIgnore.calcSizeUpperBound cannot return an error

* std: update doc comment of Base64DecoderWithIgnore.calcSizeUpperBound
2025-11-07 08:16:34 +01:00
David Rubin
71988d6719
Io.net: set receive{,Timeout} message to init
If we use `undefined`, then `netReceive` can `@intCast` the
control slice len to msghdr controllen, which is sometimes `u32`,
even on 64-bit platforms.

`init` just avoids this entirely by setting `control` to an empty
slice rather than undefined.
2025-11-06 17:44:28 -08:00
David Rubin
654a5b20d7
Io: fix compile error in receive and receiveTimeout
Correctly uses the `netReceive` API. If an error was
returned, we propagate that error, otherwise assert
we only received one message.
2025-11-06 17:42:19 -08:00
Mateusz Poliwczak
40132af3ad std.zig.AstRlAnnotate: remove pointless switch
This switch has the same cases as the outer one.
2025-11-06 23:57:16 +00:00
Ryan Liptak
4937aeff84
Merge pull request #25714 from snoire/enum-literal-format-support
std.Io.Writer.print: support .enum_literal in 't' format specifier
2025-11-06 14:40:34 -08:00