Commit graph

36074 commits

Author SHA1 Message Date
Lukas Lalinsky
73f863a6fb Fix AI/NI flag definitions for BSD systems
Add missing AI flags for NetBSD and OpenBSD:
- NetBSD: Add AI.SRV flag at bit 11 (0x00000800)
- OpenBSD: Add AI.EXT flag at bit 3 and AI.FQDN flag at bit 5

Add missing NI (getnameinfo) flag definitions for all BSDs and Darwin:
- FreeBSD/Haiku: NOFQDN, NUMERICHOST, NAMEREQD, NUMERICSERV, DGRAM, NUMERICSCOPE
- DragonFly/NetBSD: Same flags with NUMERICSCOPE at bit 6 (deprecated WITHSCOPEID at bit 5 is skipped)
- OpenBSD: NUMERICHOST, NUMERICSERV, NOFQDN, NAMEREQD, DGRAM (no NUMERICSCOPE)
- macOS/Darwin: NOFQDN, NUMERICHOST, NAMEREQD, NUMERICSERV, DGRAM, NUMERICSCOPE at bit 8 (deprecated WITHSCOPEID at bit 5 is skipped)

References:
- NetBSD: https://github.com/NetBSD/src/blob/trunk/include/netdb.h
- OpenBSD: https://github.com/openbsd/src/blob/master/include/netdb.h
- FreeBSD: https://github.com/freebsd/freebsd-src/blob/master/include/netdb.h
- DragonFly BSD: https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/include/netdb.h
- Haiku: https://github.com/haiku/haiku/blob/master/headers/posix/netdb.h
- macOS/Darwin: https://github.com/apple-oss-distributions/Libinfo/blob/main/lookup.subproj/netdb.h
2025-11-17 19:01:39 +01:00
Tobias Simetsreiter
f0a3df98d3 replace @panic with b.addFail in standalone test build.zig 2025-11-17 17:02:53 +01:00
xdBronch
d2b1aa48ab sema: fix UAF in type mismatch error 2025-11-17 10:37:22 +02:00
xdBronch
29a1d0c06f sema: improve codegen of for loop safety checks 2025-11-16 22:59:51 +00:00
Alex Rønne Petersen
35d87c4406
Merge pull request #25929 from alexrp/maccatalyst
`std.zig.target`: support `aarch64-maccatalyst` and `x86_64-maccatalyst` cross libc
2025-11-16 23:16:33 +01:00
Prokop Randáček
94e98bfe80
Dedupe types when printing error messages 2025-11-16 16:20:45 +02:00
Ryan Liptak
adf74ba4fb windows.eqlIgnoreCaseWTF16 -> eqlIgnoreCaseWtf16
Consistent with naming of other, similar functions
2025-11-16 04:03:52 -08:00
Ryan Liptak
aa4332fb0e
Merge pull request #25539 from squeek502/windows-readlinkw
windows: Make readLinkW APIs output WTF-16, reduce stack usage of callers
2025-11-15 23:36:34 -08:00
xdBronch
f6fecfdc00 improve assembly error test coverage 2025-11-16 06:30:51 +00:00
Meghan Denny
d07360f999 std.c: implement rusage for freebsd
Reference: e0c41af925/sys/sys/resource.h (L70)
2025-11-16 06:15:54 +01:00
Ryan Liptak
6aa3570cb0 windows: Make readLinkW APIs output WTF-16, reduce stack usage of callers
- Affects the following functions:
  + `std.fs.Dir.readLinkW`
  + `std.os.windows.ReadLink`
  + `std.os.windows.ntToWin32Namespace`
  + `std.posix.readlinkW`
  + `std.posix.readlinkatW`

Each of these functions (except `ntToWin32Namespace`) took WTF-16 as input and would output WTF-8, which makes optimal buffer re-use difficult at callsites and could force unnecessary WTF-16 <-> WTF-8 conversion during an intermediate step.

The functions have been updated to output WTF-16, and also allow for the path and the output to re-use the same buffer (i.e. in-place modification), which can reduce the stack usage at callsites. For example, all of `std.fs.Dir.readLink`/`readLinkZ`/`std.posix.readlink`/`readlinkZ`/`readlinkat`/`readlinkatZ` have had their stack usage reduced by one PathSpace struct (64 KiB) when targeting Windows.

The new `ntToWin32Namespace` takes an output buffer and returns a slice from that instead of returning a PathSpace, which is necessary to make the above possible.
2025-11-15 18:16:03 -08:00
Ryan Liptak
06a7597ea8 windows.ReadLink: Use OpenFile now that .filter = .any exists
The reasoning in the comment deleted by this commit no longer applies, since that same benefit can be obtained by using OpenFile with `.filter = .any`.

Also removes a stray debug.print
2025-11-15 18:07:25 -08:00
Andrew Kelley
6ecf497714
Merge pull request #25936 from Traxar/master
Add some missing features to `std.Io.Timestamp` and `spirv/CodeGen.zig`
2025-11-15 17:14:12 -08:00
Alex Rønne Petersen
83d9a5968f
std.Thread: disable thread local storage test on 32-bit targets
https://github.com/ziglang/zig/issues/25498
2025-11-16 00:08:20 +01:00
Matthew Lugg
bc589c271a
Merge pull request #25924 from mlugg/legalize-soft-float
Legalize: implement soft-float legalizations
2025-11-15 16:18:40 +00:00
Alex Rønne Petersen
96dfffb7f5
test: enable module tests for maccatalyst targets 2025-11-15 14:23:36 +01:00
Alex Rønne Petersen
bbdf8eaf75
build: change -Dskip-macos to -Dskip-darwin and make it cover all darwin OSs 2025-11-15 14:23:34 +01:00
Sam Bossley
1ebbdf8eef fix: add specific error set for SelectiveWalker iterator function 2025-11-15 05:00:14 -08:00
Matthew Lugg
cd8fdd252d
build.zig: use Step.UpdateSourceFiles for zig1.wasm
We were already using this for `stage1/zig.h`, but `stage1/zig1.wasm`
was being modified directly by the `wasm-opt` command. That's a bad idea
because it forces the build system to assume that `wasm-opt` has side
effects, so it is re-run every time you run `zig build update-zig1`,
i.e. it does not interact with the cache system correctly. It is much
better to create non-side-effecting `Run` steps (using `addOutput*Arg`)
where possible so that the build system has a more correct understanding
of the step graph.
2025-11-15 09:49:02 +00:00
Matthew Lugg
bc78d8efdb
Legalize: implement soft-float legalizations
A new `Legalize.Feature` tag is introduced for each float bit width
(16/32/64/80/128). When e.g. `soft_f16` is enabled, all arithmetic and
comparison operations on `f16` are converted to calls to the appropriate
compiler_rt function using the new AIR tag `.legalize_compiler_rt_call`.
This includes casts where the source *or* target type is `f16`, or
integer<=>float conversions to or from `f16`. Occasionally, operations
are legalized to blocks because there is extra code required; for
instance, legalizing `@floatFromInt` where the integer type is larger
than 64 bits requires calling an arbitrary-width integer conversion
function which accepts a pointer to the integer, so we need to use
`alloc` to create such a pointer, and store the integer there (after
possibly zero-extending or sign-extending it).

No backend currently uses these new legalizations (and as such, no
backend currently needs to implement `.legalize_compiler_rt_call`).
However, for testing purposes, I tried modifying the self-hosted x86_64
backend to enable all of the soft-float features (and implement the AIR
instruction). This modified backend was able to pass all of the behavior
tests (except for one `@mod` test where the LLVM backend has a bug
resulting in incorrect compiler-rt behavior!), including the tests
specific to the self-hosted x86_64 backend.

`f16` and `f80` legalizations are likely of particular interest to
backend developers, because most architectures do not have instructions
to operate on these types. However, enabling *all* of these legalization
passes can be useful when developing a new backend to hit the ground
running and pass a good amount of tests more easily.
2025-11-15 09:49:01 +00:00
Matthew Lugg
9c45a87490
compiler_rt: fix and simplify additional Windows exports
Simplifies the logic, clarifies the comment, and fixes a minor bug,
which is that we exported the Windows ABI name *instead* of the standard
compiler-rt name, but it's meant to be exported *in addition* to the
standard name (this is LLVM's behavior and it is more useful).
2025-11-15 09:49:01 +00:00
Justus Klausecker
4187d0e8fe MemoryPool: add unmanaged variants and make them the default 2025-11-15 09:30:57 +00:00
traxar
868413007f src/codegen/spirv/CodeGen.zig: add missing unary Ops 2025-11-15 16:39:39 +09:00
traxar
19c9062840 std/Io.zig Timestamp: add toMilliseconds() 2025-11-15 16:38:33 +09:00
Alex Rønne Petersen
250803661c
Merge pull request #25927 from lalinsky/netbsd-madv
Fix madvice/msync flags for BSDs
2025-11-15 01:28:05 +01:00
Justus Klausecker
06d08dabab Sema: fix illegal multi level pointer coercions
Moves a premature check that allowed pointers to mutable pointers to coerce
to any other pointer to a mutable pointer.
2025-11-14 23:25:54 +00:00
Alex Rønne Petersen
3649aeb426
std.zig.target: support aarch64-maccatalyst and x86_64-maccatalyst cross libc 2025-11-14 22:14:50 +01:00
Alex Rønne Petersen
3633dd8d41
std.zig.target: libmx is a libSystem library for maccatalyst too 2025-11-14 22:14:50 +01:00
Matthew Lugg
c6b5945356 std.Build: don't force all children to inherit color option
The build runner was previously forcing child processes to have their
stderr colorization match the build runner by setting `CLICOLOR_FORCE`
or `NO_COLOR`. This is a nice idea in some cases---for instance a simple
`Run` step which we just expect to exit with code 0 and whose stderr is
not being programmatically inspected---but is a bad idea in others, for
instance if there is a check on stderr or if stderr is captured, in
which case forcing color on the child could cause checks to fail.

Instead, this commit adds a field to `std.Build.Step.Run` which
specifies a behavior for the build runner to employ in terms of
assigning the `CLICOLOR_FORCE` and `NO_COLOR` environment variables. The
default behavior is to set `CLICOLOR_FORCE` if the build runner's output
is colorized and the step's stderr is not captured, and to set
`NO_COLOR` otherwise. Alternatively, colors can be always enabled,
always disabled, always match the build runner, or the environment
variables can be left untouched so they can be manually controlled
through `env_map`.

Notably, this fixes a failure when running `zig build test-cli` in a
TTY (or with colors explicitly enabled). GitHub CI hadn't caught this
because it does not request color, but Codeberg CI now does, and we were
seeing a failure in the `zig init` test because the actual output had
color escape codes in it due to 6d280dc.
2025-11-14 21:50:24 +01:00
Alex Rønne Petersen
2125c94abe
link.MachO.Dylib: allow maccatalyst output to link macos libraries in TBDs
This is the logic that LLD uses. It is pretty silly, but it is what it is.
2025-11-14 19:19:00 +01:00
Alex Rønne Petersen
ca7523742f
libc: rename any-macos-any to any-darwin-any 2025-11-14 19:19:00 +01:00
Lukas Lalinsky
6bdea35ce5 Fix std.c.MSF.SYNC for freebsd, openbsd, dragonfly 2025-11-14 18:02:53 +01:00
Lukas Lalinsky
6fc5923a54 Define std.c.MADV for openbsd 2025-11-14 18:01:57 +01:00
Lukas Lalinsky
3a08d2f162 Define std.c.MADV for NetBSD
The `.netbsd` branch was completely missing. Validated against the
actual system headers.
2025-11-14 17:48:19 +01:00
Alex Rønne Petersen
b38fb4bff3
Merge pull request #25917 from alexrp/target-features
`std.Target`: add CPU features and models for alpha and hppa
2025-11-14 12:23:09 +01:00
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
Alex Rønne Petersen
18a131f3da
ci: enable Forgejo Actions on master pushes 2025-11-13 23:04:40 +01:00
Alex Rønne Petersen
cca2da16bd
ci: only cancel previous PR runs on Forgejo Actions 2025-11-13 23:00:40 +01:00
Alex Rønne Petersen
65b0a2342b
std.Target.x86: refresh from update_cpu_features.zig
Just to get rid of this ordering diff.
2025-11-13 22:29:28 +01:00
Alex Rønne Petersen
39e91deb77
std.Target: add CPU features and models for hppa 2025-11-13 22:29:12 +01:00
Alex Rønne Petersen
2b23f98d2c
std.Target: add CPU features and models for alpha 2025-11-13 22:28:50 +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
So1aric
49e19fc94f
Sema: fix inline fn compiler crash (#25586)
Resolves: https://github.com/ziglang/zig/issues/25581
2025-11-12 19:21:28 +00:00