Improving Binary Size When Compiling In Simplicity Studio

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero Employee</font></font> </a> RonB on ‎06-15-2017 03:07 PM

When compiling code in Simplicity Studio, it turns out that some optimizations for size have been turned off in favor of speed during the compilation process.  The result is code binaries being larger than desired in many cases.

 

While you can compile your code directly in IAR to remedy this problem, it can be cumbersome as your have to use a different compiler and IDE.

 

 

A permanent fix to Studio which allows you to compile your code the same as IAR would be to make changes the base.slspro file within your stack and correct these optimization flags.  Within the stacks do a search for this file, some stacks may have multiple files:

 

./stacks/znet/v5.8.1.0/app/esf_common/template/studio/base.slsproj
./stacks/znet/v5.8.1.0/protocol/zigbee_5.8/tool/appbuilder/base.slsproj

 

To be certain your changes happen, change both files.

 

In each file you need to find these lines:

 

<toolOption toolId="iar.arm.toolchain.compiler.v5.4.1" optionId="iar.arm.toolchain.compiler.option.optCSE.v5.4.0" value="true"/>
<toolOption toolId="iar.arm.toolchain.compiler.v5.4.1" optionId="iar.arm.toolchain.compiler.option.optUnroll.v5.4.0" value="true"/>
<toolOption toolId="iar.arm.toolchain.compiler.v5.4.1" optionId="iar.arm.toolchain.compiler.option.optInline.v5.4.0" value="true"/>
<toolOption toolId="iar.arm.toolchain.compiler.v5.4.1" optionId="iar.arm.toolchain.compiler.option.optCodeMotion.v5.4.0" value="true"/>
<toolOption toolId="iar.arm.toolchain.compiler.v5.4.1" optionId="iar.arm.toolchain.compiler.option.optAliasAnalysis.v5.4.0" value="true"/>
<toolOption toolId="iar.arm.toolchain.compiler.v5.4.1" optionId="iar.arm.toolchain.compiler.option.optStaticClustering.v5.4.0" value="true"/>

 

And change them all from true to false.  We list them here together, but they don't appear this close together in file.

 

Once you save your file and recompile your code, you will see your binary output size decrease.