This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

armcc 5.06u6: --multifile and the elimination of unused variables

Hello,

I have successfully used armcc 5.06u6 to compile and run a firmware for an ARM7TDMI target with 32kB flash. To save some space now I am trying to use the --multifile option. This actually saves some additional space, which is nice, but I have made the observation that some unused data structures (from common files shared by various projects), and code referenced from these data structures, seem to not be removed by the linker, as opposed to the normal compilation mode (without --multifile), where these unused parts are eliminated as expected. So, without manual intervention, --multifile mode, under certain conditions, appears to result in larger code size numbers. Even if an object file is completely unused by the main application, its (unused) variable definitions may be included into the resulting executable.

I have reduced my program to a minimal example that demonstrates the behaviour: https://github.com/knieriem/armcc_5_06_u6_multifile_var_elim

The program sizes displayed are ...

... with --multifile:

compiling --multifile main.c partly_used.c unused.c unused2.c unused3.c unused4.c
linking Build/linker_test_multifile.axf
Program Size: Code=248 RO-data=2024 RW-data=3656 ZI-data=0
--

... without --multifile:


linking Build/linker_test_normal.axf
Program Size: Code=160 RO-data=20 RW-data=8 ZI-data=0
--

Since without the --multifile option, the elimination of unused parts works reliably, I would assume that this is also the case in --multifile mode. What might cause this different behaviour? Am I missing another command line option? Or is one of the compiler resp. linker options I used in the Makefile preventing armcc from eliminating the unused parts?

0