Vulkan Mystery

I’ve created a static linux binary that can use vulkan! You can find the code at GitHub - marler8997/vow: Vulkan Over the Wire

However, before looking at the code to see how it was done, I’ve uploaded a prebuilt 250Kb x86_64 binary you can download and test for yourself:

curl -L -o triangle https://github.com/marler8997/vow/releases/download/mystery/triangle && chmod +x triangle

Poke around and see if you can figure out how it was done

It currently relies on x11 but I’m hoping to make it work natively on wayland as well. I haven’t tested it but it should work even if you’re on a system that uses “exotic” runtime loader locations (cough nixos). I’m curious what theories people come up with or alternative approaches people might have.

9 Likes

I am guessing you manually load it at runtime, searching possible library paths. Andrew himself did exactly that a while ago, with vulkan too (maybe it was opengl?), unfortunately his binary no longer works last I checked

Correct me if I’m wrong, but it appears that this approach produces a static binary that will only work with glibc. It fails to run on my musl-based distro, and the project won’t build due to the libc runtime so names being different. Andrew’s old zig-window binary still runs fine on my system.

Maybe something like Detour (GitHub - graphitemaster/detour: A detour through the Linux dynamic linker) would be useful in this case?

My take on this is this project, which implements a dynamic loader for linux x86_64. It works with glibc and musl, since the system libc is loaded like any other dynamic library when loading dependencies. I have been reporting progress in this thread. There is also an x11 + vulkan example. I am currently using it, as I recently started working on a desktop app framework that produces very portable static libc-free executables that work with X11 or Wayland and CPU or GPU rendering. Having dlopen in zig unleashes a lot of use cases. :slight_smile:

1 Like

hmm

do you use venus protocol ?