Error: warning(link): unexpected LLD stderr: neither ET _REL nor LLVM bitcode

I’m trying to use Nuklear with sdl2.

build.zig of sample project

build.zig of sdl2 bindings

build.zig of nuklear bindings

I get this error with --release=fast:

$ rm -rf .zig-cache/ zig-out/ && zig build --release=fast

install
└─ install nk-sdl-example
   └─ compile exe nk-sdl-example ReleaseFast native failure
error: warning(link): unexpected LLD stderr:
ld.lld: warning: .zig-cache/o/ed92cb6971b11603cbe3d0a2565bc25c/libnk_sdl_renderer_backend.a: archive member '/usr/lib/x86_64-linux-gnu/libSDL2.so' is neither ET
_REL nor LLVM bitcode

$ ls -l zig-out/bin/nk-sdl-example 
-rwxrwxr-x 1 gianmaria gianmaria 1661592 feb  6 02:00 zig-out/bin/nk-sdl-example

Note that the executable is still built and it appears to work, and if I do again (forcing a rebuild by changing a comment)

$ zig build --release=fast
$ ls -l zig-out/bin/nk-sdl-example 
-rwxrwxr-x 1 gianmaria gianmaria 1661592 feb  6 02:00 zig-out/bin/nk-sdl-example

there are no errors (that’s why I was doing rm -rf .zig-cache/ zig-out/ before), and the executable still works (and has the same size).

What does that mean? How to fix it?

I believe it is this bug: Incorrect archiver Command Line Call When Linking a Static "System" Library to another Static Library · Issue #20476 · ziglang/zig · GitHub

Thanks, for now I kind of fixed it by only adding include paths instead of linking the library:

    nk_sdl_lib.addSystemIncludePath(.{ .cwd_relative = "/usr/include/SDL2" });

(actually using a different helper right now but this worked in this case)

1 Like