]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Infer TOOL/TOOL_FAMILY from vxworks-predef.h on VxWorks7
authorOlivier Hainque <hainque@adacore.com>
Sat, 20 Apr 2024 15:35:41 +0000 (12:35 -0300)
committerOlivier Hainque <hainque@adacore.com>
Mon, 20 Oct 2025 15:15:38 +0000 (15:15 +0000)
This change moves, for VxWorks 7, the setting of the TOOL
and TOOL_FAMILY macros from a builtin_define to a run-time
computation from vxworks-predefs.h.

This is useful on Vx7 to allow a single toolchain to be used
for instances of VxWorks based on either a gnu or an llvm system
toolchain for a given cpu (typically, powerpc).

This is achieved by leveraging the existence of a very basic
autoconf.h file in all VxWorks 7 VSBs, #included directly from
vxworks-predef.h.

gcc/
* config/vxworks.h (VXWORKS_OS_CPP_BUILTINS): Only
builtin_define TOOL and TOOL_FAMILY for !TARGET_VXWORKS7.
Augment comment on VXWORKS_PERSONALITY.
* config/vxworks/vxworks-predef.h: Infer TOOL and TOOL_FAMILY
from the VSB autoconf.h when we have one, determined by the presence
of a _VSB_CONFIG_FILE definition.

libgcc/
* config/t-vxworks: -include vxworks-predef.h explicitly, as the
automatic inclusion is disabled by -nostdinc.

gcc/config/vxworks.h
gcc/config/vxworks/vxworks-predef.h
libgcc/config/t-vxworks

index d2b6025caad96f56fdffa093c67bdda1e2e84dc6..7268ace41ece42e4d5744ad765b4ca30a5a424fd 100644 (file)
@@ -365,9 +365,16 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority);
 
 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS.  */
 
-/* The VxWorks personality we rely on, controlling which sections of system
-   headers files we trigger.  This might be redefined on targets where the
-   base VxWorks environment doesn't come with a GNU toolchain.  */
+/* The VxWorks personality we rely on for VxWorks prior to 7, controlling the
+   definition of TOOL and TOOL_FAMILY macros used within system headers and
+   expected to match the kind of system toolchain on which the OS instance is
+   based (typically, gnu or llvm).  This might be redefined on targets where
+   the base VxWorks environment doesn't come with a GNU toolchain.
+
+   From VxWorks 7 on, the actual personality might vary for different instances
+   for a given architecture.  The TOOL/TOOL_FAMILY definitions are infered at
+   run-time from vxworks-predef.h, which allows accommodating such variations
+   with a single toolchain.  */
 
 #define VXWORKS_PERSONALITY "gnu"
 
@@ -381,8 +388,6 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority);
        builtin_define ("__RTP__");                                     \
       else                                                             \
        builtin_define ("_WRS_KERNEL");                                 \
-      builtin_define ("TOOL_FAMILY=" VXWORKS_PERSONALITY);             \
-      builtin_define ("TOOL=" VXWORKS_PERSONALITY);                    \
       if (TARGET_VXWORKS7)                                             \
         {                                                              \
            builtin_define ("_VSB_CONFIG_FILE=<config/vsbConfig.h>");   \
@@ -394,6 +399,11 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority);
           if (!flag_isoc99 && !c_dialect_cxx())                        \
              builtin_define ("_ALLOW_KEYWORD_MACROS");                 \
         }                                                              \
+      else                                                             \
+       {                                                               \
+         builtin_define ("TOOL_FAMILY=" VXWORKS_PERSONALITY);          \
+         builtin_define ("TOOL=" VXWORKS_PERSONALITY);                 \
+       }                                                               \
       /* C++ support relies on C99 features from C++11, even C++98     \
          for listdc++ in particular, with corresponding checks at      \
          configure time.  Make sure C99 features are exposed by the    \
index 0ea70fb8c730d2a851e4722e3a2efa0ee3808a63..46df32c7cc8f5195004f61ac8a3d941622235df8 100644 (file)
@@ -29,4 +29,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    that the OS actually defines it as.  */
 #define __STDC_ISO_10646__             200009L
 
+/* If we have a designated VSB configuration file, fetch the associated
+   auto configuration header from which we can infer the TOOL and TOOL_FAMILY
+   that other system headers expect.  */
+
+#if defined(_VSB_CONFIG_FILE)
+
+#undef TOOL
+#undef TOOL_FAMILY
+
+#include <config/autoconf.h>
+
+#if defined(_WRS_CONFIG_PRI_llvm)
+#define TOOL_FAMILY llvm
+#elif defined(_WRS_CONFIG_PRI_gnu)
+#define TOOL_FAMILY gnu
+#endif
+
+#define TOOL TOOL_FAMILY
+
+#endif /* _VSB_CONFIG_FILE */
+
 #endif
index 81a4deab073fea3a119db8772a6b7fdffba30b99..42db6a8cb705ea44393536fb7c2e07be800a007f 100644 (file)
@@ -30,7 +30,7 @@ LIB2FUNCS_EXCLUDE += _clear_cache
 # paths differs between Windows and Linux hosts as the latter can perform
 # inode based checks while the former may only rely on name comparisons.
 
-LIBGCC2_INCLUDES = -nostdinc -I. \
+LIBGCC2_INCLUDES = -nostdinc -include vxworks-predef.h -I. \
   $(if $(findstring vxworks7, $(target_noncanonical)), \
     -I$(VSB_DIR)/h -I$(VSB_DIR)/share/h -I=/system -I=/public, \
     -I=/ -I=/wrn/coreip) \