Hacker News new | past | comments | ask | show | jobs | submit login

I'm 100% with Linus on this one.



Linus ships a kernel –– where would his stable interface live if not the syscall ABI? The *BSD and macOS folks ship operating systems, where they have the option of defining their ABI at a higher level of abstraction.


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.


> 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.


They could but they didn't. At some point, Linux almost got its own klibc. The developers realized such a thing wasn't needed in the kernel. Greg Kroah-Hartman told me about it when I asked on his AMA:

https://old.reddit.com/r/linux/comments/fx5e4v/im_greg_kroah...

The importance of this design should not be understated. It's not really an obvious thing to realize. If it was, every other operating system and kernel out there would be doing it as well. They aren't. They all make people link against some library.

So Linux is actually pretty special. It's the only system where you actually can trash the entire userspace and rewrite the world in Rust. Don't need to link against any "core" system libraries. People usually do but it's not forced upon them.

> if Linux wants to avoid breaking userspace with kernel updates, then it needs a stable syscall interface

Every kernel and operating system wants to maximize backwards compatibility and minimize user space breakage. Most of them simply stabilize the system libraries instead. The core libraries are stable, the kernel interfaces used by those core libraries are not.

So it doesn't follow that it needs a stable syscall interface. They could have solved it via user space impositions. The fact they chose a better solution is one of many things that makes Linux special.


> The importance of this design should not be understated. It's not really an obvious thing to realize. If it was, every other operating system and kernel out there would be doing it as well.

No, they would not. I can say this with confidence because at any point in the last several decades, any OS vendor could have started to do so, and they have not. They have uniformly decided that having a userspace library as their stable kernel interface is easier to maintain, so that's what they do. The idea that the rest of the world hasn't "realized" that, in addition to maintaining binary compatibility in their libc, they could also maintain binary compatible syscalls is nonsensical.

The Linux kernel, on the other hand, doesn't ship a userspace. If they wanted their stable interface to be a userspace library, they'd need to invent one! And that would be more work than providing stable syscalls.

> So Linux is actually pretty special. It's the only system where you actually can trash the entire userspace and rewrite the world in Rust.

That's not rewriting the world, that would be a new userspace for the Linux kernel. You're still calling down into C, there's just one fewer indirection along the way.

> So it doesn't follow that it needs a stable syscall interface. They could have solved it via user space impositions.

They could have, but as Greg Kroah-Hartman pointed out, that would have just shifted the complexity around. Stability at the syscall level is the simplest solution to the problem that the Linux project has, so that's what they do.

It would be pretty funny if the kernel's stability strategy was in service of allowing userspace to avoid linking a C library, considering it's been 30+ years and the Linux userspace is almost entirely C and C++ anyway.


I mean they could stuff kernel libc into vDSO.


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


And for what it's worth, the reason Windows has such a high binary backwards compatibility that win 98 programs can easily run on win 11 or so is that they have this extra abstraction layer.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: