From cef9addbbb51b1888cdbfe45221e2dbf785e9ef0 Mon Sep 17 00:00:00 2001 From: chao an Date: Fri, 5 Jul 2024 21:42:46 +0800 Subject: [PATCH] sim/cmake: enable garbage collection of unused input sections enable --gc-sections for linker enable -ffunction-sections -fdata-sections for compiler Signed-off-by: chao an --- arch/sim/src/cmake/Toolchain.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/sim/src/cmake/Toolchain.cmake b/arch/sim/src/cmake/Toolchain.cmake index 90aa92a33b294..c787a9fe3076f 100644 --- a/arch/sim/src/cmake/Toolchain.cmake +++ b/arch/sim/src/cmake/Toolchain.cmake @@ -94,6 +94,11 @@ else() endif() endif() +if(CONFIG_DEBUG_OPT_UNUSED_SECTIONS) + add_link_options(-Wl,--gc-sections) + add_compile_options(-ffunction-sections -fdata-sections) +endif() + if(CONFIG_CXX_STANDARD) add_compile_options($<$:-std=${CONFIG_CXX_STANDARD}>) endif()