Build: Add optimisation options
Add the -ffunction-sections and -fdata-sections to compile time
options in order to be able to use effectively the --remove and
--gc-sections options during linking, respectively for Armclang
and GNUARM toolchains.
Change-Id: I7cd6bba27c1e197449a3523b06680c9bf5223419
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 18652eb..1133c97 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -63,7 +63,7 @@
include("Common/FindArmClang")
include("Common/${ARMCLANG_MODULE}")
- set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse)
+ set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse -ffunction-sections -fdata-sections)
##Shared compiler settings.
function(config_setting_shared_compiler_flags tgt)
embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror)
@@ -71,7 +71,7 @@
##Shared linker settings.
function(config_setting_shared_linker_flags tgt)
- embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers)
+ embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --remove --info=summarysizes,sizes,totals,unused,veneers)
endfunction()
elseif(${COMPILER} STREQUAL "GNUARM")
#Use any GNUARM version found on PATH. Note: Only versions supported by the
@@ -80,7 +80,7 @@
include("Common/FindGNUARM")
include("Common/${GNUARM_MODULE}")
- set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse --specs=nano.specs)
+ set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse -ffunction-sections -fdata-sections --specs=nano.specs)
##Shared compiler and linker settings.
function(config_setting_shared_compiler_flags tgt)
embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror -Wno-format -Wno-return-type -Wno-unused-but-set-variable)
@@ -92,8 +92,7 @@
#with short wchars, however the standard library is compiled with normal
#wchar, and this generates linker time warnings. TF-M code does not use
#wchar, so the warning can be suppressed.
- embedded_set_target_link_flags(TARGET ${tgt} FLAGS -Xlinker -check-sections -Xlinker -fatal-warnings --entry=Reset_Handler -Wl,--no-wchar-size-warning --specs=nano.specs
- -Wl,--print-memory-usage)
+ embedded_set_target_link_flags(TARGET ${tgt} FLAGS -Wl,-check-sections,-fatal-warnings,--gc-sections,--no-wchar-size-warning,--print-memory-usage --entry=Reset_Handler --specs=nano.specs)
endfunction()
endif()