logoalt Hacker News

matheusmoreira11/08/20242 repliesview on HN

Linux could have made their own libc and mandated use of it. But they didn't. They chose a language agnostic binary interface that's documented at the instruction set level.

As a result of that brilliant design choice, every single language can make Linux system calls natively. It should be simple for JIT compilers to generate Linux system call code. No need to pull in some huge C library just for this. AOT compilers could have a linux_system_call builtin that just generates the required instructions. I actually posted this proposal to the GCC mailing list.


Replies

favorited11/08/2024

> Linux could have made their own libc

That's not what Linux is, though. It's a kernel. libc is a userspace library. The Linux developers could also make their own libpng and put their stable interface in there, but that's not in scope for their project.

> As a result of that brilliant design choice, every single language can make Linux system calls natively.

That is like saying it's a brilliant design choice for an artist to paint the sky blue on a sunny day. If Linux is a kernel, and if a kernel's interface with userspace is syscalls, and if Linux wants to avoid breaking userspace with kernel updates, then it needs a stable syscall interface.

> No need to pull in some huge C library just for this.

Again, I'm not sure why the Linux project would invent this "huge C library" to use as their stable kernel interface.

show 2 replies
titzer11/08/2024

Exactly, a stable language-agnostic binary ABI is the proper layering choice.