[EXT_EP-12398] Optimization goal for LTO does not match compiler Created: 23/Apr/25  Updated: 04/Jun/25  Resolved: 04/Jun/25

Status: Fixed
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: TI User Assignee: TI User
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-13751
Found In Release: ARMCLANG_2.1.0.LTS
ARMCLANG_4.0.2.LTS
ARMCLANG_4.0.0.LTS
ARMCLANG_2.1.2.LTS
ARMCLANG_1.3.1.LTS
ARMCLANG_3.2.1.LTS
ARMCLANG_5.0.0.LTS*
ARMCLANG_3.2.3.LTS
ARMCLANG_4.0.1.LTS
ARMCLANG_3.2.0.LTS
ARMCLANG_1.3.0.LTS
ARMCLANG_2.1.3.LTS
ARMCLANG_3.2.2.LTS
Fix In Release: ARMCLANG_5.0.0.LTS*
Affected Platform/Device: default
Workaround: - Use only a single optimization option on the command line
- Follow the precedence rules described

 Description   

When the compiler is invoked with multiple optimization flags on the command line, the goal of linktime optimization may not agree with the goal of the first optimization.

Expectation

When multiple optimization options are passed to the compiler, the last one seen takes precedence for both the initial compilation as well as LTO

Observation
-O1, -O2, -O3, -Os, -Oz, and -Og always take precedence over any other optimization options
-O0 takes precedence over -Ofast
Example

tiarmclang -O3 -O0 -flto project.c -Wl,lnk.cmd

Correctly compiles project.c with no optimization (-O0)
Incorrectly recompiles project.c as part of link-time optimization with speed-focused optimization (-O3)


Generated at Fri May 01 09:58:06 CDT 2026 using Jira 10.3.7#10030007-sha1:a563685562f94d165eb4e158cfb2a142338d8c54.