diff --git a/CMakeLists.txt b/CMakeLists.txt index b2effa4c91..5d960036f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -642,8 +642,8 @@ if(NOT CONFIG_ARCH_SIM) # TODO: nostart/nodefault not applicable to nuttx toolchain target_link_libraries( - nuttx PRIVATE -T${ldscript} -Wl,--start-group ${nuttx_libs} - ${nuttx_extra_libs} -Wl,--end-group) + nuttx PRIVATE ${NUTTX_EXTRA_FLAGS} -T${ldscript} -Wl,--start-group + ${nuttx_libs} ${nuttx_extra_libs} -Wl,--end-group) # generate binary outputs in different formats (.bin, .hex, etc) nuttx_generate_outputs(nuttx) diff --git a/libs/libc/assert/CMakeLists.txt b/libs/libc/assert/CMakeLists.txt index 09c4b50b22..e2b2f9a034 100644 --- a/libs/libc/assert/CMakeLists.txt +++ b/libs/libc/assert/CMakeLists.txt @@ -24,7 +24,10 @@ if(CONFIG_STACK_CANARIES) list(APPEND SRCS lib_stackchk.c) endif() -set_source_files_properties(lib_assert.c PROPERTIES COMPILE_FLAGS -fno-lto) -set_source_files_properties(lib_stackchk.c PROPERTIES COMPILE_FLAGS -fno-lto) - +if(CONFIG_ARCH_TOOLCHAIN_GNU AND NOT CONFIG_LTO_NONE) + 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})