Commit graph

249 commits

Author SHA1 Message Date
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.
0ecc6332b4 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
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Jacob Young
f289b82d0e Dwarf: implement .eh_frame 2024-08-27 03:55:56 -04:00
mlugg
a3a737e9a6
lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
Alex Rønne Petersen
ab9628dd2c
start: Avoid concatenating strings for inline asm.
For csky, we can just always do the gb initialization. For riscv, the gp code is
temporarily pulled above the main switch until the blocking issue is resolved.
2024-08-15 10:56:32 +02:00
Jacob Young
5d080e25d5 start: fix passing comptime-only value to inline asm
Also fix fmt directive typo.
2024-08-15 04:42:04 -04:00
Andrew Kelley
8184912a98
Merge pull request #20925 from alexrp/windows-tls
`std`: Some Windows TLS cleanup and fixes
2024-08-07 01:12:11 -07:00
Alex Rønne Petersen
c0681d6b6e start: Add sparc32 support. 2024-08-07 01:09:18 -07:00
Alex Rønne Petersen
8056a85151
std: Move start_windows_tls.zig to os/windows/tls.zig.
Just to be consistent with Linux.
2024-08-03 20:35:08 +02:00
Alex Rønne Petersen
a9c7818512
start: Fix an isARM() check to use isArmOrThumb() instead. 2024-08-01 20:58:08 +02:00
Andrew Kelley
7a0da805a8
Merge pull request #20797 from alexrp/start-more-arches
`start`: Add POSIX arc, csky, and hexagon support
2024-08-01 01:34:33 -07:00
Andrew Kelley
91163b44dd
Merge pull request #20857 from alexrp/tls-porting
`std.os.linux.tls`: Refactor, improve documentation, fix a bug, and port to more architectures
2024-08-01 01:15:17 -07:00
Andrew Kelley
63aa85e7af
Merge pull request #20872 from alexrp/riscv-gp
start: Initialize `gp` to `__global_pointer$` on riscv.
2024-08-01 00:47:05 -07:00
David Rubin
2b8a71489a
start: remove riscv condition 2024-07-31 13:40:00 -07:00
Alex Rønne Petersen
653eb75355
start: Disable the gp initialization code for the self-hosted riscv64 backend. 2024-07-31 02:06:57 +02:00