-- Leo's gemini proxy

-- Connecting to gemini.kaction.cc:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

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.

-- Response ended

-- Page fetched on Fri May 10 05:39:03 2024