Add LTO support #616
No reviewers
Labels
No Label
API Change
Breaking API Change
bug
build
cosmetics
Documentation
duplicate
feature
help wanted
hotfix
invalid
question
Refactor
Tests
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: fsfw/fsfw#616
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mueller/add-lto-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
LTO support: Allow using LTO/IPO by setting
FSFW_ENABLE_LTO=1
. CMake is able to detect whetherthe user compiler supports IPO/LPO. LTO is on by default now. Most modern compilers support it, can make good use of it and it usually makes the code faster and/or smaller.
This is preparation for a possible
{fmt}
support. fmt usually makes the binarylarger if it was not installed as a shared library, so this option can reduce code size.
UPDATE:
Enabling LTO will actually cause the compiler to only produce thin LTO by adding
-flto -fno-fat-lto-objects
to the compiler options. I am not sure this is an ideal choice because if an application linking against the FSFW does not use LTO, there can be compile issues (e.g. observed when compiling the FSFW tests without LTO). This is a known issue as can be seen in the multiple CMake issues for it: https://gitlab.kitware.com/cmake/cmake/-/issues/22913, https://gitlab.kitware.com/cmake/cmake/-/issues/16808, https://gitlab.kitware.com/cmake/cmake/-/issues/21696I would suggest still keeping this option but letting the default be OFF for now. For me, it makes the most sense to specifically compile the FSFW with fat LTO where the static library contains the regular object code and the intermedia representation which can be used by application compiling with and without LTO. CMake might have this option soon in the future. If a user wants to use full LTO, they can simly set the following option in the application
CMakeLists.txt
This will cause the compiler to compile both the application and the framework with
thin LTO, which is okay in that case.
mueller/add-lto-supportto Add LTO support8334af77ea
to637512ad77
@ -36,0 +36,4 @@
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if(NOT IPO_SUPPORTED)
message(STATUS "FSFW | IPO/LTO not supported: ${IPO_ERROR}")
Do we need that check if FSFW_ENABLE_IPO is off?
fixed it
LGTM