Posted on July 16, 2016 at 00:52For the highest speed performance and smallest code size I suggest to not use any libraries. Program with registers directly. When I remove from our project all HAL functions (which were used for peripheral initialisation only), the code size goes from 32kB to around 18 kB.
Thank you Silva for the suggestion to use Link Time Optimisation; it does actually reduce code size and increase the speed of my application. Unfortunately the disassembly of the LTO'd code removes comments and I can't verify if the 'useless' code is actually removed. And also out of curiosity, I would still like to know why removing dead code would break the code when optimised for size and work with every other optimisation level.