Skip to content

Commit

Permalink
arm/cmake: fix cmake compile error
Browse files Browse the repository at this point in the history
1. The -c parameter should not be added during the link phase, otherwise the link will fail.
2. If it is the clang compiler, its toolchain library should use --print-file-name to find it, otherwise an error will occur

Signed-off-by: wangmingrong1 <[email protected]>
  • Loading branch information
W-M-R authored and xiaoxiang781216 committed Oct 12, 2024
1 parent 3b273b1 commit b12bf1e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions arch/arm/src/cmake/clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,17 @@ if(NOT CONFIG_CXX_RTTI)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
endif()

set(CMAKE_EXE_LINKER_FLAGS_INIT "-c")

set(PREPROCESS ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} -E -P -x c)

# override nuttx_find_toolchain_lib

set(NUTTX_FIND_TOOLCHAIN_LIB_DEFINED true)

function(nuttx_find_toolchain_lib)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE extra_lib_path)
nuttx_add_extra_library(${extra_lib_path})
endfunction()

0 comments on commit b12bf1e

Please sign in to comment.