You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/02/19 11:36:50 UTC

(nuttx) branch master updated: toolchain/tasking: add dependencies rules for tasking compiler

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 e11c793b33 toolchain/tasking: add dependencies rules for tasking compiler
e11c793b33 is described below

commit e11c793b330ea4b729b0bc14057e21660a8eaec3
Author: chao an <an...@lixiang.com>
AuthorDate: Sun Feb 18 15:37:51 2024 +0800

    toolchain/tasking: add dependencies rules for tasking compiler
    
    Tasking compiler uses customized compilation options for generating dependencies files
    
    Signed-off-by: chao an <an...@lixiang.com>
---
 arch/Kconfig             |  4 +++
 include/nuttx/compiler.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/Config.mk          |  5 +++
 tools/incdir.c           |  9 ++++--
 tools/mkdeps.c           | 53 ++++++++++++++++++++++++--------
 5 files changed, 136 insertions(+), 14 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index d5de8d324d..ecab9fa69c 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -263,6 +263,10 @@ config ARCH_TOOLCHAIN_CLANG
 	select ARCH_TOOLCHAIN_GNU
 	default n
 
+config ARCH_TOOLCHAIN_TASKING
+	bool
+	default n
+
 choice
 	prompt "Link Time Optimization (LTO)"
 	default LTO_NONE
diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h
index 222f37c12c..8a6b5ec615 100644
--- a/include/nuttx/compiler.h
+++ b/include/nuttx/compiler.h
@@ -944,6 +944,85 @@
 
 #  define no_builtin(n)
 
+/* TASKING (Infineon AURIX C/C++)-specific definitions **********************/
+
+#elif defined(__TASKING__)
+
+/* Define these here and allow specific architectures to override as needed */
+
+#  define CONFIG_HAVE_LONG_LONG         1
+#  define CONFIG_HAVE_FLOAT             1
+#  define CONFIG_HAVE_DOUBLE            1
+#  define CONFIG_HAVE_LONG_DOUBLE       1
+
+/* Pre-processor */
+
+#  define CONFIG_CPP_HAVE_VARARGS       1 /* Supports variable argument macros */
+
+/* Intriniscs */
+
+#  define CONFIG_HAVE_FUNCTIONNAME      1 /* Has __FUNCTION__ */
+#  define CONFIG_HAVE_FILENAME          1 /* Has __FILE__ */
+
+#  undef  CONFIG_CPP_HAVE_WARNING
+#  undef  CONFIG_HAVE_WEAKFUNCTIONS
+#  define weak_alias(name, aliasname)
+#  define weak_data                     __attribute__((weak))
+#  define weak_function                 __attribute__((weak))
+#  define weak_const_function           __attribute__((weak, __const__))
+#  define restrict
+#  define noreturn_function
+#  define farcall_function              __attribute__((long_call))
+#  define predict_true(x) (x)
+#  define predict_false(x) (x)
+#  define aligned_data(n)               __attribute__((aligned(n)))
+#  define locate_code(n)                __attribute__((section(n)))
+#  define locate_data(n)                __attribute__((section(n)))
+#  define begin_packed_struct
+#  define end_packed_struct             __attribute__((packed))
+#  define reentrant_function
+#  define naked_function
+#  define always_inline_function        __attribute__((always_inline))
+#  define noinline_function             __attribute__((noinline))
+#  define noinstrument_function
+#  define nooptimiziation_function      __attribute__((optimize(0)))
+#  define nosanitize_address
+#  define nosanitize_undefined
+#  define nostackprotect_function
+#  define unused_code                   __attribute__((unused))
+#  define unused_data                   __attribute__((unused))
+#  define used_code                     __attribute__((used))
+#  define used_data                     __attribute__((used))
+#  define fopen_like
+#  define popen_like
+#  define malloc_like
+#  define malloc_like1(a)
+#  define malloc_like2(a, b)
+#  define realloc_like(a)
+#  define format_like(a)
+#  define printf_like(a, b)
+#  define syslog_like(a, b)
+#  define scanf_like(a, b)
+#  define strftime_like(a)
+
+#  define FAR
+#  define NEAR
+#  define DSEG
+#  define CODE
+#  define IOBJ
+#  define IPTR
+
+#  undef  CONFIG_SMALL_MEMORY
+#  undef  CONFIG_LONG_IS_NOT_INT
+#  undef  CONFIG_PTR_IS_NOT_INT
+
+#  define UNUSED(a) ((void)(1 || &(a)))
+
+#  define offsetof(a, b) ((size_t)(&(((a *)(0))->b)))
+#  define return_address(x) 0
+
+#  define no_builtin(n)
+
 /* Unknown compiler *********************************************************/
 
 #else
diff --git a/tools/Config.mk b/tools/Config.mk
index 92c753b8f6..8cb5901a50 100644
--- a/tools/Config.mk
+++ b/tools/Config.mk
@@ -578,6 +578,11 @@ ifeq ($(CONFIG_STACK_USAGE),y)
 	EXTRA += *.su
 endif
 
+ifeq ($(CONFIG_ARCH_TOOLCHAIN_TASKING),y)
+	EXTRA += *.d
+	EXTRA += *.src
+endif
+
 ifeq ($(CONFIG_WINDOWS_NATIVE),y)
 define CLEAN
 	$(Q) if exist *$(OBJEXT) (del /f /q *$(OBJEXT))
diff --git a/tools/incdir.c b/tools/incdir.c
index 67c6035e7e..8d9e338329 100644
--- a/tools/incdir.c
+++ b/tools/incdir.c
@@ -67,7 +67,8 @@ enum compiler_e
   COMPILER_CLANG,
   COMPILER_MINGW,
   COMPILER_SDCC,
-  COMPILER_ZDSII
+  COMPILER_ZDSII,
+  COMPILER_TASKING
 };
 
 /****************************************************************************
@@ -200,6 +201,10 @@ static enum compiler_e get_compiler(char *ccname)
     {
       return COMPILER_ZDSII;
     }
+  else if (strstr(ccname, "ctc") != NULL)
+    {
+      return COMPILER_TASKING;
+    }
   else
     {
       /* Unknown compiler. Assume GCC-compatible */
@@ -347,7 +352,7 @@ int main(int argc, char **argv, char **envp)
       wintool = true;
 #endif
     }
-  else if (compiler == COMPILER_SDCC)
+  else if (compiler == COMPILER_SDCC || compiler == COMPILER_TASKING)
     {
       cmdarg = "-I";
     }
diff --git a/tools/mkdeps.c b/tools/mkdeps.c
index da9a3f5b88..a38d245e2e 100644
--- a/tools/mkdeps.c
+++ b/tools/mkdeps.c
@@ -81,12 +81,12 @@
  * Private Types
  ****************************************************************************/
 
-enum slashmode_e
+typedef enum
 {
-  MODE_FSLASH  = 0,
-  MODE_BSLASH  = 1,
-  MODE_DBLBACK = 2
-};
+  COMPILER_GNU      = 0,
+  COMPILER_TASKING  = 1,
+  COMPILER_NUM      = 2
+} compiler_t;
 
 /****************************************************************************
  * Private Data
@@ -115,10 +115,37 @@ static char g_posixpath[MAX_PATH];
 static char g_shquote[MAX_SHQUOTE];
 #endif
 
+static const char * const g_moptions[COMPILER_NUM][2] =
+{
+  /* GNU C/C++ Compiler */
+
+  {
+    " -M ",
+    " -MT "
+  },
+
+  /* Tasking C/C++ Compiler */
+
+  {
+    " -Em ",
+    " --pass-c=--make-target="
+  }
+};
+
 /****************************************************************************
  * Private Functions
  ****************************************************************************/
 
+static compiler_t get_compiler(char *ccname)
+{
+  if (strstr(ccname, "ctc") != NULL)
+    {
+      return COMPILER_TASKING;
+    }
+
+  return COMPILER_GNU;
+}
+
 /* MinGW does not seem to provide strtok_r */
 
 #ifndef HAVE_STRTOK_R
@@ -684,7 +711,7 @@ static const char *convert_path(const char *path)
 
 static void do_dependency(const char *file)
 {
-  static const char moption[] = " -M ";
+  const char * const * moption;
   struct stat buf;
   char *alloc;
   char *altpath;
@@ -705,6 +732,8 @@ static void do_dependency(const char *file)
   separator =  g_winnative ? '\\' : '/';
 #endif
 
+  moption = g_moptions[get_compiler(g_cc)];
+
   /* Copy the compiler into the command buffer */
 
   cmdlen = strlen(g_cc);
@@ -741,15 +770,15 @@ static void do_dependency(const char *file)
           *dotptr = '\0';
         }
 
-      snprintf(tmp, NAME_MAX + 6, " -MT %s%c%s%s ",
-               g_objpath, separator, objname, g_suffix);
+      snprintf(tmp, NAME_MAX + 6, "%s%s%c%s%s ",
+               moption[1], g_objpath, separator, objname, g_suffix);
       expanded = do_expand(tmp);
 
       cmdlen += strlen(expanded);
       if (cmdlen >= MAX_BUFFER)
         {
           fprintf(stderr, "ERROR: Option string is too long [%d/%d]: %s\n",
-                  cmdlen, MAX_BUFFER, moption);
+                  cmdlen, MAX_BUFFER, moption[0]);
           exit(EXIT_FAILURE);
         }
 
@@ -759,15 +788,15 @@ static void do_dependency(const char *file)
 
   /* Copy " -M " */
 
-  cmdlen += strlen(moption);
+  cmdlen += strlen(moption[0]);
   if (cmdlen >= MAX_BUFFER)
     {
       fprintf(stderr, "ERROR: Option string is too long [%d/%d]: %s\n",
-              cmdlen, MAX_BUFFER, moption);
+              cmdlen, MAX_BUFFER, moption[0]);
       exit(EXIT_FAILURE);
     }
 
-  strcat(g_command, moption);
+  strcat(g_command, moption[0]);
 
   /* Copy the CFLAGS into the command buffer */