Compiler unused code/data removal

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Compiler unused code/data removal

Jump to solution
1,241 Views
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 Kudos
1 Solution
985 Views
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

View solution in original post

0 Kudos
6 Replies
986 Views
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 Kudos
985 Views
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 Kudos
985 Views
converse
Senior Contributor V

Attach you map file. This may give some clues

0 Kudos
985 Views
embeddeddavid
Contributor IV

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

0 Kudos
985 Views
converse
Senior Contributor V

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

0 Kudos
985 Views
converse
Senior Contributor V

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

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

0 Kudos