Compiler unused code/data removal

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Compiler unused code/data removal

跳至解决方案
2,707 次查看
gschelotto
Contributor V

Hi,

I usually use (at the end of the development) a compiler option that removes unused data/code. From Atollic toolchain for ST here's the option to activate it.

mcuxpresso.png

Where can I find these options on MCUxpresso?

regards,

gaston

0 项奖励
回复
1 解答
2,451 次查看
BlackNight
NXP Employee
NXP Employee

This is about grouping code and data items into single sections:

-ffunction-sections -fdata-sections

They should be set by default already in the SDK projects:

pastedImage_1.png

And for the linker to remove unused ones:

--gc-sections

pastedImage_1.png

I hope this helps,

Erich

在原帖中查看解决方案

0 项奖励
回复
6 回复数
2,452 次查看
BlackNight
NXP Employee
NXP Employee

This is about grouping code and data items into single sections:

-ffunction-sections -fdata-sections

They should be set by default already in the SDK projects:

pastedImage_1.png

And for the linker to remove unused ones:

--gc-sections

pastedImage_1.png

I hope this helps,

Erich

0 项奖励
回复
2,451 次查看
embeddeddavid
Contributor IV

Hi there,

-ffunction-sections and -fdata-sections MCU compiler flags are set in my project; and also --gc-sections MCU linker flag. However, lots of unused standard functions are linked to my application, such as read_r, _realloc_r, etc.

The build configuration is using my own linker script and I have unchecked 'Do not use default libraries (-nodefaultlibs)' at Tool Settings >> MCU Linker >> General

pastedImage_1.png

Any clue of what can be happening here?

Thanks in advance!

0 项奖励
回复
2,451 次查看
converse
Senior Contributor V

Attach you map file. This may give some clues

0 项奖励
回复
2,451 次查看
embeddeddavid
Contributor IV

I'm sorry but I can't provide this information.

0 项奖励
回复
2,451 次查看
converse
Senior Contributor V

I’m sorry, but I can’t help without it.

0 项奖励
回复
2,451 次查看
converse
Senior Contributor V

AFAIK, MCUXpresso has this option set automatically for Release builds. 

See https://community.nxp.com/thread/389145 

0 项奖励
回复