cmake:bugfix fix CMake LTO build block

it was wrong in https://github.com/apache/nuttx/pull/12423/files#r1618852245
EXTRA_FLAGS is useful in LTO for pass option tu lto linker

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
xuxin19 2024-07-16 15:50:13 +08:00 committed by Xiang Xiao
parent a409c42d13
commit b64fb09e6c
2 changed files with 8 additions and 5 deletions

View File

@ -642,8 +642,8 @@ if(NOT CONFIG_ARCH_SIM)
# TODO: nostart/nodefault not applicable to nuttx toolchain # TODO: nostart/nodefault not applicable to nuttx toolchain
target_link_libraries( target_link_libraries(
nuttx PRIVATE -T${ldscript} -Wl,--start-group ${nuttx_libs} nuttx PRIVATE ${NUTTX_EXTRA_FLAGS} -T${ldscript} -Wl,--start-group
${nuttx_extra_libs} -Wl,--end-group) ${nuttx_libs} ${nuttx_extra_libs} -Wl,--end-group)
# generate binary outputs in different formats (.bin, .hex, etc) # generate binary outputs in different formats (.bin, .hex, etc)
nuttx_generate_outputs(nuttx) nuttx_generate_outputs(nuttx)

View File

@ -24,7 +24,10 @@ if(CONFIG_STACK_CANARIES)
list(APPEND SRCS lib_stackchk.c) list(APPEND SRCS lib_stackchk.c)
endif() endif()
set_source_files_properties(lib_assert.c PROPERTIES COMPILE_FLAGS -fno-lto) if(CONFIG_ARCH_TOOLCHAIN_GNU AND NOT CONFIG_LTO_NONE)
set_source_files_properties(lib_stackchk.c PROPERTIES COMPILE_FLAGS -fno-lto) set_source_files_properties(lib_assert.c DIRECTORY .. PROPERTIES COMPILE_FLAGS
-fno-lto)
set_source_files_properties(lib_stackchk.c DIRECTORY ..
PROPERTIES COMPILE_FLAGS -fno-lto)
endif()
target_sources(c PRIVATE ${SRCS}) target_sources(c PRIVATE ${SRCS})