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.
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
| Parameter | Description | Options |
|---|
| COMP_LIST | Installed compiler version selection (auto-detected) | XC16 v1.xx-v2.xx |
| LATEST_CMPLR | Always use latest installed compiler | on / off |
| DFP_LIST | Device Family Pack version | from compiler |
| CMSIS_DSP | (ARM) | CMSIS DSP library for ARM |
Optimization Levels
| Level | Speed | Code Size | Use Case |
|---|
| -O0 | Slowest | Largest | Debug - no optimization |
| -O1 | Moderate | Reduced | Basic optimization |
| -O2 | Fast | Smaller | Production (recommended) |
| -O3 | Fastest | May increase | Maximum speed |
| -Os | Varies | Smallest | Size-constrained |
dsPIC Options (16-bit)
| Option | Description | Impact |
|---|
| USE_64BIT_DOUBLE | 64-bit doubles vs 32-bit | 2Γ memory, higher precision |
| PROCEDURAL_ABSTRACTION | Extract common code (-mpa) | 5-15% size reduction |
| MCODE | Code memory model | small ( |
| MDATA | Data memory model | small (near) / large (far) |
| MLARGEARRAY | Arrays >32KB | 32-bit indexing required |
| GC_SECTIONS | Remove unused code/data | 10-30% size reduction |
ARM/PIC32 Options (32-bit)
| Option | Description | Impact |
|---|
| OPTIMIZATION_FLTO | Link-Time Optimization | 5-20% improvement, slow build |
| OPTIMIZATION_REORDER | Reorder for cache locality | Speed improvement |
| CONSERVE_STACK | Minimize stack usage | Reduced stack requirements |
Debug Options
| Option | Description | Output |
|---|
| DEBUG_INFO | Debug symbols in ELF | Required for debugging |
| AssemblyListing | .lst file generation | Assembly/source mix |
| ProduceHexOutput | .hex file generation | Programming file |
| MCHP_STACK_USAGE | Stack usage report (MCHP) | .su files |
| GCC_STACK_USAGE | Stack usage report (GCC) | .su files |
Linker Configuration
| Parameter | Description |
|---|
| UseCustom_LinkerScript | Use custom memory map |
| LinkerScript | Path to .gld/.ld file |
| HEAP_SIZE | Heap allocation (bytes) |
| CUSTOM_OPTIM | Additional compiler flags |
| CUSTOM_OPTIM_LD | Additional linker flags |
Math Libraries (dsPIC)
| Library | Speed | Accuracy |
|---|
| Standard | Moderate | Full precision |
| Fast | 2-3Γ faster | Slightly reduced |
| Relaxed | Maximum speed | Trade 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