Hacker News new | ask | show | jobs
by forrestthewoods 13 days ago
My kingdom for Zig to have an official mechanism to emit the Linux library stubs.

Zig’s ability to crosscompile and target arbitrary versions of glibc is PURE MAGIC. I leverage this magic in an unrelated C++ build system. But I have to hack around to get those library stubs from Zig. Would love it to be an official output.

1 comments

Interesting. So here's my pretty hacky take on it.

https://github.com/forrestthewoods/anubis/blob/983d8a1b9ea5e...

It invokes zig on a dummy C or CPP file. Then it scrapes the output looking for specific files.

C: crt1.o, libm.so, libpthread.so, libc.so, libdl.so, librt.so, libld.so, libutil.so, libresolv.so, libc_nonshared.a, libcompiler_rt.a

C++: crt1.o, libc++abi.a, libc++.a, libunwind.a, libm.so, libpthread.so, libc.so, libdl.so, librt.so, libld.so, libutil.so, libresolv.so, libc_nonshared.a, libcompiler_rt.a

Zig is also a god send in that it has all the generated glibc header bullshit for Linux.

I've got a system that is able to cross-compile ffmpeg for Linux from Windows. Which is a shockingly painful and rare capability. Linux userspace design is so so so so so bad. So embarrassingly bad.

Andrew Kelley is a damn saint for the mountains he moved for Zig. https://andrewkelley.me/post/zig-cc-powerful-drop-in-replace...

Now I just wish some of this capability was exposed in a slightly more formal capacity so that it could be leveraged by the broader community :)