logoalt Hacker News

Zig Libc

167 pointsby ingveyesterday at 5:28 PM63 commentsview on HN

Comments

OsamaJaberyesterday at 10:46 PM

250 C files were deleted. 2032 to go. Watching Zig slowly eat libc from the inside is one of the more satisfying long term projects to follow

tiffanyhtoday at 2:08 AM

Does this mean long term Zig won’t run on OpenBSD?

Because doesn’t OpenBSD block direct syscalls & force everything to go through libc.

https://news.ycombinator.com/item?id=38039689

show 2 replies
xrdyesterday at 10:29 PM

"Abolish ICE" at the bottom. Obviously a Bad Bunny fan, as I am.

show 5 replies
jzelinskieyesterday at 9:54 PM

Cool idea, for sure, but I can't help but wonder: for the code that's been ported, is there a concern that you'd have to perpetually watch out for CVEs in glibc/musl and determine if they also apply to the Zig implementations?

show 1 reply
generichumantoday at 12:55 AM

This is very exciting for zig projects linking C libraries. Though I'm curious about the following case:

Let's say I'm building a C program targeting Windows with MinGW & only using Zig as a cross compiler. Is there a way to still statically link MinGW's libc implementation or does this mean that's going away and I can only statically link ziglibc even if it looks like MinGW from the outside?

show 1 reply
meiselyesterday at 10:45 PM

> It’s kind of like enabling LTO (Link-Time Optimization) across the libc boundary, except it’s done properly in the frontend instead of too late, in the linker

Why is the linker too late? Is Zig able to do optimizations in the frontend that, e.g., a linker working with LLVM IR is not?

show 1 reply
nesarkvechnepyesterday at 9:36 PM

"Furthermore, when this work is combined with the recent std.Io changes, there is potential for users to seamlessly control how libc performs I/O - for example forcing all calls to read and write to participate in an io_uring event loop"

This is exciting! I particularly care more about kqueue but I guess the quote applies to it too.

squirrelloustoday at 2:09 AM

I’m sure this has crossed someone’s mind but why isn’t this called zlibc? :-)

show 1 reply
ciesyesterday at 9:30 PM

Super cool project.

I expect a lot of C code may be quite mechanically translated to Zig (by help of LLMs). Unlike C->Rust or C->C++, where there's more of a paradigm shift.

show 1 reply
nameconflictstoday at 12:41 AM

[flagged]

show 1 reply
self_awarenessyesterday at 10:53 PM

[flagged]

show 3 replies
nemo1618yesterday at 9:52 PM

This strikes me as a very agent-friendly problem. Given a harness that enforces sufficiently-rigorous tests, I'm sure you could spin up an agent loop that methodically churns through these functions one by one, finishing in a few days.

show 3 replies