This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 81024bbdf0bb5a750c38b187b959ded3a131e7b1
Author: Saravanan Sekar <[email protected]>
AuthorDate: Tue Nov 10 12:11:08 2026 +0530

    arch/tricore: Preprocess the TASKING assembly sources.
    
    The .asm sources of the TASKING build go to the assembler as they are,
    so they cannot include the CSFR offsets or test the configuration, and
    spell out the numbers instead.  Preprocess them with ctc -Ep first, as
    GCC does for the .S sources, and assemble the result, for make and
    cmake; ctc -Ep leaves no line markers, which the assembler does not
    take.  When the build forces response files, as NuttX does for Ninja,
    ctc takes the -D, -U and -I options from the response file, as the other
    options in it are for the control program.  The make dependencies come
    from ctc -Em.
    
    Signed-off-by: Saravanan Sekar <[email protected]>
---
 arch/tricore/src/cmake/tasking.cmake          | 22 ++++++++++++++++++++++
 arch/tricore/src/common/ToolchainTasking.defs | 16 +++++++++++++---
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/arch/tricore/src/cmake/tasking.cmake 
b/arch/tricore/src/cmake/tasking.cmake
index 63b73077515..8979fcd20a4 100644
--- a/arch/tricore/src/cmake/tasking.cmake
+++ b/arch/tricore/src/cmake/tasking.cmake
@@ -44,6 +44,28 @@ set(ASMEXT
     asm
     CACHE INTERNAL "")
 
+# The .asm sources go through the C preprocessor first, as the .S sources of
+# GCC, so that they can use the configuration and the headers.  ctc -Ep leaves
+# no line markers, which the assembler does not take.
+
+if(CMAKE_NINJA_FORCE_RESPONSE_FILE)
+  # With the response files that the top-level CMakeLists.txt forces for Ninja,
+  # the defines and includes are only in the response file, which also has the
+  # control program options that ctc does not take, so ctc only gets the -D, -U
+  # and -I options of it.
+
+  set(CMAKE_ASM_COMPILE_OBJECT
+      "grep -o -E -e \"-[DUI][^ ]+\" ${CMAKE_BINARY_DIR}/$RSP_FILE > 
<OBJECT>.opt"
+      "${TOOLCHAIN_PREFIX}ctc -f <OBJECT>.opt -Ep <SOURCE> -o <OBJECT>.src"
+      "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -c <OBJECT>.src -o 
<OBJECT>"
+  )
+else()
+  set(CMAKE_ASM_COMPILE_OBJECT
+      "${TOOLCHAIN_PREFIX}ctc -Ep <DEFINES> <INCLUDES> <SOURCE> -o 
<OBJECT>.src"
+      "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -c <OBJECT>.src -o 
<OBJECT>"
+  )
+endif()
+
 if(CONFIG_OUTPUT_STRIP_PATHS)
   # TASKING cctc has no -fmacro-prefix-map. Convert absolute source paths to
   # relative paths by cd-ing to code root before compilation, so __FILE__ 
embeds
diff --git a/arch/tricore/src/common/ToolchainTasking.defs 
b/arch/tricore/src/common/ToolchainTasking.defs
index 348ff05aa20..2a3e4cac1a9 100644
--- a/arch/tricore/src/common/ToolchainTasking.defs
+++ b/arch/tricore/src/common/ToolchainTasking.defs
@@ -64,11 +64,21 @@ OBJCOPY           = echo
 OBJDUMP           = elfdump
 ASMEXT            = .asm
 
-# The .asm sources are not run through the C preprocessor and include no
-# headers, so they only depend on themselves.
+# The .asm sources go through the C preprocessor first, as the .S sources
+# of GCC, so that they can use the configuration and the headers.  ctc -Ep
+# leaves no line markers, which the assembler does not take.
+
+define ASSEMBLE
+       $(ECHO_BEGIN)"AS: $1 "
+       $(Q) ctc -Ep $(filter -D% -U% -I%,$(subst -I ,-I,$(AFLAGS) $($(strip 
$1)_AFLAGS))) $1 -o $(basename $2).src
+       $(Q) $(CC) -c $(AFLAGS) $($(strip $1)_AFLAGS) $(basename $2).src -o $2
+       $(Q) $(call DELFILE, $(basename $2).src)
+       $(ECHO_END)
+endef
 
 %.dds: %.asm
-       $(Q) echo "$(OBJPATH)$(DELIM)$*$(OBJEXT): $<" > $@
+       $(Q) ctc -Em $(filter -D% -U% -I%,$(subst -I ,-I,$(CFLAGS))) $< -o $@
+       $(Q) sed -i "s|^$(notdir $*)\.o *:|$(OBJPATH)$(DELIM)$*$(OBJEXT):|" $@
 
 ARCHOPTIMIZATION += --lsl-core=vtc
 LDFLAGS          += --lsl-core=vtc

Reply via email to