This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 522ae4cb3f9 tools/Zig.defs: Fix Zig builds on sim:x86_64
522ae4cb3f9 is described below
commit 522ae4cb3f9032e7a2f092932a2c49277ddc2bec
Author: Ansh Rai <[email protected]>
AuthorDate: Sun Jul 19 06:58:36 2026 +0000
tools/Zig.defs: Fix Zig builds on sim:x86_64
Building Zig applications on sim:x86_64 with Zig 0.13.0 fails because
the generated target "x86_64-freestanding-sysv" is not recognized by
Zig. Introduce a Zig-specific ABI mapping that translates "sysv" to
"gnu" without affecting other toolchains.
After correcting the target ABI, linking still fails due to unresolved
references to __zig_probe_stack. Add -fcompiler-rt so Zig includes the
required compiler runtime during linking.
Verified on sim:nsh with CONFIG_EXAMPLES_HELLO_ZIG=y:
nsh> hello_zig
[sim]: Hello, Zig!
Fixes #19475
Signed-off-by: Ansh Rai <[email protected]>
---
tools/Zig.defs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/Zig.defs b/tools/Zig.defs
index 6feabe72e22..18f7424c995 100644
--- a/tools/Zig.defs
+++ b/tools/Zig.defs
@@ -36,7 +36,13 @@ else ifeq ($(CONFIG_ARCH_RISCV),y)
ZIGFLAGS += -mcmodel=medium
else
- ZIGFLAGS := -target $(LLVM_ARCHTYPE)-freestanding-$(LLVM_ABITYPE)
+ ifeq ($(LLVM_ABITYPE),sysv)
+ ZIG_ABITYPE := gnu
+ else
+ ZIG_ABITYPE := $(LLVM_ABITYPE)
+ endif
+
+ ZIGFLAGS := -target $(LLVM_ARCHTYPE)-freestanding-$(ZIG_ABITYPE)
endif
# Convert cortex-xxx/sifive-exx to cortex_xxx/sifive_exx
@@ -44,3 +50,5 @@ endif
ifneq ($(LLVM_CPUTYPE),)
ZIGFLAGS += -mcpu $(subst -,_,$(LLVM_CPUTYPE))
endif
+
+ZIGFLAGS += -fcompiler-rt