Commit graph

40 commits

Author SHA1 Message Date
Alex Rønne Petersen
dba1bf9353 remove all Oracle Solaris support
There is no straightforward way for the Zig team to access the Solaris system
headers; to do this, one has to create an Oracle account, accept their EULA to
download the installer ISO, and finally install it on a machine or VM. We do not
have to jump through hoops like this for any other OS that we support, and no
one on the team has expressed willingness to do it.

As a result, we cannot audit any Solaris contributions to std.c or other
similarly sensitive parts of the standard library. The best we would be able to
do is assume that Solaris and illumos are 100% compatible with no way to verify
that assumption. But at that point, the solaris and illumos OS tags would be
functionally identical anyway.

For Solaris especially, any contributions that involve APIs introduced after the
OS was made closed-source would also be inherently more risky than equivalent
contributions for other proprietary OSs due to the case of Google LLC v. Oracle
America, Inc., wherein Oracle clearly demonstrated its willingness to pursue
legal action against entities that merely copy API declarations.

Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in
maintenance mode since, presumably to be retired completely sometime in the 2030s.

For these reasons, this commit removes all Oracle Solaris support.

Anyone who still wishes to use Zig on Solaris can try their luck by simply using
illumos instead of solaris in target triples - chances are it'll work. But there
will be no effort from the Zig team to support this use case; we recommend that
people move to illumos instead.
2025-10-27 07:35:38 -07:00
Alex Rønne Petersen
c9e0df97f9 std.debug.cpu_context: fix mcontext alignment for x86_64-illumos
It contains a upad128_t array which increases its alignment.
2025-10-26 08:48:21 +01:00
Stephen Gregoratto
f4ef7e8761
std.debug.cpu_context: add missing signal_ucontext_t fields for x86_64-solaris/illumos 2025-10-25 12:44:17 +02:00
Alex Rønne Petersen
d99cf5061c
std.debug.cpu_context: add signal_ucontext_t for alpha, hppa, microblaze, sh 2025-10-23 19:34:02 +02:00
Alex Rønne Petersen
3e2daa509a
std.Target: add arceb and xtensaeb Cpu.Arch tags 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
9fd7f38600
std.debug.cpu_context.Sparc: fix bad use of call delay slot 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
727942bc03
std.debug.cpu_context: let the compiler deal with clobbers
Otherwise we might be restoring registers we don't even need to.
2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
1f15e265fe
std.debug.cpu_context: sort context decls according to switch prongs (NFC) 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
4c81a496e7
std.debug: add CPU context and DWARF mappings for arc 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
ba9ab3fb67
std.debug: add CPU context and DWARF mappings for m68k 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
eb36a45ed9
std.debug: add CPU context and DWARF mappings for or1k 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
de3947608c
std.debug: add CPU context and DWARF mappings for csky 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
81fe640dd2
std.debug: add CPU context and DWARF mappings for lanai 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
0b55393a2f
std.debug: add CPU context and DWARF mappings for ve 2025-10-18 00:36:52 +02:00
Alex Rønne Petersen
b2732645b7
std.debug.cpu_context: add sparc*-linux context conversion support
It's not really a ucontext_t at all. Lovely stuff.
2025-10-15 13:59:17 +02:00
Alex Rønne Petersen
b8dd40fde8
std.debug.cpu_context.Sparc: flush register windows in current()
It's better to do this here than in StackIterator.init() so that
std.debug.cpu_context.Native.current() isn't a footgun on SPARC.
2025-10-15 13:59:17 +02:00
Alex Rønne Petersen
12b1d57df1
std.debug.cpu_context: add Sparc context 2025-10-15 13:59:17 +02:00
Alex Rønne Petersen
ea694bfdb7 std.debug.cpu_context: consider arm and aarch64 reserved register ranges unsupported
If these ever get allocated, it's most likely going to be for things that don't
matter to us anyway, so completely abandoning DWARF unwinding just because we
see these doesn't seem justified. We will still do so if we're actually asked to
read from such a register, which is the only actually problematic case; see
c23a5ccd19 for more details.
2025-10-12 12:59:06 +02:00
Alex Rønne Petersen
f33d3a5166
std.debug: greatly expand target support for segfault handling/unwinding
I made a couple of decisions for this based on the fact that we don't expose the
signal_ucontext_t type outside of the file:

* Adding all the floating point and vector state to every ucontext_t and
  mcontext_t variant was way, way too much work, especially when we don't even
  use the stuff. So I deleted all that and kept only the bare minimum needed to
  reach into general-purpose registers.
* There is no particularly compelling reason to stick to the naming and struct
  nesting used in the system headers. So we can actually unify the access
  patterns for almost all of these variants by taking some liberties here; as a
  result, fromPosixSignalContext() is now much nicer to read and extend.
2025-10-10 04:43:15 +02:00
Alex Rønne Petersen
a54906b46e
std.debug.cpu_context: make arch-specific implementations private 2025-10-07 19:18:46 +02:00
Alex Rønne Petersen
7fdd5704ed
std.debug.cpu_context: map a bunch of known registers as unsupported instead of invalid 2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
de3b22db4d
std.debug.cpu_context: remove support for s390x float registers
Let's for the moment assume that compilers haven't lost the plot.

Fingers crossed.
2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
9cd37a0696
std.debug.Dwarf: use 66 as the (fake) MIPS PC register
32-63 conflict with the floating point registers. 64 and 65 are used for the
ac0 hi/lo registers.
2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
f6403ed5ea
std.debug.Dwarf: use 67 as the (fake) PowerPC PC register
It's free real estate, as it turns out.
2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
feba8a83a7
std.debug.Dwarf: use 65 as the (fake) RISC-V PC register
32-63 conflict with the floating point registers. 64 is the Alternate Frame
Return Column.
2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
9a6fad2706
std.debug.Dwarf: use 64 as the (fake) LoongArch PC register
32-63 conflict with the floating point registers.
2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
aa74eb505a
std.debug: add unwind support for powerpc*-linux 2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
ca73d697b9
std.debug: add unwind support for mips*-linux 2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
a5a9ffb90b
std.debug.cpu_context: check for architecture, i.e. register size, not bitness
We care about the hardware here, not the ABI.
2025-10-07 16:47:57 +02:00
Alex Rønne Petersen
a5ff376b8f
std.debug: add unwind support for hexagon-linux 2025-10-05 20:09:26 +02:00
Linus Groh
b0f280f4a4 std.debug: Add unwind support for serenity 2025-10-03 22:59:40 +01:00
Alex Rønne Petersen
8263f55ab2
std.debug: add s390x-linux unwind support 2025-10-03 03:29:20 +02:00
Alex Rønne Petersen
97de46dc16
std.debug: add riscv32-linux and riscv64-linux unwind support 2025-10-01 23:47:47 +02:00
Alex Rønne Petersen
8520e9312e
std.debug: add loongarch64-linux unwind support 2025-10-01 23:47:47 +02:00
Alex Rønne Petersen
b46867848e
std.debug: some adjustments to target handling
* driverkit handling missing in a few places.
* x86-solaris is a dead target.
* aarch64_be does not exist on Darwin, FreeBSD, Windows.
2025-10-01 23:47:47 +02:00
mlugg
a90eb50c80
typo 2025-09-30 13:44:56 +01:00
mlugg
f7e0ff8a5f
std: clarify cpu_context register order rationale 2025-09-30 13:44:56 +01:00
mlugg
084e92879a
std: don't get CPU context when using CBE targeting MSVC
Calling `current` here causes compilation failures as the C backend
currently does not emit valid MSVC inline assembly. This change means
that when building for MSVC with the self-hosted C backend, only FP
unwinding can be used.
2025-09-30 13:44:55 +01:00
mlugg
dd8d59686a
std.debug: miscellaneous fixes
Mostly on macOS, since Loris showed me a not-great stack trace, and I
spent 8 hours trying to make it better. The dyld shared cache is
designed in a way which makes this really hard to do right, and
documentation is non-existent, but this *seems* to work pretty well.
I'll leave the ruling on whether I did a good job to CI and our users.
2025-09-30 13:44:54 +01:00
mlugg
a18fd41064
std: rework/remove ucontext_t
Our usage of `ucontext_t` in the standard library was kind of
problematic. We unnecessarily mimiced libc-specific structures, and our
`getcontext` implementation was overkill for our use case of stack
tracing.

This commit introduces a new namespace, `std.debug.cpu_context`, which
contains "context" types for various architectures (currently x86,
x86_64, ARM, and AARCH64) containing the general-purpose CPU registers;
the ones needed in practice for stack unwinding. Each implementation has
a function `current` which populates the structure using inline
assembly. The structure is user-overrideable, though that should only be
necessary if the standard library does not have an implementation for
the *architecture*: that is to say, none of this is OS-dependent.

Of course, in POSIX signal handlers, we get a `ucontext_t` from the
kernel. The function `std.debug.cpu_context.fromPosixSignalContext`
converts this to a `std.debug.cpu_context.Native` with a big ol' target
switch.

This functionality is not exposed from `std.c` or `std.posix`, and
neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale
is that these types and functions do not conform to a specific ABI, and
in fact tend to get updated over time based on CPU features and
extensions; in addition, different libcs use different structures which
are "partially compatible" with the kernel structure. Overall, it's a
mess, but all we need is the kernel context, so we can just define a
kernel-compatible structure as long as we don't claim C compatibility by
putting it in `std.c` or `std.posix`.

This change resulted in a few nice `std.debug` simplifications, but
nothing too noteworthy. However, the main benefit of this change is that
DWARF unwinding---sometimes necessary for collecting stack traces
reliably---now requires far less target-specific integration.

Also fix a bug I noticed in `PageAllocator` (I found this due to a bug
in my distro's QEMU distribution; thanks, broken QEMU patch!) and I
think a couple of minor bugs in `std.debug`.

Resolves: #23801
Resolves: #23802
2025-09-30 13:44:54 +01:00