Nolibc: a minimal C-library replacement shipped with the kernel
Nolibc: a minimal C-library replacement shipped with the kernel
Posted Jan 21, 2023 6:02 UTC (Sat) by wtarreau (subscriber, #51152)Parent article: Nolibc: a minimal C-library replacement shipped with the kernel
Based on previous discussions for splitting nolibc into multiple files, the point was raised a few times that what is desired is to have the OS-independent stuff being either self-sustaining (e.g. memcpy()) or relying on a portable syscall API and _start code, and that's why we split the code like this (probably far from being perfect yet). In a modern world we could imagine the stdlib being provided with the language (and toolchain) and the syscall with the OS and arch, both in source form so that they're built on the fly with the resulting program. Maybe building the high-level stuff would be slow once the lib becomes rich though.
Posted Jan 21, 2023 8:21 UTC (Sat)
by WolfWings (subscriber, #56790)
[Link] (5 responses)
In theory all the tools are there, libc.so could be a set of much smaller components that could be dlopen'ed transparently the first time any given families of functions are called and instrumented to let other software only copy over actually required components, but that's less "efficient" (performance hits, re-using mappings across processes, etc) for the normal system case where hundreds of tools will all be loading libc in parallel.
So instead they're even removing separate libraries and merging them into libc.so lately like pthreads and bulking up the single monolithic library even more.
Posted Jan 22, 2023 2:19 UTC (Sun)
by wahern (subscriber, #37304)
[Link] (1 responses)
A major reason for musl's lighter footprint is eschewing locale support--the original idea was that simply being UTF-8 clean would suffice for a POSIX-compliant environment, though they eventually had to backtrack somewhat even after some concessions from [future] POSIX. glibc's locale support adds alot of weight, and significantly impacts performance. OTOH, this is probably one of the more justifiable features of glibc; at least, justifiable at a time when Unix environments, and libc specifically, were more often relied upon for higher-level application interfaces--timekeeping, I18N, string processing, etc. OTOOH, simply avoiding locale interfaces entirely, POSIX be damned, is one of the easiest choices to justify for a lightweight, embedded libc.
Posted Jan 22, 2023 2:49 UTC (Sun)
by Cyberax (✭ supporter ✭, #52523)
[Link]
No, it's not. It would have been justifiable if the interface were a little bit more thought out. But it's thread-unsafe and clunky.
Posted Apr 11, 2023 22:38 UTC (Tue)
by Phoenix591 (guest, #157780)
[Link]
boots faster than the autogenerated giant initrds too.
Posted Apr 20, 2023 11:32 UTC (Thu)
by anselm (subscriber, #2796)
[Link] (1 responses)
Systems like Linux already use “demand paging”, i.e., only those pages of libc.so (or any executable) that contain code which is actually being executed are fetched into memory (and evicted again if their code hasn't been executed in some time). Chances are that, with loads of different processes using libc.so simultaneously, almost all of it will be used by something, but in principle the system is pretty good at ignoring unneeded stuff, so the added complication of subdividing libc.so seems unnecessary.
Posted Apr 21, 2023 10:20 UTC (Fri)
by farnz (subscriber, #17727)
[Link]
Rather than splitting libc.so, then, would a better option be to work out what pages of libc are commonly used together, and group things such that you don't page in the bits you're not going to use? That way, you need only build system changes to libc (possibly quite big ones), but then all applications benefit immediately (e.g. if you don't ever use the X/Open Message Catalog interface for message translation, you don't page in any of the functions involved in that interface).
Nolibc: a minimal C-library replacement shipped with the kernel
Nolibc: a minimal C-library replacement shipped with the kernel
Nolibc: a minimal C-library replacement shipped with the kernel
Nolibc: a minimal C-library replacement shipped with the kernel
Nolibc: a minimal C-library replacement shipped with the kernel
In theory all the tools are there, libc.so could be a set of much smaller components that could be dlopen'ed transparently the first time any given families of functions are called and instrumented to let other software only copy over actually required components, but that's less "efficient" (performance hits, re-using mappings across processes, etc) for the normal system case where hundreds of tools will all be loading libc in parallel.
Nolibc: a minimal C-library replacement shipped with the kernel