ziglang/zig
261
5.9k
Fork
You've already forked zig
767

Add ashetos tag to std.Target #35954

Merged
alexrp merged 3 commits from Der_Teufel/zig:ashetos-target into master 2026年07月07日 15:19:24 +02:00
Contributor
Copy link
No description provided.
Der_Teufel force-pushed ashetos-target from 8c6c60aea9
Some checks failed
ci / aarch64-freebsd-debug (pull_request) Has been cancelled
ci / aarch64-freebsd-release (pull_request) Has been cancelled
ci / aarch64-netbsd-debug (pull_request) Has been cancelled
ci / aarch64-netbsd-release (pull_request) Has been cancelled
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
ci / s390x-linux-debug (pull_request) Has been cancelled
ci / s390x-linux-release (pull_request) Has been cancelled
ci / x86_64-linux-debug (pull_request) Has been cancelled
ci / x86_64-linux-debug-llvm (pull_request) Has been cancelled
ci / x86_64-linux-release (pull_request) Has been cancelled
ci / x86_64-windows-debug (pull_request) Has been cancelled
ci / x86_64-windows-release (pull_request) Has been cancelled
ci / aarch64-macos-debug (pull_request) Has been cancelled
ci / aarch64-linux-debug (pull_request) Has been cancelled
ci / aarch64-macos-release (pull_request) Has been cancelled
ci / x86_64-freebsd-release (pull_request) Has been cancelled
ci / aarch64-linux-release (pull_request) Has been cancelled
ci / x86_64-openbsd-release (pull_request) Has been cancelled
ci / x86_64-freebsd-debug (pull_request) Has been cancelled
ci / x86_64-openbsd-debug (pull_request) Has been cancelled
ci / x86_64-netbsd-debug (pull_request) Has been cancelled
ci / x86_64-netbsd-release (pull_request) Has been cancelled
ci / powerpc64le-linux-release (pull_request) Has been cancelled
ci / powerpc64le-linux-debug (pull_request) Has been cancelled
to 65367ad86b
Some checks failed
ci / x86_64-netbsd-release (pull_request) Successful in 51m34s
ci / x86_64-netbsd-debug (pull_request) Successful in 54m49s
ci / x86_64-freebsd-release (pull_request) Successful in 58m11s
ci / x86_64-freebsd-debug (pull_request) Successful in 1h2m2s
ci / x86_64-openbsd-release (pull_request) Successful in 1h11m35s
ci / x86_64-openbsd-debug (pull_request) Successful in 1h18m43s
ci / aarch64-freebsd-debug (pull_request) Has been skipped
ci / aarch64-freebsd-release (pull_request) Has been skipped
ci / aarch64-macos-release (pull_request) Successful in 1h35m7s
ci / x86_64-linux-debug (pull_request) Successful in 1h12m43s
ci / aarch64-linux-release (pull_request) Successful in 1h36m54s
ci / x86_64-windows-debug (pull_request) Successful in 1h32m23s
ci / aarch64-macos-debug (pull_request) Successful in 1h49m27s
ci / x86_64-windows-release (pull_request) Successful in 1h32m30s
ci / aarch64-netbsd-debug (pull_request) Has been skipped
ci / aarch64-netbsd-release (pull_request) Has been skipped
ci / powerpc64le-linux-release (pull_request) Successful in 2h37m44s
ci / aarch64-linux-debug (pull_request) Successful in 2h49m9s
ci / powerpc64le-linux-debug (pull_request) Successful in 4h8m33s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 4h4m11s
ci / s390x-linux-release (pull_request) Successful in 2h49m35s
ci / x86_64-linux-release (pull_request) Successful in 3h46m19s
ci / s390x-linux-debug (pull_request) Successful in 3h53m5s
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
2026年06月27日 12:35:38 +02:00
Compare
@ -957,6 +963,8 @@ pub const Abi = enum {
.vita=>.eabihf,
.wasi,.emscripten=>.musl,
.ashetos=>.eabi,
Owner
Copy link

This is almost certainly not right, unless you only support AshetOS on architectures that distinguish between soft float and hard float ABI.

This is almost certainly not right, unless you only support AshetOS on architectures that distinguish between soft float and hard float ABI.
First-time contributor
Copy link

Right now, I compile the applications for Ashet OS for .x86, .riscv32 and .thumb with .eabi, without kernel support for hard float passing.

Technically, i'd need a x86-ashetos-ashetos interface but teaching my kind of syscall/callconv to LLVM sounds like a stupid idea ^-^

Can you elaborate your question? I've used EABI because i knew it would work fairly well on all platforms, but you have more expertise here

Right now, I compile the applications for Ashet OS for `.x86`, `.riscv32` and `.thumb` with `.eabi`, without kernel support for hard float passing. Technically, i'd need a `x86-ashetos-ashetos` interface but teaching my kind of syscall/callconv to LLVM sounds like a stupid idea ^-^ Can you elaborate your question? I've used EABI because i knew it would work fairly well on all platforms, but you have more expertise here
Owner
Copy link

eabi/eabihf are intended to distinguish soft/hard float as a stopgap until https://github.com/ziglang/zig/issues/20690 (or some variation thereof) is implemented. (I'm hoping to make some progress on this in the next release cycle.) For architectures that don't have a soft float ABI, we just use none or similar.

riscv32-ashetos-eabi is almost certainly not doing what you want, however, because eabi/eabihf aren't even enough to describe the possible float ABIs on RISC-V. There, we unfortunately pick the ABI based on the presence of the d and f CPU features. The eabi probably just does nothing.

x86-ashetos-eabi might work by accident, but x86 + eabi is not really a tested combination. This is another unfortunate situation where you need to set the soft_float CPU feature for good measure.

Can you clarify why any of this matters for syscalls though? On most/all OSs, whether the userspace ABI uses soft or hard float has no bearing on the kABI.

`eabi`/`eabihf` are intended to distinguish soft/hard float as a stopgap until https://github.com/ziglang/zig/issues/20690 (or some variation thereof) is implemented. (I'm hoping to make some progress on this in the next release cycle.) For architectures that don't have a soft float ABI, we just use `none` or similar. `riscv32-ashetos-eabi` is almost certainly not doing what you want, however, because `eabi`/`eabihf` aren't even enough to describe the possible float ABIs on RISC-V. There, we unfortunately pick the ABI based on the presence of the `d` and `f` CPU features. The `eabi` *probably* just does nothing. `x86-ashetos-eabi` *might* work by accident, but `x86` + `eabi` is not really a tested combination. This is another unfortunate situation where you need to set the `soft_float` CPU feature for good measure. Can you clarify why any of this matters for syscalls though? On most/all OSs, whether the userspace ABI uses soft or hard float has no bearing on the kABI.
First-time contributor
Copy link

Ashet OS (right now) uses a callconv(.c) compatible function calls for syscalls (Ashet OS does not require interrupts, and has no memory protection, so syscalls are just function calls).

This means that kernel and userland have to agree on the C calling convention.

But this means i'll have to go forward and start doing a larger refactoring of switching from .c to a well-defined calling convention (which sadly will be .x86_stdcall on x86).

But this also implies that when i compile my kernel for a cpu which supports f/d, and the application is compiled generically, they will fail to pass floats?

That sounds horrible.

Ashet OS (right now) uses a `callconv(.c)` compatible function calls for syscalls (Ashet OS does not require interrupts, and has no memory protection, so syscalls are just function calls). This means that kernel and userland have to agree on the C calling convention. But this means i'll have to go forward and start doing a larger refactoring of switching from `.c` to a well-defined calling convention (which sadly will be `.x86_stdcall` on x86). But this also implies that when i compile my kernel for a cpu which supports f/d, and the application is compiled generically, they will fail to pass floats? That sounds horrible.
Owner
Copy link

@ikskuh wrote in #35954 (comment):

But this means i'll have to go forward and start doing a larger refactoring of switching from .c to a well-defined calling convention (which sadly will be .x86_stdcall on x86).

I don't quite follow how you got from there to here.

@ikskuh wrote in #35954 (comment):

But this also implies that when i compile my kernel for a cpu which supports f/d, and the application is compiled generically, they will fail to pass floats?

Yes. That's one reason among several that making ABI decisions based on presence of CPU features results in a really bad user experience.

@ikskuh wrote in https://codeberg.org/ziglang/zig/pulls/35954#issuecomment-18174893: > But this means i'll have to go forward and start doing a larger refactoring of switching from `.c` to a well-defined calling convention (which sadly will be `.x86_stdcall` on x86). I don't quite follow how you got from there to here. @ikskuh wrote in https://codeberg.org/ziglang/zig/pulls/35954#issuecomment-18174893: > But this also implies that when i compile my kernel for a cpu which supports f/d, and the application is compiled generically, they will fail to pass floats? Yes. That's one reason among several that making ABI decisions based on presence of CPU features results in a really bad user experience.
First-time contributor
Copy link

I don't quite follow how you got from there to here.

Long story. tl;dr: LLVM neither allows (x86-windows + .x86_sysv nor x86-linux + .sysv_cdecl), which means i can't use either for syscalls in my hosted OS variant (run as os app). The only one that
remains on win and linux is .stdcall.

I wanted to use a well-defined CC for this that isn't .c so it's more ABI triple independent.

That's one reason among several that making ABI decisions based on presence of CPU features results in a really bad user experience.

thought so.

I'm not sure what's the right way forward, i guess we could leave in .eabi until I figure it out better and you introduce the target quadruples

> I don't quite follow how you got from there to here. Long story. tl;dr: LLVM neither allows (`x86-windows` + `.x86_sysv` nor `x86-linux` + `.sysv_cdecl`), which means i can't use either for syscalls in my hosted OS variant (run as os app). The only one that remains on win and linux is `.stdcall`. I wanted to use a well-defined CC for this that isn't `.c` so it's more ABI triple independent. > That's one reason among several that making ABI decisions based on presence of CPU features results in a really bad user experience. thought so. I'm not sure what's the right way forward, i guess we could leave in `.eabi` until I figure it out better and you introduce the target quadruples
src/target.zig Outdated
@ -95,3 +96,3 @@
pubfndefaultPie(target:*conststd.Target)bool{
returnswitch(target.os.tag){
.openbsd,.serenity=>true,
.openbsd,.serenity,.ashetos=>true,
Owner
Copy link

AshetOS shouldn't be added here since you already enforce PIE.

AshetOS shouldn't be added here since you already enforce PIE.
Owner
Copy link

You didn't actually remove this change.

You didn't actually remove this change.
Author
Contributor
Copy link

Yep, forgot to git add

Yep, forgot to git add
Der_Teufel marked this conversation as resolved
@ -454,7 +454,8 @@ pub fn resolve(options: Options) ResolveError!Config {
constpie=b:{
switch(options.output_mode){
.Exe=>if(target.os.tag==.fuchsiaor
Owner
Copy link

It may be a good time to factor this condition into a requiresPie function in target.zig.

It may be a good time to factor this condition into a `requiresPie` function in `target.zig`.
Der_Teufel marked this conversation as resolved
src/target.zig Outdated
@ -67,2 +67,3 @@
target.requiresLibC()or
(linking_libcandtarget.isGnuLibC());
(linking_libcandtarget.isGnuLibC())or
target.os.tag==.ashetos;
Owner
Copy link

This is not necessary; enforcing PIE implies enforcing PIC.

This is not necessary; enforcing PIE implies enforcing PIC.
Der_Teufel marked this conversation as resolved
Der_Teufel force-pushed ashetos-target from be65e7542b
Some checks failed
ci / aarch64-netbsd-release (pull_request) Has been skipped
ci / aarch64-netbsd-debug (pull_request) Has been skipped
ci / aarch64-freebsd-debug (pull_request) Has been skipped
ci / aarch64-freebsd-release (pull_request) Has been skipped
ci / loongarch64-linux-debug (pull_request) Has been cancelled
ci / loongarch64-linux-release (pull_request) Has been cancelled
ci / riscv64-linux-debug (pull_request) Has been cancelled
ci / riscv64-linux-release (pull_request) Has been cancelled
ci / aarch64-linux-debug (pull_request) Has been cancelled
ci / aarch64-linux-release (pull_request) Has been cancelled
ci / powerpc64le-linux-debug (pull_request) Has been cancelled
ci / powerpc64le-linux-release (pull_request) Has been cancelled
ci / x86_64-linux-debug-llvm (pull_request) Has been cancelled
ci / x86_64-linux-release (pull_request) Has been cancelled
ci / s390x-linux-release (pull_request) Has been cancelled
ci / s390x-linux-debug (pull_request) Has been cancelled
ci / x86_64-freebsd-release (pull_request) Has been cancelled
ci / x86_64-freebsd-debug (pull_request) Has been cancelled
ci / aarch64-macos-debug (pull_request) Has been cancelled
ci / aarch64-macos-release (pull_request) Has been cancelled
ci / x86_64-openbsd-release (pull_request) Has been cancelled
ci / x86_64-netbsd-release (pull_request) Has been cancelled
ci / x86_64-linux-debug (pull_request) Has been cancelled
ci / x86_64-openbsd-debug (pull_request) Has been cancelled
ci / x86_64-netbsd-debug (pull_request) Has been cancelled
ci / x86_64-windows-debug (pull_request) Has been cancelled
ci / x86_64-windows-release (pull_request) Has been cancelled
to 0b1bc666c9
All checks were successful
ci / aarch64-freebsd-debug (pull_request) Has been skipped
ci / aarch64-netbsd-debug (pull_request) Has been skipped
ci / aarch64-netbsd-release (pull_request) Has been skipped
ci / aarch64-freebsd-release (pull_request) Has been skipped
ci / x86_64-netbsd-release (pull_request) Successful in 54m11s
ci / x86_64-windows-release (pull_request) Successful in 58m39s
ci / x86_64-freebsd-release (pull_request) Successful in 59m12s
ci / x86_64-linux-debug (pull_request) Successful in 1h0m52s
ci / x86_64-openbsd-release (pull_request) Successful in 1h1m6s
ci / x86_64-netbsd-debug (pull_request) Successful in 1h8m49s
ci / x86_64-freebsd-debug (pull_request) Successful in 1h18m57s
ci / x86_64-openbsd-debug (pull_request) Successful in 1h31m41s
ci / x86_64-windows-debug (pull_request) Successful in 1h32m57s
ci / aarch64-linux-release (pull_request) Successful in 1h35m49s
ci / s390x-linux-release (pull_request) Successful in 1h50m59s
ci / aarch64-macos-release (pull_request) Successful in 1h56m28s
ci / powerpc64le-linux-release (pull_request) Successful in 2h26m14s
ci / aarch64-macos-debug (pull_request) Successful in 2h29m8s
ci / aarch64-linux-debug (pull_request) Successful in 2h49m17s
ci / s390x-linux-debug (pull_request) Successful in 3h12m38s
ci / x86_64-linux-release (pull_request) Successful in 4h2m14s
ci / x86_64-linux-debug-llvm (pull_request) Successful in 4h6m32s
ci / powerpc64le-linux-debug (pull_request) Successful in 4h37m18s
ci / loongarch64-linux-release (pull_request) Successful in 2h31m24s
ci / loongarch64-linux-debug (pull_request) Successful in 4h3m38s
ci / riscv64-linux-debug (pull_request) Has been skipped
ci / riscv64-linux-release (pull_request) Has been skipped
2026年06月27日 18:48:16 +02:00
Compare
@ -3177,1 +3188,3 @@
.freestanding,.other=>switch(target.cpu.arch){
.freestanding,
.other,
.ashetos,
Owner
Copy link

Putting this in the freestanding prong is not necessarily a problem, but it is a bit odd. Why not just add it to the prong below that has most OSs?

Putting this in the freestanding prong is not necessarily a problem, but it is a bit odd. Why not just add it to the prong below that has most OSs?
Author
Contributor
Copy link

We were using one of freestanding or other before iirc

We were using one of `freestanding` or `other` before iirc
Sign in to join this conversation.
No reviewers
Labels
Clear labels
abi/f32
abi/ilp32
abi/sf
accepted
This proposal is planned.
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
The web application for interactive documentation and generation of its assets.
backend/c
The C backend outputs C source code.
backend/llvm
The LLVM backend outputs an LLVM bitcode module.
backend/self-hosted
The self-hosted backends produce machine code directly.
binutils
Zig's included binary utilities: zig ar, zig dlltool, zig lib, zig ranlib, zig objcopy, and zig rc.
breaking
Implementing this issue could cause existing code to no longer compile or have different behavior.
build system
The Zig build system - zig build, std.Build, the build runner, and package management.
debug info
An issue related to debug information (e.g. DWARF) produced by the Zig compiler.
docs
An issue with documentation, e.g. the language reference or standard library doc comments.
error message
This issue points out an error message that is unhelpful and should be improved.
frontend
Tokenization, parsing, AstGen, ZonGen, Sema, Legalize, and Liveness.
fuzzing
An issue related to Zig's integrated fuzz testing.
incremental
Reuse of internal compiler state for faster compilation.
lib/c
This issue relates to Zig's libc implementation and/or vendored libcs.
lib/compiler-rt
This issue relates to Zig's compiler-rt library.
lib/cxx
This issue relates to Zig's vendored libc++ and/or libc++abi.
lib/std
This issue relates to Zig's standard library.
lib/tsan
This issue relates to Zig's vendored libtsan.
lib/ubsan-rt
This issue relates to Zig's ubsan-rt library.
lib/unwind
This issue relates to Zig's vendored libunwind.
linking
Zig's integrated object file and incremental linker.
miscompilation
The compiler reports success but produces semantically incorrect code.
os/android
os/contiki
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hermit
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
This issue suggests language modifications. If it also has the "accepted" label then it is planned.
release notes
This issue or pull request should be mentioned in the release notes.
testing
This issue is related to testing the compiler, standard library, or other parts of Zig.
zig cc
Zig as a drop-in C-family compiler.
zig fmt
The Zig source code formatter.
zig reduce
The Zig source code reduction tool.
bounty
https://ziglang.org/news/announcing-donor-bounties
bug
Observed behavior contradicts documented or intended behavior.
contributor-friendly
This issue is limited in scope and/or knowledge of project internals.
downstream
An issue with a third-party project that uses this project.
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
infra
An issue related to project infrastructure, e.g. continuous integration.
optimization
A task to improve performance and/or resource usage.
question
No questions on the issue tracker; use a community space instead.
regression
Something that used to work in a previous version stopped working
upstream
An issue with a third-party project that this project uses.
use case
Describes a real use case that is difficult or impossible, but does not propose a solution.
No labels
abi/f32
abi/ilp32
abi/sf
accepted
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
backend/c
backend/llvm
backend/self-hosted
binutils
breaking
build system
debug info
docs
error message
frontend
fuzzing
incremental
lib/c
lib/compiler-rt
lib/cxx
lib/std
lib/tsan
lib/ubsan-rt
lib/unwind
linking
miscompilation
os/android
os/contiki
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hermit
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
release notes
testing
zig cc
zig fmt
zig reduce
bounty
bug
contributor-friendly
downstream
enhancement
infra
optimization
question
regression
upstream
use case
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglang/zig!35954
Reference in a new issue
ziglang/zig
No description provided.
Delete branch "Der_Teufel/zig:ashetos-target"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?