System calls are the most critical interface of all user space software. They are the means of invoking kernel's functionality. Without them, software would not be able to communicate with the user, access the file system or establish network connections.
Every kernel provides a very specific set of system calls, even if there is a similar set of libc APIs available on different systems. For example, the system call set greatly differs between Linux and FreeBSD.
MacOS uses a kernel named XNU. XNU's system calls differ greatly from those of Linux, which is why XNU system call emulation is at the heart of Darling.
Unlike other kernels, XNU has three distinct system call tables:
int 0x82. There is only a few of them and they are mainly related to Thread Local Storage.
Darling emulates system calls by providing a modified
/usr/lib/system/libsystem_kernel.dylib library, the source code of which is located in
src/kernel. Even though some parts of the emulation are located in Darling's kernel module (located in
src/lkm), Darling's emulation is user space based.
This is why
libsystem_kernel.dylib (and also
dyld, which contains a static build of this library) can never be copied from macOS to Darling.
Emulating XNU system calls directly in Linux would have a few benefits, but isn't really workable. Unlike BSD kernels, Linux has no support for foreign system call emulation and having such an extensive and intrusive patchset merged into Linux would be too difficult. Requiring Darling's users to patch their kernels is out of question as well.