dietlibc | Inofficial git-cvs clone
kandi X-RAY | dietlibc Summary
kandi X-RAY | dietlibc Summary
The system library is a challenge to all those using the computer to write their own faster and better routines or to bow to the superior strength and skill of a true master. --Use diet libc to statically link programs that don't need all the bloat from glibc. malloc, printf and scanf contributed from Olaf Dreesen. make should compile the diet libc itself.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dietlibc
dietlibc Key Features
dietlibc Examples and Code Snippets
Community Discussions
Trending Discussions on dietlibc
QUESTION
I am trying to find dietlibc source code for basic functions like printf, puts, etc. Currently using grep {command_name} -r -A20 in the folder where they should be, but it seems really exhausting. Is there any faster way?
Another known way is to reverse object files for each function, but i think it will take more time.
...ANSWER
Answered 2020-Sep-18 at 20:00I've already found folder with *.S files, but for the most basic functions such as printf() there are only .c files
Many functions are written in C, and they're written in terms of other C functions and/or assembly language functions. So printf()
(in .../libstdio/printf.c
), for example, uses vprintf()
, which uses __v_printf()
(in .../lib/__v_printf.c
), which uses strcpy()
and strlen()
etc., which have ARM implementations in .../arm
. Some functions are implemented both in C and assembly, probably because assembly provides a performance boost on some architectures but not others (or possibly because nobody has gotten around to writing assembly versions for some architectures).
So, if you're looking for printf.S
, you're probably not going to find it for any architecture because it's a relatively high level function that calls other functions. That means that you can port dietlibc to a new architecture without having to write assembly versions of every function in the library; you only have to implement a small set of essential routines. Read the PORTING file to get an idea of what has to be done to port to a new architecture, and that'll help you understand what those core routines are. Or, just look in several of the architecture-specific directories and see what they implement.
QUESTION
So, I did a lot of experimentation with Emscripten. And what I noticed pretty much is that the musl-libc that is being used is impressively huge...like, really huge. A simple "Hello, World!" printing app is way above the 10kb...which is by far not practical.
Now how can I reduce this? So far, I figured that I could use -Os
and --closure 1
. But the latter only really works over JavaScript, so it does not affect the Wasm output.
What else can I do? Use a different libc implementation, maybe? I looked at uClibc and dietlibc as well as Metallic. I also thought about looing for a cheap - filesize-wise - deflate function so I could transfer a gzipped version of the Wasm binary. But so far, that is all I got.
Any suggestions? My last try was:
...ANSWER
Answered 2019-Feb-19 at 00:33printf()
, consider using puts()
.
In my experiment, printf()
version of "Hello world" is whopping 13KB, and puts()
version is as small as 2KB.
You say "A simple "Hello, World!" printing app
", but it is actually not true in the wider perspective because printf()
is by far the biggest part of the C standard library in terms of the binary size. Actually I am a bit surprised that they managed reducing it to 13KB. This is mainly because of the %
formatting. Not only printf()
deals with simple formats such as %c
, %d
, and %ld
, but it has to deal with complex formats such as %4.2f
, %+.0e
, %E
, and %*d
.
Apart from the web application, this is a common problem in the embedded systems where you should statically link against stdlib and the available program memory size is often as small as 10kb. Just google "printf size in embedded system", you will easily see a lot of hates around printf() and a lot of efforts to reduce size of it.
Switching stdlib like uClibc and dietlibc won't help much because they still are libraries for the POSIX system which implements a full specification of printf(). You should look for stdlibs for bare-metal embedded systems such as newlib-nano that implements a subset of printf() specification to reduce the binary size. Moreover, I don't think switching stdlib for Emscripten is almost an impossible job because Emscripten uses significantly hacked version of musl-libc for their use case.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dietlibc
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page