GCC LTO optimization on PSoC4 and cy_boot v5.61

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GiFR_1080991
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

I'm using Creator 4.4 in a PSoC4 project.
For best size optimization, under "Build Settings" I enabled "Link Time Optimization".
For maximum gain I also added "-fwhole-program" as Custom Flag for both Compiler and Linker.
With the above options there are compilation errors caused by removal of some global symbol.

After debugging I found that the following changes are required into file ".\Generated_Source\PSoC4\Cm0plusStart.c".

 

//!void Reset(void)
void __attribute__((externally_visible))Reset(void)

//!cyisraddress CyRamVectors[CY_NUM_VECTORS];
cyisraddress __attribute__((externally_visible)) CyRamVectors[CY_NUM_VECTORS];

//!const cyisraddress RomVectors[CY_NUM_ROM_VECTORS] =
const cyisraddress __attribute__((externally_visible)) RomVectors[CY_NUM_ROM_VECTORS] =

 

The GCC attribute "externally_visible" correctly prevents the optimization on these symbols.
With the above fix I was able to test a working application and save quite Flash space thanks to LTO.

I hope this could be of interest to someone.
I suggest to file an enhancement request so that this fix could be included in a future revision of cy_boot component.

Regards,
Giuliano

0 Likes
1 Reply
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi Giuliano,

Thank you for sharing the enhancement details.

We will file an internal ticket regarding this.

Regards

Alakananda
0 Likes