From a2df9179747bf8b90eca892fa323e17ab973739e Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Sat, 18 Jun 2022 01:33:25 +0200 Subject: [PATCH] Enable LTO shaves off ~10% of the code size which is very nice ... also some RAM, but we are not short on RAM in this case. --- CMakeLists.txt | 1 + src/main.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8aca20e..c18db27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,6 +143,7 @@ if(CMAKE_CROSSCOMPILING) #]] # limit the text section to 28K (32K - 4k reserved for the bootloader) + set_target_properties(firmware PROPERTIES INTERPROCEDURAL_OPTIMIZATION True) target_link_options(firmware PUBLIC -Wl,--defsym=__TEXT_REGION_LENGTH__=28K) # generate firmware.bin file diff --git a/src/main.cpp b/src/main.cpp index b37af1b..44a4f75 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -166,3 +166,9 @@ int main() { } return 0; } + +// make lto happy... +extern "C" void __cxa_pure_virtual() { + while (1) + ; +}