263 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
4193ea8239
std.start: add sh support 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
c792ebfee2
std.start: add microblaze support 2025-10-23 09:27:17 +02:00
Alex Rønne Petersen
252e1fd7ec
std.start: add alpha support 2025-10-23 09:27:17 +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
38caa4902f
Merge pull request #25623 from alexrp/or1k
Add `or1k-linux` support (via CBE)
2025-10-19 11:50:06 +02:00
GasInfinity
1bca158c6e fix(std): don't add the default _start and panic in homebrew targets
* even if std supported those targets, they're not posixy to be in that codepath.
2025-10-18 23:54:27 +02:00
Alex Rønne Petersen
2d5cdfcfc2
std.start: align stack pointer according to ARC v3 ABI 2025-10-18 22:26:52 +02:00
Alex Rønne Petersen
0d2d51dd8c
std.start: add or1k support 2025-10-18 22:26:52 +02:00
Alex Rønne Petersen
2305527342
std.start: fix _start for mipsn32
This is more similar to O32 than N64.
2025-10-18 12:11:27 +02:00
Alex Rønne Petersen
b8d776928a
std: make all MIPS inline asm safe for MIPS I
MIPS I has load hazards so we need to insert nops in a few places. This is not a
problem for MIPS II and later.

While doing this, I also touched up all the inline asm to use ABI register
aliases and a consistent formatting convention. Also fixed a few places that
didn't properly check if the syscall return value should be negated.
2025-10-18 11:16:31 +02:00
mlugg
604fb3001d
std.start: also don't print error trace targeting .other
This only matters if `callMain` is called by a user, since `std.start`
will never itself call `callMain` when `target.os.tag == .other`.
However, it *is* a valid use case for a user to call
`std.start.callMain` in their own startup logic, so this makes sense.
2025-09-30 13:44:54 +01:00
mlugg
51d08f4b9b
fix compile errors and minor bugs 2025-09-30 13:44:54 +01:00
mlugg
202aeacc05
std: fixes 2025-09-30 13:44:51 +01:00
Alex Rønne Petersen
5d019abe4e start adding big endian RISC-V support
The big endian RISC-V effort is mostly driven by MIPS (the company) which is
pivoting to RISC-V, and presumably needs a big endian variant to fill the niche
that big endian MIPS (the ISA) did.

GCC already supports these targets, but LLVM support will only appear in 22;
this commit just adds the necessary target knowledge and checks on our end.
2025-08-25 16:15:17 +02:00
Alex Rønne Petersen
07cc32b004 wasi-libc: update to c89896107d7b57aef69dcadede47409ee4f702ee 2025-08-20 19:18:11 +02:00
Linus Groh
ce776d3245 std: Add serenity to more OS checks 2025-07-30 23:28:58 +01:00
Jacob Young
c334956a54 aarch64: workaround some optional/union issues 2025-07-28 09:03:17 -07:00
Jacob Young
5060ab99c9 aarch64: add new from scratch self-hosted backend 2025-07-22 19:43:47 -07:00
Andrew Kelley
15f45e89a7 remove condition codes
LLVM always assumes these are on. Zig backends do not observe them.

If Zig backends want to start using them, they can be introduced, one
arch at a time, with proper documentation.
2025-07-16 10:27:39 -07:00
Andrew Kelley
76d04c1662 zig fmt 2025-07-16 10:27:39 -07:00
Alex Rønne Petersen
9a8f1f675b start: Only issue fninit for x86(_64)-windows
Closes #24263.
2025-07-04 20:09:20 +02:00
Jacob Young
1f98c98fff x86_64: increase passing test coverage on windows
Now that codegen has no references to linker state this is much easier.

Closes #24153
2025-06-19 18:41:12 -04:00
Ali Cheraghi
872f68c9cb
rename spirv backend name
`stage2_spirv64` -> `stage2_spirv`
2025-06-16 13:22:19 +03:30
Jacob Young
0bf8617d96 x86_64: add support for pie executables 2025-06-06 23:42:14 -07: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
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
Pat Tullmann
120c4789c3 sigset_t: sigemptyset() and sigfillset() are functions that return sigset_t
By returning an initialized sigset (instead of taking the set as an output
parameter), these functions can be used to directly initialize the `mask`
parameter of a `Sigaction` instance.
2025-04-30 20:32:04 -07:00
Pat Tullmann
f0aefa625b posix: remove empty_sigset
When linking a libc, Zig should defer to the C library for sigset
operations.  The pre-filled constants signal sets (empty_sigset,
filled_sigset) are not compatible with C library initialization, so remove
them and use the runtime `sigemptyset` and `sigfillset` methods to
initialize any sigset.
2025-04-30 20:32:04 -07:00
Alex Rønne Petersen
4b5941c54b
start: Reduce stack alignment for hexagon.
The ABI requires 8-byte alignment, not 16.
2025-04-07 13:09:10 +02:00
Alex Rønne Petersen
d3bf6c518f
start: Align the stack on m68k. 2025-04-07 13:09:10 +02:00
Stefan Weigl-Bosker
8fea9f68e8
start: fix pc register syntax for m68k 2025-04-07 13:09:10 +02:00
Carmen
9720bade7a
std.start: allow return uefi error union in main (#23425) 2025-04-01 17:10:10 +00:00
Andrew Kelley
284de7d957 adjust runtime page size APIs
* fix merge conflicts
* rename the declarations
* reword documentation
* extract FixedBufferAllocator to separate file
* take advantage of locals
* remove the assertion about max alignment in Allocator API, leaving it
  Allocator implementation defined
* fix non-inline function call in start logic

The GeneralPurposeAllocator implementation is totally broken because it
uses global state but I didn't address that in this commit.
2025-02-06 14:23:23 -08:00
Archbirdplus
439667be04 runtime page size detection
heap.zig: define new default page sizes
heap.zig: add min/max_page_size and their options
lib/std/c: add miscellaneous declarations
heap.zig: add pageSize() and its options
switch to new page sizes, especially in GPA/stdlib
mem.zig: remove page_size
2025-02-06 14:23:23 -08:00
Alex Rønne Petersen
4de661ef18
start: Don't emit CFI directives if unwind tables are disabled. 2025-01-19 02:15:30 +01:00
Alex Rønne Petersen
7d00877076
start: Extend DWARF unwinding protection to more architectures.
The function is not marked .cantunwind for Arm/Thumb because of an LLVM
assembler bug: https://github.com/llvm/llvm-project/issues/115891
2024-12-11 00:10:17 +01:00
Alex Rønne Petersen
43b6bd4243
start: Zero the link and frame pointer registers on all architectures. 2024-12-11 00:10:17 +01:00
Alex Rønne Petersen
3054486d1d
Merge pull request #21843 from alexrp/callconv-followup
Some follow-up work for #21697
2024-11-03 14:27:09 +01:00
Alex Rønne Petersen
c9e67e71c1
std.Target: Replace isARM() with isArmOrThumb() and rename it to isArm().
The old isARM() function was a portability trap. With the name it had, it seemed
like the obviously correct function to use, but it didn't include Thumb. In the
vast majority of cases where someone wants to ask "is the target Arm?", Thumb
*should* be included.

There are exactly 3 cases in the codebase where we do actually need to exclude
Thumb, although one of those is in Aro and mirrors a check in Clang that is
itself likely a bug. These rare cases can just add an extra isThumb() check.
2024-11-03 09:29:30 +01:00
Alex Rønne Petersen
82e82b6267
start: Fix callconv for the wWinMainCRTStartup symbol.
This just uses the C calling convention in the vcruntime sources.
2024-11-02 10:44:18 +01:00
Alex Rønne Petersen
8a2d960627
start: Fix a calling convention check to use eql().
Also modernize some callconv uses.

Closes #21813.
2024-11-02 10:44:18 +01:00
Robin Voetter
9b42bc1ce5
spirv: start.zig support for vulkan
* Use builtin.zig_backend instead of builtin.cpu.arch, the latter
  does not yet compile under VK.
* Don't call regular _start for either opencl or vulkan. We might
  even want to disable these completely.
2024-10-27 14:20:52 +01:00
mlugg
bc797a97b1
std: update for new CallingConvention
The old `CallingConvention` type is replaced with the new
`NewCallingConvention`. References to `NewCallingConvention` in the
compiler are updated accordingly. In addition, a few parts of the
standard library are updated to use the new type correctly.
2024-10-19 19:15:23 +01:00
Michael Dusan
665d0157d5
std ppc64: add nop to start inline-asm
fixes ld.lld error: call to save_start.posixCallMainAndExit lacks nop, can't restore toc
2024-10-05 10:27:13 -04:00
Alex Rønne Petersen
038e002b1c
Merge pull request #21527 from alexrp/elf-emulations
`link.Elf`: Make `getLDMOption()` exhaustive with regards to LLD's `parseEmulation()`.
2024-10-02 23:22:44 +02:00
Michael Ortmann
3b465ebec5
std.start: dont query stack limit for wanted stack size 0 (#21533) 2024-09-28 23:06:28 -07:00
Alex Rønne Petersen
59ae51199e
std.Target: Return EM_ARC_COMPACT instead of EM_ARC_COMPACT2 for arc.
Also fix an incorrect related comment in start.zig.
2024-09-26 21:45:49 +02:00
Alex Rønne Petersen
b56a667ecd start: Rewrite arm code to work for thumb1 too.
0ecc6332b4eb1ced547ffa38f57471134aaa4d13 improved things for thumb2, but thumb1
has a much smaller permissible instruction set. This commit makes that work.
2024-09-12 20:10:45 -07:00
Alex Rønne Petersen
0ecc6332b4
start: Fix arm stack alignment code to work for thumb too. 2024-08-31 03:38:35 +02:00