Reputation: 1288
I have some C code that I trying to compile for a Sparc V8 based system with highly constrained resources. I am using gcc and I would like to ask the following questions.
1) Besides turning off debugging (-g flag) what other options do I have to reduce the compile object size?
2) ARM has a thumb mode, does Sparc have anything similar?
3) What other compiler options (or even C code tricks) can be used to reduce a compiled binary object size.
Once again I am using gcc.
Upvotes: 1
Views: 312
Reputation: 2967
1) As Mat said: Use -Os flag for code size reduction
2) No. Have a look at the manual here: http://www.gaisler.com/doc/sparcv8.pdf
3) Read this article: https://github.com/contiki-os/contiki/wiki/Reducing-Contiki-OS-firmware-size It is code size reduction recommendations for Contiki OS project written by a very experienced engineer. Contiki OS is an embedded C project usually compiled with GCC, so it applies to your problem.
Upvotes: 1
Reputation: 126
Compile with -Os. It means optimize for size.
If some parts of the code are supposed to run as fast as possible, you can use __attribute__((optimize("-O2")))
to optimize an specific function for speed.
See the following link for explanation of optimization flags: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Upvotes: 2