Current Minimal Binary Size
Andrew Jeffery
andrew at aj.id.au
Mon Sep 16 13:45:50 AEST 2019
Hi Wilfred,
On Fri, 13 Sep 2019, at 22:22, Wilfred Smith wrote:
> These values may be of use to someone else. I’ve been putting energy
> into reducing code size lately. The following are all with -Os enabled.
>
> Smallest .SO (one function with no statements in the body) - 8.2K
> Smallest executable (main with only a return statement) - 12K
> Smallest executable with a printf and return - 14K
> Smallest executable with a std::cout and return - 103K
Out of curiosity, how are you generating these results? For instance using
the Ubuntu ARM GCC cross compiler I have a smallest executable of less
than half the size of what you list above:
$ arm-linux-gnueabi-gcc --version
arm-linux-gnueabi-gcc (Ubuntu/Linaro 8.3.0-6ubuntu1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat empty.c
int main(void)
{
return 0;
}
$ make empty CC=arm-linux-gnueabi-gcc CFLAGS=-Os && arm-linux-gnueabi-strip empty && ls -l empty
arm-linux-gnueabi-gcc -Os -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed empty.c -o empty
-rwxr-xr-x 1 andrew andrew 5544 Sep 16 13:08 empty
$ size empty
text data bss dec hex filename
759 276 4 1039 40f empty
Admittedly it's not the SDK cross-compiler, but some more clarity
on how you came to those numbers would be helpful.
Andrew
More information about the openbmc
mailing list