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 <anchao@lixiang.com>
This commit is contained in:
chao an 2024-07-05 21:42:46 +08:00 committed by Xiang Xiao
parent d29875926e
commit cef9addbbb

View File

@ -94,6 +94,11 @@ else()
endif() endif()
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) if(CONFIG_CXX_STANDARD)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=${CONFIG_CXX_STANDARD}>) add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=${CONFIG_CXX_STANDARD}>)
endif() endif()