This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ff36b242438ebcd1c837da534227f3769cffad0b Author: xuxin19 <[email protected]> AuthorDate: Tue Mar 4 15:33:11 2025 +0800 openamp/libmetal.cmake: prefix object names for the TASKING archiver The TASKING archiver (artc) cannot put two object files with the same name into one library, and libmetal has several (for example system/nuttx/*.c and its generic sources). Under CONFIG_ARCH_TOOLCHAIN_TASKING, rename each libmetal source's object file with a directory-derived prefix in the binary directory. Signed-off-by: xuxin19 <[email protected]> --- openamp/libmetal.cmake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/openamp/libmetal.cmake b/openamp/libmetal.cmake index 30044cef5f0..0547702bef5 100644 --- a/openamp/libmetal.cmake +++ b/openamp/libmetal.cmake @@ -79,3 +79,27 @@ nuttx_create_symlink(${CMAKE_CURRENT_BINARY_DIR}/libmetal/lib/include/metal ${NUTTX_BINARY_DIR}/include/metal) nuttx_add_external_library(metal-static MODE KERNEL) + +# decorate lib metal output object file name in TASKING. TASKING archive tool +# `artc` DO NOT support obj files with the same name in different directories. +# We workaround this by adding a prefix to the object file name in BINARY dir +if(CONFIG_ARCH_TOOLCHAIN_TASKING) + get_target_property(METAL_SOURCES metal-static SOURCES) + set_target_properties(metal-static PROPERTIES SOURCES "") + foreach(SRC_FILE IN LISTS METAL_SOURCES) + get_filename_component(ABS_SRC_FILE "${SRC_FILE}" ABSOLUTE) + file(RELATIVE_PATH REL_SRC_FILE "${CMAKE_SOURCE_DIR}" "${ABS_SRC_FILE}") + get_filename_component(DIR_PART "${REL_SRC_FILE}" DIRECTORY) + get_filename_component(FILE_PART "${REL_SRC_FILE}" NAME) + string(REPLACE "/" "_" DIR_PREFIX "${DIR_PART}") + if(DIR_PREFIX) + set(NEW_OBJ_NAME "${DIR_PREFIX}_${FILE_PART}") + else() + set(NEW_OBJ_NAME "${FILE_PART}") + endif() + configure_file(${CMAKE_CURRENT_LIST_DIR}/libmetal/lib/${SRC_FILE} + ${CMAKE_CURRENT_BINARY_DIR}/${NEW_OBJ_NAME} COPYONLY) + target_sources(metal-static + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${NEW_OBJ_NAME}) + endforeach() +endif()
