Current Minimal Binary Size
Wilfred Smith
wilfredsmith at fb.com
Tue Sep 17 00:10:12 AEST 2019
>
> 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
>
Andrew,
So glad you replied.
I’m doing a Bitbake build for a recipe that uses CMAKE:
add_executable( sizetest.bin source/sizebin.cpp)
target_compile_options( sizetest.bin PUBLIC -Os -s)
I don’t know if it matters, but I’m compiling in CentOS 7 with the OpenBMC/OpenBMC tree and my TemplateConf set to meta-facebook/meta-tiogapass.
arm-openbmc-linux-gnueabi-gcc (GCC) 9.2.0
I need to run an errand this morning, but will replicate your precise sequence a bit later today.
I’m always open to the possibility that I’m doing something wrong or missing something, but last time I checked, -Os generates the smallest possible code and -s strips symbols.
Wilfred
More information about the openbmc
mailing list