Dynamic linking without libc adventures

Vulkan triangle from a static executable without libc: achieved!

This is a direct copy-paste of the vulkan-zig triangle example, where uses of glfw to load vulkan and create/manage the window have been replaced by calls to the dynamic loader and direct x11 window handling. Source is here.

Tested the same executable (!) on multiple ubuntu machines (one is kinda old), on a manjaro one, and surprisingly it also works on the chimera virtual machine.
Since implementing some thread safety was required, and was done in a not fully correct way to speed things up (maybe I was starting to feel vulkan fatigue…), I’m starting to think that the great rewrite is coming.

I also tested that loading the ubuntu bundled glibc versions since 2.23 (april 2016) works. I discovered some nasty bugs while going back in time. To my knowledge, distributions don’t patch glibc too much, so I think this is a good methodology.
I plan to do the same for musl, using chimera and void. I already know that musl pre-1.2.1 will have problems (the __libc struct wasn’t the same before that).

I should take a step back from this project for a couple of months, since my real life work is slowly getting deprioritized, and projecting the current trend leads to bankruptcy :slight_smile:

17 Likes