Search code examples
elfred-lang

Understanding Red/System compilation optimizations compared to GCC


While reading the Red site, I came across a statement stating that compiling an hello world Red/System program creates..

"...a 162 bytes ELF binary, while a similar C code would produce a 5-6KB binary using Gcc"

That's amazing. Can someone explain/point me to the techniques making such optimizations possible?


Solution

  • It was achieved by having an almost empty runtime library (just a few syscalls wrappers) and an ELF emitter which would not align sections on 4K page boundaries for optimal loading.

    Though, that was true for Red/System 0.1.0, so in its very early days, not true anymore (now it would be similar to other compilers). Though we still have a -r compilation option for compiling Red/System code without any runtime, but as nobody uses it, it might not work anymore (should be easy to fix anyway if someone needs it, just drop by Red's chat and ask for it. ;-))