Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Omax and LTO have no mapping/abstraction yet #1886

Open
ReinhardKeil opened this issue Dec 4, 2024 · 4 comments
Open

-Omax and LTO have no mapping/abstraction yet #1886

ReinhardKeil opened this issue Dec 4, 2024 · 4 comments
Assignees
Labels
discussion Indicates an issue being in discussion enhancement New feature or request

Comments

@ReinhardKeil
Copy link
Collaborator

Describe The Problem To Be Solved

AC6 has -Omax and several compilers offer Link Time Optimization (LTO). We should evaluate if we can add features for it.

See also ARM-software/vscode-cmsis-csolution#131

@ReinhardKeil ReinhardKeil added the enhancement New feature or request label Dec 4, 2024
@jkrech jkrech changed the title -Omax and LTO have not mapping yet -Omax and LTO have no mapping/abstraction yet Dec 17, 2024
@jkrech jkrech changed the title -Omax and LTO have no mapping/abstraction yet -Omax and LTO have no mapping/abstraction yet Dec 17, 2024
@jkrech jkrech moved this to Todo in CMSIS-Toolbox 2.8.0 Dec 17, 2024
@brondani
Copy link
Collaborator

What generic optimize value should be added?

Can we precisely establish what should be implemented for each supported toolchain?
For example:

Toolchain Compiler and/or Linker options Doc
AC6 -Omax 1
GCC -O3 -flto 2
CLANG -O3 -flto 3
CLANG_TI -O3 -flto 4
IAR -Oh? --vfe --inline --merge_duplicate_sections 5

Please note Arm states that -Omax "might violate strict compliance with language standards":
https://developer.arm.com/documentation/100748/0623/Using-Common-Compiler-Options/Selecting-optimization-options

@jkrech jkrech added the discussion Indicates an issue being in discussion label Jan 28, 2025
@ReinhardKeil
Copy link
Collaborator Author

Maybe the best is to add another control to enable link-time-optimize:.

@mario-pi
Copy link

IAR compiler optimizations can be directed for size (-Ohz), speed (-Ohs) or balanced (-Oh). The linker has no general -O option, but it can enable specific optimizations. I discussed this with the compiler team:

--vfe is a size optimization (discards unused virtual functions), the cost is link time (minimal) so it should be used

--inline inlines small functions (the payload of the target fits in the code). This is a speed optimization. This can be problematic if you place a breakpoint in foobar, and then it is optimized away so that the call to foobar never takes place. In EW this is default on for Release build configurations.

--merge_duplicate_sections is a size optimization, like the name implies duplicate sections are eliminated. This is a relatively expensive (paid with link time) optimization. It is not active by default in EW.

Generally speaking I agree with @ReinhardKeil that it would probably be best to have a separate control for linker optimization, mostly given that they are so specific.

@ReinhardKeil
Copy link
Collaborator Author

ReinhardKeil commented Feb 11, 2025

Proposal separate option:

Also AC6 offers the option --flto. As this can be combined with optimize levels (size, speed, etc.) it should be a separate option, my proposal link-time-optimize:. For the files or components it is applied it enables --flto. When one or more files use this option a corresponding linker option should be enabled.

IAR compiler uses multi-file compilation which at this point in time cannot handled by CMake. Therefore this option should be ignored for IAR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Indicates an issue being in discussion enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

4 participants