4 ms·
Compiling with -Os brings it down to 800 KB. % gcc -c sqlite3.c % ls -l sqlite3.o -rw-r--r-- 1 dalke admin 1270372 Feb 6 04:11 sqlite3.o % gcc -c s
by dalke 11y ago
Compiling with -Os brings it down to 800 KB.
% gcc -c sqlite3.c
% ls -l sqlite3.o
-rw-r--r-- 1 dalke admin 1270372 Feb 6 04:11 sqlite3.o
% gcc -c sqlite3.c -Os
% ls -l sqlite3.o
-rw-r--r-- 1 dalke admin 805044 Feb 6 04:12 sqlite3.o
% clang -c sqlite3.c
% ls -l sqlite3.o
-rw-r--r-- 1 dalke admin 1248704 Feb 6 04:15 sqlite3.o
% clang -c -Os sqlite3.c
% ls -l sqlite3.o
-rw-r--r-- 1 dalke admin 796888 Feb 6 04:16 sqlite3.o
778 KiB is still some 50% larger than 500.
- SQLite 11y agoUsing "gcc -Os -m32 -c sqlite3.c; size sqlite3.o" I get 443,264 bytes using the latest SQLite source on Ubuntu. The "size" command gives a more accurate measurement of what actually ends up in a compiled and stripped binary. "ls -l" includes symbolic and linking info that gets stripped from the finished binary.
- jevinskie 11y agoClang also has -Oz for even more aggressive size optimizations. I find that it is identical codegen to -Os half the time and shows some nice size reductions the other half of the time.