Hello,

This change extends the VxWorks support on intel CPUs to
VxWorks7r2, with a "mcmodel=large" additional multilib for
the 64bit configuration.
    
The support for fPIC is not functional yet for this model,
so we just don't add the corresponding multilib.

Following the trend already visible on powerpc, the base system
environment is getting extremely close to the standard Linux one,
so fPIC and usual kernel vs RTP distinction apart, the new port 
essentially just leverages the base ELF definitions.
    
We extend the range of CPU families handled by TARGET_OS_CPP_BUILTINS,
accounting for the fact that archs older than PENTIUM4 are
not supported (any more) by VxWorks 7. As we did for powerpc, we
leverage VX_CPU_PREFIX to emit different forms of definitions for
different families of VxWorks as the system headers's expectations
has evolved between Vx 5, 6 and 7.

Wiith libquadmath disabled (compile time confusion from an
imprecise definition of “howmany” in some variants of the system
headers), we get decent gcc/g++/libstdc++ testsuite results with
this change on a gcc-9 source base, for both 32 and 64bit environments,
for both kernel and RTP modes.

I was able to get good gcc and g++ results for RTPs with this change
applied on a gcc-10 source base and sanity checked that a build with
mainline sources proceeds to completion.

Olivier
    
2020-10-27  Olivier Hainque  <hain...@adacore.com>
    
gcc/
        * config.gcc: Adjust the ix86/x86_64-wrs-vxworks filters
        to apply to VxWorks 7 as well.
        * config/i386/t-vxworks (MULTILIB_OPTIONS, MULTILIB_DIRNAMES):
        Remove the fPIC multilib and add one for the large code model
        on x86_64.
        * config/i386/vxworks.h: Separate sections for TARGET_VXWORKS7,
        other variants and common bits.
        (TARGET_OS_CPP_BUILTINS): Augment to support a range of CPU
        families. Leverage VX_CPU_PREFIX.
        (CC1_SPEC): Add definition.
        (STACK_CHECK_PROTECT): Use conditional expression instead of
        heavier to read conditioned macro definitions.
    
libgcc/
        config.host: Adjust the ix86/x86_64-wrs-vxworks filters
        to apply to VxWorks 7 as well.
    
Co-autored-by:  Douglas Rupp  <r...@adacore.com>
Co-autored-by:  Pat Bernardi  <berna...@adacore.com>

diff --git a/gcc/config.gcc b/gcc/config.gcc
index d14a1a3e8124..b169f2fc3aad 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2050,7 +2050,7 @@ i[34567]86-*-solaris2* | x86_64-*-solaris2*)
                esac
        fi
        ;;
-i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae|i[4567]86-wrs-vxworks7|x86_64-wrs-vxworks7)
+i[4567]86-wrs-vxworks*|x86_64-wrs-vxworks7*)
        tm_file="${tm_file} i386/unix.h i386/att.h elfos.h"
        case ${target} in
          x86_64-*)
diff --git a/gcc/config/i386/t-vxworks b/gcc/config/i386/t-vxworks
index c440b1f90317..8f5e8c73b71e 100644
--- a/gcc/config/i386/t-vxworks
+++ b/gcc/config/i386/t-vxworks
@@ -1,8 +1,19 @@
 # Multilibs for VxWorks.
 
-# Build multilibs for normal, -mrtp, and -mrtp -fPIC.
-MULTILIB_OPTIONS = mrtp fPIC
-MULTILIB_DIRNAMES =
+# The common variant across the board is for -mrtp
+MULTILIB_OPTIONS = mrtp
+MULTILIB_DIRNAMES = mrtp
+
+# Then variants for the "large" code model on x86_64, or fPIC on x86,
+# RTP only. -fPIC -mrtp -mcmodel=large is not functional yet.
+ifneq (,$(findstring x86_64, $(target)))
+MULTILIB_OPTIONS += mcmodel=large
+MULTILIB_DIRNAMES += large
+else
+MULTILIB_OPTIONS += fPIC
+MULTILIB_DIRNAMES += fPIC
 MULTILIB_MATCHES = fPIC=fpic
-MULTILIB_EXCEPTIONS = fPIC
 
+# -fPIC is only supported in combination with -mrtp
+MULTILIB_EXCEPTIONS = fPIC
+endif
diff --git a/gcc/config/i386/vxworks.h b/gcc/config/i386/vxworks.h
index ad9404b40ccd..891b4ff04b5f 100644
--- a/gcc/config/i386/vxworks.h
+++ b/gcc/config/i386/vxworks.h
@@ -18,12 +18,21 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+/* VxWorks after 7 SR0600 use the ELF ABI and the system environment is llvm
+   based.  Earlier versions have GNU based environment components and use the
+   same ABI as Solaris 2.  */
+
+#if TARGET_VXWORKS7
+
+#undef VXWORKS_PERSONALITY
+#define VXWORKS_PERSONALITY "llvm"
+
+#else
+
 #undef ASM_OUTPUT_ALIGNED_BSS
 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
 
-/* VxWorks uses the same ABI as Solaris 2, so use i386/sol2.h version.  */
-
 #undef TARGET_SUBTARGET_DEFAULT
 #define TARGET_SUBTARGET_DEFAULT \
        (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_VECT8_RETURNS)
@@ -41,43 +50,73 @@ along with GCC; see the file COPYING3.  If not see
 #undef SIZE_TYPE
 #define SIZE_TYPE (TARGET_LP64 ? "long unsigned int" : "unsigned int")
 
+/* We cannot use PC-relative accesses for VxWorks PIC because there is no
+   fixed gap between segments.  */
+#undef ASM_PREFERRED_EH_DATA_FORMAT
+
 #if TARGET_64BIT_DEFAULT
 #undef VXWORKS_SYSCALL_LIBS_RTP
 #define VXWORKS_SYSCALL_LIBS_RTP "-lsyscall"
 #endif
 
+#endif
+
+/* CPU macro definitions, ordered to account for VxWorks 7 not
+   supporting CPUs older than PENTIUM4 since SR0650.  */
+
+#define VX_CPUDEF(CPU) builtin_define(VX_CPU_PREFIX "CPU=" #CPU)
+#define VX_CPUVDEF(CPU) builtin_define(VX_CPU_PREFIX "CPU_VARIANT=" #CPU)
+
 #define TARGET_OS_CPP_BUILTINS()                       \
   do                                                   \
     {                                                  \
       VXWORKS_OS_CPP_BUILTINS ();                      \
-      if (TARGET_386)                                  \
-        builtin_define ("CPU=I80386");                 \
+      if (TARGET_64BIT)                                        \
+       VX_CPUDEF (X86_64);                             \
+      else if (TARGET_PENTIUM4)                                \
+       {                                               \
+         VX_CPUDEF (PENTIUM4);                         \
+         VX_CPUVDEF (PENTIUM4);                        \
+       }                                               \
+      else if (TARGET_CORE2)                           \
+       VX_CPUDEF (CORE2);                              \
+      else if (TARGET_NEHALEM)                         \
+       VX_CPUDEF (NEHALEM);                            \
+      else if (TARGET_SANDYBRIDGE)                     \
+       VX_CPUDEF (SANDYBRIDGE);                        \
+      else if (TARGET_HASWELL)                         \
+       VX_CPUDEF (HASWELL);                            \
+      else if (TARGET_SILVERMONT)                      \
+       VX_CPUDEF (SILVERMONT);                         \
+      else if (TARGET_SKYLAKE || TARGET_SKYLAKE_AVX512) \
+       VX_CPUDEF (SKYLAKE);                            \
+      else if (TARGET_GOLDMONT)                                \
+       VX_CPUDEF (GOLDMONT);                           \
+      else if (TARGET_VXWORKS7)                                \
+       VX_CPUDEF (PENTIUM4);                           \
+      else if (TARGET_386)                             \
+       VX_CPUDEF (I80386);                             \
       else if (TARGET_486)                             \
-        builtin_define ("CPU=I80486");                 \
+       VX_CPUDEF (I80486);                             \
       else if (TARGET_PENTIUM)                         \
-        {                                              \
-          builtin_define ("CPU=PENTIUM");              \
-          builtin_define ("CPU_VARIANT=PENTIUM");      \
-        }                                              \
+       {                                               \
+         VX_CPUDEF (PENTIUM);                          \
+         VX_CPUVDEF (PENTIUM);                         \
+       }                                               \
       else if (TARGET_PENTIUMPRO)                      \
-        {                                              \
-          builtin_define ("CPU=PENTIUM2");             \
-          builtin_define ("CPU_VARIANT=PENTIUMPRO");   \
-        }                                              \
-      else if (TARGET_PENTIUM4)                                \
-        {                                              \
-          builtin_define ("CPU=PENTIUM4");             \
-          builtin_define ("CPU_VARIANT=PENTIUM4");     \
-        }                                              \
-      else if (TARGET_64BIT)                           \
-          builtin_define ("CPU=X86_64");               \
+       {                                               \
+         VX_CPUDEF (PENTIUM2);                         \
+         VX_CPUVDEF (PENTIUMPRO);                      \
+       }                                               \
       else                                             \
-          builtin_define ("CPU=I80386");               \
-    }                                                  \
+       VX_CPUDEF (I80386);                             \
+    }                                                  \
   while (0)
 
 #undef  CPP_SPEC
 #define CPP_SPEC VXWORKS_ADDITIONAL_CPP_SPEC
+#undef  CC1_SPEC
+#define CC1_SPEC VXWORKS_CC1_SPEC
 #undef  LIB_SPEC
 #define LIB_SPEC VXWORKS_LIB_SPEC
 #undef  STARTFILE_SPEC
@@ -97,18 +136,11 @@ along with GCC; see the file COPYING3.  If not see
 #undef FUNCTION_PROFILER
 #define FUNCTION_PROFILER(FILE,LABELNO) VXWORKS_FUNCTION_PROFILER(FILE,LABELNO)
 
-/* We cannot use PC-relative accesses for VxWorks PIC because there is no
-   fixed gap between segments.  */
-#undef ASM_PREFERRED_EH_DATA_FORMAT
-
 /* Define this to be nonzero if static stack checking is supported.  */
 #define STACK_CHECK_STATIC_BUILTIN 1
 
 /* This platform supports the probing method of stack checking (RTP mode).
-   8K is reserved in the stack to propagate exceptions in case of overflow. 
+   8K is reserved in the stack to propagate exceptions in case of overflow.
    On 64-bit targets, we double that size.  */
-#if TARGET_64BIT_DEFAULT
-#define STACK_CHECK_PROTECT 16384
-#else
-#define STACK_CHECK_PROTECT 8192
-#endif
+
+#define STACK_CHECK_PROTECT (TARGET_64BIT_DEFAULT ? 16 * 1024 : 8 * 1024)
diff --git a/libgcc/config.host b/libgcc/config.host
index fd8e55e92e1a..40823f0cff43 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -774,7 +774,7 @@ i[34567]86-*-solaris2* | x86_64-*-solaris2*)
        tm_file="${tm_file} i386/elf-lib.h"
        md_unwind_header=i386/sol2-unwind.h
        ;;
-i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae|i[4567]86-wrs-vxworks7|x86_64-wrs-vxworks7)
+i[4567]86-wrs-vxworks*|x86_64-wrs-vxworks*)
        ;;
 i[34567]86-*-cygwin*)
        extra_parts="crtbegin.o crtbeginS.o crtend.o crtfastmath.o"
-- 
2.17.1

Reply via email to