nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

[BUG] hello_zig fails to build on sim:x86_64 with Zig 0.13.0

Open ML-dev-crypto opened this issue 4 months ago • 3 comments

Description / Steps to reproduce the issue

Description / Steps to reproduce the issue

While testing the Zig hello_zig example on sim:x86_64, I found that it cannot be built with Zig 0.13.0 due to two build issues.

Steps to reproduce

  1. Configure NuttX for sim:x86_64.
  2. Enable the Zig hello example:
    CONFIG_EXAMPLES_HELLO_ZIG=y
    
  3. Build NuttX.

The build first fails because tools/Zig.defs generates the following target:

-target x86_64-freestanding-sysv

However, Zig reports:

error: unknown ABI: 'sysv'

After locally changing the target to a Zig-supported ABI, the build proceeds further but then fails during linking with:

undefined reference to `__zig_probe_stack'

The generated Zig object references __zig_probe_stack, but the required compiler runtime is not linked.

After applying local changes, the project builds successfully and the example runs correctly:

NuttShell (NSH)

nsh> hello_zig
[sim]: Hello, Zig!

At this point I'm unsure what the preferred upstream approach is for addressing these two build issues, so I'm opening this issue first before preparing a patch.


On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Ubuntu 24.04 LTS (WSL2)

NuttX Version

master

Issue Architecture

[Arch: x86], [Arch: x86_64]

Issue Area

[Area: Build System]

Host information

Host information

  • Zig 0.13.0
  • GCC host toolchain
  • x86_64 Linux (WSL2)

Verification

  • [x] I have verified before submitting the report.

ML-dev-crypto avatar Jul 18 '26 20:07 ML-dev-crypto

@yf13 ,@xiaoxiang781216 ,@acassis I have a local patch that addresses both build failures. The first change updates the generated Zig target to use a Zig-supported ABI, and the second adds the required compiler runtime so the linker can resolve __zig_probe_stack. With these changes, hello_zig builds and runs successfully on sim:x86_64. Could you please take a look and let me know if this seems like the right direction? If so, I'll clean it up and submit a patch.

ML-dev-crypto avatar Jul 18 '26 20:07 ML-dev-crypto

@yf13 ,@xiaoxiang781216 ,@acassis I have a local patch that addresses both build failures. The first change updates the generated Zig target to use a Zig-supported ABI, and the second adds the required compiler runtime so the linker can resolve __zig_probe_stack. With these changes, hello_zig builds and runs successfully on sim:x86_64. Could you please take a look and let me know if this seems like the right direction? If so, I'll clean it up and submit a patch.

yes, please provide a fix.

xiaoxiang781216 avatar Jul 19 '26 05:07 xiaoxiang781216

@xiaoxiang781216 Done. I've submitted the fix in #19477.

ML-dev-crypto avatar Jul 19 '26 07:07 ML-dev-crypto