All the magic seems to happen in
const lib = b.addLibrary(.{
.linkage = .static,
.name = "cgo_static_linking",
.root_module = lib_mod,
});
and
/*
#cgo LDFLAGS: -L./zig-out/lib -lcgo_static_linking -static
#include "zig_lib.h"
*/
Now I can only guess why it works. A bit of an explanation wouldn't hurt.
Good post btw