Introduce support for vxworks7r2 on x86 and x86_64

This change extends the VxWorks support on intel CPUs to
VxWorks7r2 for x86_64 as well as x86, 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.

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.

2020-10-27  Olivier Hainque  <hainque@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-authored-by: Douglas Rupp <rupp@adacore.com>
Co-authored-by: Pat Bernardi <bernardi@adacore.com>
This commit is contained in:
Olivier Hainque 2020-02-26 13:47:43 +00:00
parent 71e713209a
commit 9a835ba4c0
4 changed files with 84 additions and 41 deletions

View File

@ -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-*)

View File

@ -1,8 +1,19 @@
# Multilibs for VxWorks.
# Build multilibs for normal, -mrtp, and -mrtp -fPIC.
MULTILIB_OPTIONS = mrtp fPIC
MULTILIB_DIRNAMES =
MULTILIB_MATCHES = fPIC=fpic
MULTILIB_EXCEPTIONS = fPIC
# 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
# -fPIC is only supported in combination with -mrtp
MULTILIB_EXCEPTIONS = fPIC
endif

View File

@ -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"); \
else if (TARGET_486) \
builtin_define ("CPU=I80486"); \
else if (TARGET_PENTIUM) \
{ \
builtin_define ("CPU=PENTIUM"); \
builtin_define ("CPU_VARIANT=PENTIUM"); \
} \
else if (TARGET_PENTIUMPRO) \
{ \
builtin_define ("CPU=PENTIUM2"); \
builtin_define ("CPU_VARIANT=PENTIUMPRO"); \
} \
if (TARGET_64BIT) \
VX_CPUDEF (X86_64); \
else if (TARGET_PENTIUM4) \
{ \
builtin_define ("CPU=PENTIUM4"); \
builtin_define ("CPU_VARIANT=PENTIUM4"); \
} \
else if (TARGET_64BIT) \
builtin_define ("CPU=X86_64"); \
{ \
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) \
VX_CPUDEF (I80486); \
else if (TARGET_PENTIUM) \
{ \
VX_CPUDEF (PENTIUM); \
VX_CPUVDEF (PENTIUM); \
} \
else if (TARGET_PENTIUMPRO) \
{ \
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)

View File

@ -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"