Add LTO support #616

Merged
gaisser merged 15 commits from mueller/add-lto-support into development 2022-05-12 16:56:55 +02:00
Owner
  • LTO support: Allow using LTO/IPO by setting FSFW_ENABLE_LTO=1. CMake is able to detect whether
    the 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 binary
    larger 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/21696

  • I 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

    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
    

    This will cause the compiler to compile both the application and the framework with
    thin LTO, which is okay in that case.

- LTO support: Allow using LTO/IPO by setting `FSFW_ENABLE_LTO=1`. CMake is able to detect whether the 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 binary larger 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/21696 - I 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` ```cmake set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) ``` This will cause the compiler to compile both the application and the framework with thin LTO, which is okay in that case.
muellerr added 2 commits 2022-05-09 10:29:53 +02:00
enable LTO where applicable
Some checks are pending
fsfw/fsfw/pipeline/head Build started...
fsfw/fsfw/pipeline/pr-development This commit looks good
a943e4eebb
muellerr added 1 commit 2022-05-09 10:31:12 +02:00
update changelog
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
a4bd5a2aaa
muellerr added this to the v5.0.0 milestone 2022-05-09 10:31:18 +02:00
muellerr changed title from mueller/add-lto-support to Add LTO support 2022-05-09 10:31:23 +02:00
mohr was assigned by muellerr 2022-05-09 10:31:38 +02:00
mohr was unassigned by muellerr 2022-05-09 10:31:46 +02:00
meierj was assigned by muellerr 2022-05-09 10:31:46 +02:00
meierj was unassigned by muellerr 2022-05-09 10:31:51 +02:00
muellerr requested review from gaisser 2022-05-09 10:31:56 +02:00
muellerr force-pushed mueller/add-lto-support from 8334af77ea to 637512ad77 2022-05-09 10:34:35 +02:00 Compare
muellerr added the
feature
build
labels 2022-05-09 10:40:07 +02:00
muellerr added 1 commit 2022-05-09 15:17:21 +02:00
Merge remote-tracking branch 'origin/development' into mueller/add-lto-support
Some checks failed
fsfw/fsfw/pipeline/pr-development There was a failure building this commit
8a40878eb5
muellerr added 1 commit 2022-05-09 15:52:33 +02:00
Merge branch 'development' into mueller/add-lto-support
Some checks failed
fsfw/fsfw/pipeline/pr-development There was a failure building this commit
75132c1e39
muellerr added 2 commits 2022-05-09 16:07:17 +02:00
muellerr added 1 commit 2022-05-09 16:09:42 +02:00
Merge branch 'development' into mueller/add-lto-support
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
dd9e28fca1
muellerr added 1 commit 2022-05-09 22:34:32 +02:00
Merge branch 'development' into mueller/add-lto-support
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
eb0223bc51
muellerr added 1 commit 2022-05-10 11:19:41 +02:00
keep LTO option off by default
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
0fe1b70bae
gaisser added 1 commit 2022-05-10 11:51:43 +02:00
Merge branch 'development' into mueller/add-lto-support
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
0410ecd9e3
gaisser reviewed 2022-05-10 11:53:39 +02:00
CMakeLists.txt Outdated
@ -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}")
Owner

Do we need that check if FSFW_ENABLE_IPO is off?

Do we need that check if FSFW_ENABLE_IPO is off?
Author
Owner

fixed it

fixed it
gaisser marked this conversation as resolved
muellerr added 2 commits 2022-05-10 11:57:06 +02:00
muellerr added 1 commit 2022-05-10 13:08:25 +02:00
minor formatting fix
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
e05c72b062
gaisser approved these changes 2022-05-12 16:56:49 +02:00
gaisser left a comment
Owner

LGTM

LGTM
gaisser merged commit b99160e850 into development 2022-05-12 16:56:55 +02:00
gaisser deleted branch mueller/add-lto-support 2022-05-12 16:57:01 +02:00
Sign in to join this conversation.
No description provided.