Compiler Options Block Icon
The CompilerOptimisation block configures compiler toolchain, optimization levels, Device Family Pack (DFP) selection, and linker options for controlling code size, execution speed, and build behavior.

Block Inputs/Outputs

Inputs: None (configuration block only)

Outputs: None (configuration block only)

This is a configuration block that sets compiler and linker options. It does not have signal portsβ€”it provides build system configuration used during code generation.

Compiler Selection

ParameterDescriptionOptions
COMP_LISTInstalled compiler version selection (auto-detected)XC16 v1.xx-v2.xx
LATEST_CMPLRAlways use latest installed compileron / off
DFP_LISTDevice Family Pack versionfrom compiler
CMSIS_DSP(ARM)CMSIS DSP library for ARM

Optimization Levels

LevelSpeedCode SizeUse Case
-O0SlowestLargestDebug - no optimization
-O1ModerateReducedBasic optimization
-O2FastSmallerProduction (recommended)
-O3FastestMay increaseMaximum speed
-OsVariesSmallestSize-constrained

dsPIC Options (16-bit)

OptionDescriptionImpact
USE_64BIT_DOUBLE64-bit doubles vs 32-bit2Γ— memory, higher precision
PROCEDURAL_ABSTRACTIONExtract common code (-mpa)5-15% size reduction
MCODECode memory modelsmall (
MDATAData memory modelsmall (near) / large (far)
MLARGEARRAYArrays >32KB32-bit indexing required
GC_SECTIONSRemove unused code/data10-30% size reduction

ARM/PIC32 Options (32-bit)

OptionDescriptionImpact
OPTIMIZATION_FLTOLink-Time Optimization5-20% improvement, slow build
OPTIMIZATION_REORDERReorder for cache localitySpeed improvement
CONSERVE_STACKMinimize stack usageReduced stack requirements

Debug Options

OptionDescriptionOutput
DEBUG_INFODebug symbols in ELFRequired for debugging
AssemblyListing.lst file generationAssembly/source mix
ProduceHexOutput.hex file generationProgramming file
MCHP_STACK_USAGEStack usage report (MCHP).su files
GCC_STACK_USAGEStack usage report (GCC).su files

Linker Configuration

ParameterDescription
UseCustom_LinkerScriptUse custom memory map
LinkerScriptPath to .gld/.ld file
HEAP_SIZEHeap allocation (bytes)
CUSTOM_OPTIMAdditional compiler flags
CUSTOM_OPTIM_LDAdditional linker flags

Math Libraries (dsPIC)

LibrarySpeedAccuracy
StandardModerateFull precision
Fast2-3Γ— fasterSlightly reduced
RelaxedMaximum speedTrade precision

Example Configurations

Debug

OPTIMIZATION_LEVEL: -O0
DEBUG_INFO: on
GC_SECTIONS: None
β†’ Largest code, easiest debugging

Production (Speed)

OPTIMIZATION_LEVEL: -O2
PROCEDURAL_ABSTRACTION: on (dsPIC)
OPTIMIZATION_FLTO: on (ARM/PIC32)
GC_SECTIONS: Remove unused
β†’ Fast execution, moderate size

Size-Constrained

OPTIMIZATION_LEVEL: -Os
PROCEDURAL_ABSTRACTION: on
GC_SECTIONS: Remove unused
β†’ Minimum code size

See Also

  • [MCHP_Master] - Compiler auto-configuration
  • [MCHP_PortInfo] - Resource visualization