I have a AVR GCC toolchain compiled to work on aarch64-linux-gnu devices (ARM64) and it produced twice larger file (around 35Kb) than almost identical command-line on desktop (mac silicon, around 20Kb):
Android
13:41:48.329 8114 System.out I avr-g++ -no-canonical-prefixes -std=gnu++11 -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fpermissive -fno-threadsafe-statics -mmcu=atmega328p -DF_CPU=16000000L -MMD -flto -Wno-error=narrowing -DARDUINO=10607 -DARDUINO_ARCH_AVR -DARDUINO_AVR_UNO -v -I/data/user/0/com.app/files/sdk/hardware/arduino/variants/standard -I/data/user/0/com.app/files/sdk/hardware/arduino/cores/arduino /data/user/0/com.app/files/sdk/hardware/arduino/cores/arduino/HardwareSerial.cpp -o /data/user/0/com.app/files/coreBuild/HardwareSerial.cpp.o
Desktop
/Users/developer/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/developer/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/developer/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/standard /Users/developer/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino/HardwareSerial.cpp -o /Users/developer/Library/Caches/arduino/sketches/7DB601531F17D390EF34F3CA8F8B77C9/core/HardwareSerial.cpp.o
I've passed "-v" flag and i can see the binaries are configured with different flags.
Android:
13:41:48.334 8114 System.err W Configured with: /home/developer/tools/ct-ng_1.24.0-f7b1ece/build/.build/HOST-aarch64-linux-gnu/avr/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=aarch64-host_unknown-linux-gnu --target=avr --prefix=/home/developer/x-tools/HOST-aarch64-linux-gnu/avr --with-local-prefix=/home/developer/x-tools/HOST-aarch64-linux-gnu/avr/avr --with-headers=/home/developer/x-tools/HOST-aarch64-linux-gnu/avr/avr/include --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG 1.24.0-rc3.1-f7b1ece' --disable-__cxa_atexit --disable-libgomp --disable-libmudflap --disable-libmpx --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/home/developer/tools/ct-ng_1.24.0-f7b1ece/build/.build/HOST-aarch64-linux-gnu/avr/buildtools/complibs-host --with-mpfr=/home/developer/tools/ct-ng_1.24.0-f7b1ece/build/.build/HOST-aarch64-linux-gnu/avr/buildtools/complibs-host --with-mpc=/home/developer/tools/ct-ng_1.24.0-f7b1ece/build/.build/HOST-aarch64-linux-gnu/avr/buildtools/complibs-host --disable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++ -lm' --enable-target-optspace --disable-nls --enable-multiarch --enable-languages=c,c++ --enable-plugins --enable-lto
...
13:41:48.336 8114 System.err W GNU C++11 (crosstool-NG 1.24.0-rc3.1-f7b1ece) version 7.3.0 (avr)
13:41:48.336 8114 System.err W compiled by GNU C version 7.5.0, GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9, isl version none
Desktop:
Configured with: ../gcc/configure --enable-fixed-point --enable-languages=c,c++ --prefix=/Users/jenkins/jenkins/workspace/avr-gcc-staging/label/mac-mini/objdir --disable-nls --disable-libssp --disable-libada --disable-shared --with-avrlibc=yes --with-dwarf2 --disable-doc --target=avr
Thread model: single
...
GNU C++11 (GCC) version 7.3.0 (avr)
compiled by GNU C version 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9, isl version none
What argument makes an impact on final .o file size to make it twice larger? Is it possible to avoid rebuilding toolchain and pass some runtime (cmd) arguments to avoid using what something that inflates the file?