About compile option setting of KBA229177

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

cross mob
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hello,

I am using Modus toolbox2.1 with PSoC6 BLE Pioneer kit.

If the compiler optimization options are changed, the following methods described in KBA229177 may not be effective?

CFLAGS=-Wall -O2

Described in  "13. How do I pass compiler flags?"

Because gcc gives priority to the last option if multiple options that affect each other are used.

SOLUTION:

We need to set the optimization option in "CY_TOOLCHAIN OPTIMIZATION=" or place it as a new compile configuration in the GCC_ARM.mk file.

Thanks,

Kenshow

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello Kenshow,

When you want to specify custom compiler optimization flags, please make sure you set the CONFIG option to "Custom" instead of "Debug". This line should have been mentioned in the KBA, I will fix that. Thanks for pointing it out

Once you do that the toolchain optimizations won't override the options you have specified. They only apply for Debug and Release build options as seen in this line of code in GCC_ARM.mk file:

ifeq ($(CONFIG),Debug)

CY_TOOLCHAIN_DEBUG_FLAG=-DDEBUG

CY_TOOLCHAIN_OPTIMIZATION=-Og

else ifeq ($(CONFIG),Release)

CY_TOOLCHAIN_DEBUG_FLAG=-DNDEBUG

CY_TOOLCHAIN_OPTIMIZATION=-Os

else

CY_TOOLCHAIN_DEBUG_FLAG=

CY_TOOLCHAIN_OPTIMIZATION=

endif

Regards,
Dheeraj

View solution in original post

2 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello Kenshow,

When you want to specify custom compiler optimization flags, please make sure you set the CONFIG option to "Custom" instead of "Debug". This line should have been mentioned in the KBA, I will fix that. Thanks for pointing it out

Once you do that the toolchain optimizations won't override the options you have specified. They only apply for Debug and Release build options as seen in this line of code in GCC_ARM.mk file:

ifeq ($(CONFIG),Debug)

CY_TOOLCHAIN_DEBUG_FLAG=-DDEBUG

CY_TOOLCHAIN_OPTIMIZATION=-Og

else ifeq ($(CONFIG),Release)

CY_TOOLCHAIN_DEBUG_FLAG=-DNDEBUG

CY_TOOLCHAIN_OPTIMIZATION=-Os

else

CY_TOOLCHAIN_DEBUG_FLAG=

CY_TOOLCHAIN_OPTIMIZATION=

endif

Regards,
Dheeraj

Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi Dheeraj,

Yes, I did.

Thank you for your reply.

Regards,

Kenshow

0 Likes