💾 Archived View for tilde.pink › ~kaction › log › 2022-08-06.1.gmi captured on 2023-09-08 at 16:34:12. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Thoughts on separate compilation (part 2)

Continuing musing on how to recover C language optimization lost to separate compilation.

./2022-07-14.1.gmi

As proof of concept, I made tool that takes C source and appends unique hash to every static definition and adjusts references accordingly. After that we can concatenate individual files, eliminate duplicate declarations/definitions and finally feed it to the compiler. Here is the link to the tool source:

https://git.sr.ht/~kaction/cstatic

It actually worked! For GNU Ed=1.4, compiled with gcc=9.3.0 on Alpine=3.11 with "-Os -s" flags, trickery with "cstatic" saved 4Kb, from 47144 bytes to 43080. Next step was to inline whole standard library, so I decided to do the same with musl C library.

That didn't work out of the box, for many reasons, but most importantly, musl has multiple distinct definitions of "struct cookie". I didn't found anything short of forking to solve this problem.

Anyway, here is the current state of my research on how to save couple kilobytes in the world that eagerly wastes megabytes to read 140 byte text message.