Zig fails to build my project with unhelpful error message

After adding this code to my project, the compiler fails to build it with no error message at all. I’m using Zig version 0.15.2.

Here’s the error message:

install
└─ install ness
   └─ compile exe ness Debug native failure
error: the following command terminated unexpectedly:
/home/labatata/Downloads/zig-x86_64-linux-0.15.2/zig build-exe -fllvm -fno-strip -ODebug --dep ness -Mroot=/home/labatata/Code/Zig/8bit-emulator/src/main.zig .zig-cache/o/f517a313cf88065690fe32b3cd42db0d/libSDL3.a .zig-cache/o/d75169ef4a66fad01dafda99fda166d4/libblip_buf.a -I .zig-cache/o/a405d7d25f945e38b8a0cca5dd710db8 -I /home/labatata/Code/Zig/8bit-emulator/third-party/blip_buf-1.1.0 -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 -Mness=/home/labatata/Code/Zig/8bit-emulator/src/root.zig -lc --cache-dir .zig-cache --global-cache-dir /home/labatata/.cache/zig --name ness --zig-lib-dir /home/labatata/Downloads/zig-x86_64-linux-0.15.2/lib/ --listen=-

Build Summary: 7/10 steps succeeded; 1 failed
install transitive failure
└─ install ness transitive failure
   └─ compile exe ness Debug native failure

error: the following build command failed with exit code 1:
.zig-cache/o/e1b6bfd2cde9b06c346af1f0902faeb9/build /home/labatata/Downloads/zig-x86_64-linux-0.15.2/zig /home/labatata/Downloads/zig-x86_64-linux-0.15.2/lib /home/labatata/Code/Zig/8bit-emulator .zig-cache /home/labatata/.cache/zig --seed 0xd8929d99 -Zcb851105fa437907

I’ve already tried deleting the cache but got the same error.

I don’t know why, but here are some steps which are showing more info:

zig build --verbose-link --verbose-air --verbose-cc --debug-rt

error: the following command terminated unexpectedly:
/Users/trj/Desktop/org/zig/zig0152/zig-aarch64-macos-0.15.2/zig build-exe -fllvm -fno-strip -ODebug --dep ness -Mroot=/Users/trj/Desktop/org/zig/git/NESS/src/main.zig .zig-cache/o/4ab1b25ddbc6620ff963b19e5172a8fe/libSDL3.a .zig-cache/o/53405497440d7e3817a7dd3351ef314d/libblip_buf.a -I .zig-cache/o/0fc21f84b22e5c6866935b635cc15b29 -I /Users/trj/Desktop/org/zig/git/NESS/third-party/blip_buf-1.1.0 -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 -Mness=/Users/trj/Desktop/org/zig/git/NESS/src/root.zig -framework CoreMedia -framework CoreVideo -framework Cocoa -weak_framework UniformTypeIdentifiers -framework IOKit -framework ForceFeedback -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AVFoundation -framework Foundation -framework GameController -framework Metal -framework QuartzCore -weak_framework CoreHaptics -lc --verbose-air --verbose-link --verbose-cc --cache-dir .zig-cache --global-cache-dir /Users/trj/.cache/zig --debug-rt --name ness --zig-lib-dir /Users/trj/Desktop/org/zig/zig0152/zig-aarch64-macos-0.15.2/lib/ --listen=-

So, I run that by hand (skipping the final --listen=-)

/Users/trj/Desktop/org/zig/zig0152/zig-aarch64-macos-0.15.2/zig build-exe -fllvm -fno-strip -ODebug --dep ness -Mroot=/Users/trj/Desktop/org/zig/git/NESS/src/main.zig .zig-cache/o/4ab1b25ddbc6620ff963b19e5172a8fe/libSDL3.a .zig-cache/o/53405497440d7e3817a7dd3351ef314d/libblip_buf.a -I .zig-cache/o/0fc21f84b22e5c6866935b635cc15b29 -I /Users/trj/Desktop/org/zig/git/NESS/third-party/blip_buf-1.1.0 -I .zig-cache/o/a6fb089e932f705ef1065695b36c6e90 -Mness=/Users/trj/Desktop/org/zig/git/NESS/src/root.zig -framework CoreMedia -framework CoreVideo -framework Cocoa -weak_framework UniformTypeIdentifiers -framework IOKit -framework ForceFeedback -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AVFoundation -framework Foundation -framework GameController -framework Metal -framework QuartzCore -weak_framework CoreHaptics -lc --verbose-air --verbose-link --verbose-cc --cache-dir .zig-cache --global-cache-dir /Users/trj/.cache/zig --debug-rt --name ness --zig-lib-dir /Users/trj/Desktop/org/zig/zig0152/zig-aarch64-macos-0.15.2/lib/
Trace/BPT trap: 5ng

https://stackoverflow.com/questions/14675206/what-is-trace-bpt-trap-5 says:

It has to do with not being able to find/load a dylib, which is specific to OSX. Which one it can’t find, is as you have found out is application specific.

Running that command without the --listen=- results in a segmentation fault (core dumped) on my machine.

This seems like a compiler bug in the llvm codegen on inline functions (Edit: the bug is most likely in an earlier compiler step, but has to do with inline functions). You don’t hit it, if you remove the inline keyword of functions.

That was it, thanks!