From: Olivier Hainque Date: Sat, 20 Apr 2024 15:35:41 +0000 (-0300) Subject: Infer TOOL/TOOL_FAMILY from vxworks-predef.h on VxWorks7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c3a37c4d5fe55878f81601fd16f1ce5259f4162f;p=thirdparty%2Fgcc.git Infer TOOL/TOOL_FAMILY from vxworks-predef.h on VxWorks7 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. --- diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h index d2b6025caad9..7268ace41ece 100644 --- a/gcc/config/vxworks.h +++ b/gcc/config/vxworks.h @@ -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="); \ @@ -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 \ diff --git a/gcc/config/vxworks/vxworks-predef.h b/gcc/config/vxworks/vxworks-predef.h index 0ea70fb8c730..46df32c7cc8f 100644 --- a/gcc/config/vxworks/vxworks-predef.h +++ b/gcc/config/vxworks/vxworks-predef.h @@ -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 + +#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 diff --git a/libgcc/config/t-vxworks b/libgcc/config/t-vxworks index 81a4deab073f..42db6a8cb705 100644 --- a/libgcc/config/t-vxworks +++ b/libgcc/config/t-vxworks @@ -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) \