This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new cda60ceab3e ghs: fix the gnu-elf.ld handle error at pre-process
cda60ceab3e is described below
commit cda60ceab3eeead658d37153ab6533c4fabd28d7
Author: guoshichao <[email protected]>
AuthorDate: Wed Mar 26 15:48:51 2025 +0800
ghs: fix the gnu-elf.ld handle error at pre-process
In Green Hills, if the name of the file to be preprocessed ends with ".ld",
this file must be renamed to ".ld.i". Otherwise, the following error will
be reported:
ccarm: Error: -o out/build/cmake_out/mann_dcu_evb_ghs_ap/gnu-elf.ld has
wrong suffix for -P option (expect .i)
Currently, based on the documentation and actual operations, only files
ending with "*.ld" can trigger this preprocessing error. There are no such
issues in other cases.
Signed-off-by: guoshichao <[email protected]>
---
arch/arm/src/cmake/ghs.cmake | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/arch/arm/src/cmake/ghs.cmake b/arch/arm/src/cmake/ghs.cmake
index c7529eb9a96..f640084f1c7 100644
--- a/arch/arm/src/cmake/ghs.cmake
+++ b/arch/arm/src/cmake/ghs.cmake
@@ -219,12 +219,31 @@ function(nuttx_generate_preprocess_target)
ARGN
${ARGN})
+ # in greenhills, for file to pre-process, if the file name is ends with
+ # "*.ld", will report error, and we need to change the target file name to
+ # "*.ld.i" or "*.ld.tmp", this is a special corner case, and the official
+ # greenhills reference manual do not have explanation about why the only
+ # "*.ld" should handle
+ set(EXPECT_TARGET_FILE_NAME ${TARGET_FILE})
+ string(REGEX MATCH ".*\.ld$" ends_with_ld ${TARGET_FILE})
+
+ if(ends_with_ld STREQUAL ${TARGET_FILE})
+ set(EXPECT_TARGET_FILE_NAME "${TARGET_FILE}.i")
+ endif()
+
add_custom_command(
- OUTPUT ${TARGET_FILE}
+ OUTPUT ${EXPECT_TARGET_FILE_NAME}
COMMAND ${PREPROCESS} -I${CMAKE_BINARY_DIR}/include -filetype.cpp
- ${SOURCE_FILE} -o ${TARGET_FILE}
+ ${SOURCE_FILE} -o ${EXPECT_TARGET_FILE_NAME}
DEPENDS ${SOURCE_FILE} ${DEPENDS})
+ if(NOT ${EXPECT_TARGET_FILE_NAME} STREQUAL ${TARGET_FILE})
+ add_custom_command(
+ OUTPUT ${TARGET_FILE}
+ COMMAND ${CMAKE_COMMAND} -E copy ${EXPECT_TARGET_FILE_NAME}
${TARGET_FILE}
+ DEPENDS ${EXPECT_TARGET_FILE_NAME})
+ endif()
+
endfunction()
# override nuttx_find_toolchain_lib