Keil MDK编译优化(不编译未使用的函数)
设置选项为: Options-C/C++中勾选上 One ELF Section per Function复选框
它的意义多是,每个函数独自设立建设一个 elf,link时能够仅把须要的函数编译进代码内里。
官方说法:
One ELF Section per Function:
Generate one ELF section for each function in source file. Output sections are named with the same name as the function that generates the section. Allows to optimize code or to locate each function on individual memory addresses.
这里有个文章:http://wenku.baidu.com/view/6bd94e60561252d380eb6e3e.html
有人提出不同意见:
这个选项是说,每个函数只存在一个,而不是复制多个,可以理解为 时间换空间。
意思是运行速度会慢一点。
也有人在选择了此项优化后,串口通信出了问题,去掉优化后就好了,有待考证.
它的意义多是,每个函数独自设立建设一个 elf,link时能够仅把须要的函数编译进代码内里。
官方说法:
One ELF Section per Function:
Generate one ELF section for each function in source file. Output sections are named with the same name as the function that generates the section. Allows to optimize code or to locate each function on individual memory addresses.
这里有个文章:http://wenku.baidu.com/view/6bd94e60561252d380eb6e3e.html
有人提出不同意见:
这个选项是说,每个函数只存在一个,而不是复制多个,可以理解为 时间换空间。
意思是运行速度会慢一点。
也有人在选择了此项优化后,串口通信出了问题,去掉优化后就好了,有待考证.
我的使用:
选择此优化,但不选择Optimization优化(Level 0),暂时没有发现问题,串口xmodem烧录Flash也没有问题。
本文出自 LcdBBS,转载时请注明出处及相应链接。
评论
Incredible points. Great arguments. Keep up the amazing effort.
提供个keilC51的方法:
把target options中的device页中选上"Use LX51 ...",然后在LX51 Misc页中的Misc Control中填入"REMOVEUNUSED",确认后重新编译即可自动去掉未调用的函数。