2018-07-13 10:05 PM
Hello anyone,
When compiling a program including Standard Peripheral Library in the output *.elf file, all unused modules was included. Does is SDCC the dead code elimination optimization and how to activate it?
Thanks in advance.
#dce #optimalization #sdcc #stm8-toolchain2018-07-14 07:50 AM
'
Does is SDCC the dead code elimination optimization and how to activate it?'
it does, in such a way that it doesn't.
you will need to put each function in a separate file for the unused functions to not be linked in. for modern modular programming, that's not a workable approach.
2018-07-14 01:07 PM
It's a pity. All modern compilers exclude unused functions from the code. Those, assembly occurs at the level of object files, not by functions. As in the first compilers. And there is no undocumented magic key? Thanks.
2018-07-15 03:42 PM
'
It's a pity.
'
indeed. it essentially made the compiler unusable - i ruled it out very early based on that.
2018-07-15 07:34 PM
I think it is more the job of the linker rather than the compiler. I've written linkers and librarians in the past when the vendor supplied tools are unsatisfactory, or where I want to feed objects to different tools from different vendors, or on different platforms.
2018-07-15 10:54 PM
Thanks for reply Clive, Modern compilers does complex link time inter-procedural optimizations. And it becomes difficult to separate these two functions, the actual compilation and the linking. As an example is can view GCC for AVR .
2018-07-16 02:45 AM
SDCC, however, still has separate compiler and linker.
Philipp
2018-07-16 02:50 AM
Compilers could eliminate unused static functions, but for other functions it would be done in the linker.
Philipp