From 936e8279f9cdfc58ce614075015b5c3acd7aac5b Mon Sep 17 00:00:00 2001 From: "E.T" Date: Wed, 14 Feb 2024 20:54:20 +0100 Subject: [PATCH] Add lto flag only to "internal" source files (#1895) --- firmware/application/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index 988f5bcd..575c5032 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -44,7 +44,7 @@ if(cpp20_supported) else() set(USE_CPPOPT "-std=c++17") endif() -set(USE_CPPOPT "${USE_CPPOPT} -flto -fno-rtti -fno-exceptions -Weffc++ -Wuninitialized -Wno-volatile") +set(USE_CPPOPT "${USE_CPPOPT} -fno-rtti -fno-exceptions -Weffc++ -Wuninitialized -Wno-volatile") # Enable this if you want the linker to remove unused code and data set(USE_LINK_GC yes) @@ -347,10 +347,12 @@ set(CPPSRC ${HACKRF_CPLD_DATA_CPP} ui_external_items_menu_loader.cpp view_factory_base.cpp - - ${EXTCPPSRC} ) +set_source_files_properties(${CPPSRC} PROPERTIES COMPILE_FLAGS -flto) # Add lto flag to the non-external sources only + +list (APPEND CPPSRC ${EXTCPPSRC}) # Append external sources after setting lto flag to internal ones + # C sources to be compiled in ARM mode regardless of the global setting. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler # option that results in lower performance and larger code size. @@ -492,7 +494,6 @@ add_custom_command( ) add_executable(${PROJECT_NAME}.elf ${CSRC} ${CPPSRC} ${ASMSRC}) -set_source_files_properties(${EXTCPPSRC} PROPERTIES COMPILE_FLAGS -fno-lto) set_target_properties(${PROJECT_NAME}.elf PROPERTIES LINK_DEPENDS ${LDSCRIPT}) add_definitions(${DEFS}) include_directories(. ${INCDIR})