Why do programs like glibc need the Linux Kernel headers? The Linux API is provided via syscalls, and other libc implementations such as musl do not require these headers.
What makes glibc special?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Syscalls are not different from normal function calls, except for the calling mechanism. Just as with normal C function calls, you need to know that parameters and of which type the called function expects, and what the return value is. As an example, look at the
stat system call which takes as a parameter a pointer to a
struct stat. The kernel and user space code must agree upon how the data is structured, and the definitive source for the type definition of this is the kernel.
Now, because the kernel API comes with a stability guarantee, these data types rarely ever change. Therefore the Musl developers have found it easier to simply maintain manually edited copies of the definitions rather than rely on the kernel headers. The Musl source code contains, for example, its own list of system call numbers in the file