Commit Graph

11490 Commits

Author SHA1 Message Date
Jacob Young 9edfccb9a7 Legalize: implement scalarization of overflow intrinsics 2025-06-01 08:24:01 +01:00
Jacob Young ec579aa0f3 Legalize: implement scalarization of @shuffle 2025-06-01 08:24:01 +01:00
Jacob Young b48d6ff619 Legalize: implement scalarization of @select 2025-06-01 08:24:01 +01:00
Jacob Young b483defc5a Legalize: implement scalarization of binary operations 2025-05-31 18:54:28 -04:00
Alex Rønne Petersen 0cbff2ff7f mingw: Remove libscrnsav(e,w) support.
This defines a WinMain() function that can be potentially problematic when it
isn't wanted. If we add back support for this library in the future, it should
be built separately from mingw32.lib and on demand.
2025-05-30 01:03:47 +02:00
Alex Rønne Petersen 7c7627b18a compiler: Use new merged header paths for glibc and NetBSD libc. 2025-05-30 00:15:37 +02:00
Alex Rønne Petersen 92b3c4b451 std.c: Expand the definition of NetBSD's pthread_rwlock_t for more targets. 2025-05-29 16:48:28 +02:00
Alex Rønne Petersen 71fd5ac38a std.c: Fix return type for NetBSD's __sigfillset14(). 2025-05-29 16:48:28 +02:00
Alex Rønne Petersen fb3a9fc18e std.posix.test: Fix reserved_signo() for NetBSD. 2025-05-29 16:48:28 +02:00
Alex Rønne Petersen 309ac27d35 std.c: Fix sigrtmin()/sigrtmax() for FreeBSD and NetBSD.
They just define the constants in the system headers.
2025-05-29 16:48:28 +02:00
Jacob Young 8bacf3e757 x86_64: implement integer @reduce(.Max) 2025-05-28 15:10:22 -04:00
Jacob Young 3fd3358f37 x86_64: implement integer @reduce(.Min) 2025-05-28 15:10:22 -04:00
Jacob Young a4a1ebdeed x86_64: implement optimized float @reduce(.Mul) 2025-05-28 15:10:22 -04:00
Jacob Young 1f6f8b0ffe x86_64: implement integer @reduce(.Add) 2025-05-28 15:10:22 -04:00
Jacob Young d69f4c48fc x86_64: rewrite bitwise @reduce 2025-05-28 15:10:22 -04:00
Jacob Young 4f3b59f708 debug: disable fp-based frame unwinding when fp is omitted
This has been causing non-deterministic timeouts on aarch64 CI.
2025-05-28 15:08:39 -04:00
mlugg 92c63126e8 compiler: tlv pointers are not comptime-known
Pointers to thread-local variables do not have their addresses known
until runtime, so it is nonsensical for them to be comptime-known. There
was logic in the compiler which was essentially attempting to treat them
as not being comptime-known despite the pointer being an interned value.
This was a bit of a mess, the check was frequent enough to actually show
up in compiler profiles, and it was very awkward for backends to deal
with, because they had to grapple with the fact that a "constant" they
were lowering might actually require runtime operations.

So, instead, do not consider these pointers to be comptime-known in
*any* way. Never intern such a pointer; instead, when the address of a
threadlocal is taken, emit an AIR instruction which computes the pointer
at runtime. This avoids lots of special handling for TLVs across
basically all codegen backends; of all somewhat-functional backends, the
only one which wasn't improved by this change was the LLVM backend,
because LLVM pretends this complexity around threadlocals doesn't exist.

This change simplifies Sema and codegen, avoids a potential source of
bugs, and potentially improves Sema performance very slightly by
avoiding a non-trivial check on a hot path.
2025-05-27 19:23:11 +01:00
Matthew Lugg ef35c3d5fe Merge pull request #23986 from mlugg/incremental-stuff
incremental: bugfix (and a debugging feature that helped me do that bugfix)
2025-05-25 18:02:16 +01:00
Robin Voetter dc6ffc28b5 Merge pull request #23815 from alichraghi/master
spirv: unroll all vector operations
2025-05-25 12:36:53 +02:00
mlugg aeed5f9ebd compiler: introduce incremental debug server
In a compiler built with debug extensions, pass `--debug-incremental` to
spawn the "incremental debug server". This is a TCP server exposing a
REPL which allows querying a bunch of compiler state, some of which is
stored only when that flag is passed. Eventually, this will probably
move into `std.zig.Server`/`std.zig.Client`, but this is easier to work
with right now. The easiest way to interact with the server is `telnet`.
2025-05-25 04:43:43 +01:00
KNnut 7dbd21bd5b std.zig.LibCDirs: fix wasi-libc support 2025-05-24 13:32:17 +02:00
Felix Rabe ad2b175d45 std.log: fix example 2025-05-24 10:52:56 +02:00
mlugg 9a3540d61e std.Build: resolved generated paths are cwd-relative
The doc comment here agreed with the implementation, but not with *any*
`Step` which populates a `GeneratedFile`, where they are treated as
cwd-relative. This is the obvious correct choice, because these paths
usually come from joining onto a cache root, and those are cwd-relative
if not absolute.

This was a pre-existing bug, but #23836 caused it to trigger more often,
because the compiler now commonly passes the local cache directory to
the build runner process as a relative path where it was previously an
absolute path.

Resolves: #23954
2025-05-22 08:43:37 +01:00
Evan Silberman 931c6f90f5 Add EVFILT_USER and friends for OpenBSD
OpenBSD -current grew EVFILT_USER. See commit message [1] and and
current sys/event.h [2]

Also EVFILT_DEVICE was missing.

Closes #23930

[1]: https://marc.info/?l=openbsd-cvs&m=174686993115485&w=2
[2]: https://codeberg.org/OpenBSD/src/src/branch/master/sys/sys/event.h
2025-05-22 04:37:57 +02:00
Ali Cheraghi 4bf1e4d198 target: auto-generated spirv features 2025-05-21 15:26:18 +03:30
Matthew Lugg ef92c156b5 Merge pull request #23946 from mlugg/build-step-run-cwd
std.Build.Step.Run: inherit build runner cwd
2025-05-21 10:33:30 +01:00
Ali Cheraghi 8fa54eb798 spirv: error when execution mode is set more than once 2025-05-21 13:01:21 +03:30
Ali Cheraghi 0901328f12 spirv: write error value in an storage buffer 2025-05-21 12:57:40 +03:30
Alex Rønne Petersen f925e1379a std.zig.target: Remove thumb-freebsd-eabihf.
Leftover from 76d525f74a.
2025-05-21 09:55:23 +02:00
mlugg fe855691f6 std.Build.Step.Run: inherit build runner cwd
Right now, if you override the build root with `--build-root`, then
`Run` steps can fail to execute because of incorrect path handling in
the compiler: `std.process.Child` gets a cwd-relative path, but also has
its cwd set to the build root. The latter behavior is really weird; it
doesn't match my expectations, nor does it match how we spawn child
`zig` processes. So, this commit makes the child process inherit the
build runner's cwd, as `LazyPath.getPath2` *expects* it to.

After investigating, this behavior dates all the way back to 2017; it
was introduced in 4543413. So, there isn't any clear/documented reason
for this; it should be safe to revert, since under the modern `LazyPath`
system it is strictly a bug AFAICT.
2025-05-21 01:45:05 +01:00
David 55848363fd libc: implement common abs for various integer sizes (#23893)
* libc: implement common `abs` for various integer sizes

* libc: move imaxabs to inttypes.zig and don't use cInclude

* libc: delete `fabs` c implementations because already implemented in compiler_rt

* libc: export functions depending on the target libc

Previously all the functions that were exported were handled equally,
though some may exist and some not inside the same file. Moving the
checks inside the file allows handling different functions differently

* remove empty ifs in inttypes

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

* remove empty ifs in stdlib

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

* libc: use `@abs` for the absolute value calculation

---------

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-05-21 00:57:38 +02:00
Alex Rønne Petersen 999777e73a compiler: Scaffold stage2_powerpc backend.
Nothing interesting here; literally just the bare minimum so I can work on this
on and off in a branch without worrying about merge conflicts in the non-backend
code.
2025-05-20 10:23:16 +02:00
Alex Rønne Petersen d000e53b29 Merge pull request #23923 from alexrp/compiler-rt-symbols
Use hidden visibility in compiler-rt and libzigc except when testing
2025-05-20 07:48:35 +02:00
Alex Rønne Petersen b27c5fbbde Merge pull request #23913 from alexrp/netbsd-libc
Support dynamically-linked NetBSD libc when cross-compiling
2025-05-20 07:46:08 +02:00
Matthew Lugg 23c817548b Merge pull request #23836 from mlugg/incr-fixes
Incremental fixes, refactor `Zcu.File`
2025-05-20 03:25:19 +01:00
Alex Rønne Petersen e882956ef6 std.leb128: Disable two tests on x86-linux-musl with dynamic linkage.
https://github.com/ziglang/zig/issues/23922
2025-05-19 00:22:19 +02:00
Andrew Kelley b77e601342 Merge pull request #23834 from jacobly0/x86_64-rewrite
x86_64: finish rewriting scalar overflow and saturate operations
2025-05-18 14:36:33 -04:00
mlugg d32829e053 std.Build.Cache: change contract of addFilePostContents
This function was broken, because it took ownership of the buffer on
error *sometimes*, in a way which the caller could not tell. Rather than
trying to be clever, it's easier to just follow the same interface as
all other `addFilePost` methods, and not take ownership of the path.

This is a breaking change. The next commits will apply it to the
compiler, which is the only user of this function in the ziglang/zig
repository.
2025-05-18 17:10:04 +01:00
Alex Rønne Petersen 74a3ae4927 start: Don't artificially limit some posixCallMainAndExit() logic to Linux.
This code applies to ~any POSIX OS where we don't link libc. For example, it'll
be useful for FreeBSD and NetBSD.

As part of this, move std.os.linux.pie to std.pie since there's really nothing
Linux-specific about what that file is doing.
2025-05-18 17:14:09 +02:00
Jacob Young a3b0c242b0 x86_64: rewrite @splat 2025-05-17 18:00:17 -04:00
Jacob Young 58d2bd601e x86_64: rewrite scalar <<|
Closes #23035
2025-05-17 18:00:17 -04:00
Jacob Young 4adb7eca6a debug: correctly detect missing entries in .eh_frame_hdr 2025-05-17 02:08:41 -04:00
Jacob Young 6d68a494c8 x86_64: rewrite vector +| 2025-05-17 02:08:41 -04:00
Alex Rønne Petersen 1a82cceb8c std.Target: Factor arch/ABI into NetBSD minimum OS version selection.
Based on data in std.zig.target.
2025-05-17 04:41:27 +02:00
Alex Rønne Petersen a090ef007b std.zig.target: Add NetBSD libc support. 2025-05-17 04:41:27 +02:00
Alex Rønne Petersen 35f8121194 std.zig.LibCDirs: Add NetBSD libc support. 2025-05-17 04:41:27 +02:00
Alex Rønne Petersen 6028db7f29 std.Target: Add isNetBSDLibC() function. 2025-05-17 04:41:27 +02:00
Alex Rønne Petersen 8a7d925d36 std.Target: Fix requiresLibC() for NetBSD. 2025-05-17 04:41:27 +02:00
Alex Rønne Petersen 3d6f83b331 std.Target: Adjust DynamicLinker.standard() for NetBSD.
* powerpc64 does not appear to be a thing.
* riscv32/riscv64 have not had actual releases yet.
2025-05-17 04:41:27 +02:00
Alex Rønne Petersen 9af8e7c68e std.c: Fill out some missing definitions for supported NetBSD libc targets.
This allows ubsan-rt to build.
2025-05-17 04:41:26 +02:00