This patch modifies the C & C++ VxWorks compiler to predefine the __STDC_ macros verified by gcc.dg/c99-predef-1.c in the testsuite. We setup a vxworks-predef.h header file which arranges to define TARGET_C_PREINCLUDE, in a separate config/vxworks directory where other runtime header files will be added afterwards for libstdc++ support.
Tested in accordance with the description in https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00911.html Committing to mainline. Olivier 2019-12-13 Joel Brobecker <brobec...@adacore.com> * config.gcc <*-*-vxworks*>: Add vxworks-c.o to c_target_objs and cxx_target_objs. Set target_has_targetcm to "yes". Add vxworks-predef.h to extra_headers. * config/t-vxworks (vxworks-c.o): New target. * config/vxworks-c.c: New file. * config/vxworks/vxworks-predef.h: New file.
gcc/config.gcc | 4 ++++ gcc/config/t-vxworks | 4 ++++ gcc/config/vxworks-c.c | 37 +++++++++++++++++++++++++++++ gcc/config/vxworks/vxworks-predef.h | 32 +++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 gcc/config/vxworks-c.c create mode 100644 gcc/config/vxworks/vxworks-predef.h diff --git a/gcc/config.gcc b/gcc/config.gcc index 5aa0130135f..cf73a853e11 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -955,6 +955,10 @@ case ${target} in xm_defines=POSIX extra_options="${extra_options} vxworks.opt" extra_objs="$extra_objs vxworks.o" + c_target_objs="${c_target_objs} vxworks-c.o" + cxx_target_objs="${cxx_target_objs} vxworks-c.o" + extra_headers="${extra_headers} ../vxworks/vxworks-predef.h" + target_has_targetcm="yes" use_gcc_stdint=provide tm_file="${tm_file} vxworks-stdint.h" case ${enable_threads} in diff --git a/gcc/config/t-vxworks b/gcc/config/t-vxworks index 86b26cc1ecc..69b3a2e3199 100644 --- a/gcc/config/t-vxworks +++ b/gcc/config/t-vxworks @@ -20,6 +20,10 @@ vxworks.o: $(srcdir)/config/vxworks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TARGET_H) output.h $(TM_H) $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< +vxworks-c.o: $(srcdir)/config/vxworks-c.c + $(COMPILE) $< + $(POSTCOMPILE) + # Both the kernel and RTP headers provide limits.h. They embed VxWorks # specificities and are dated on some configurations so we both need to # provide our own version and make sure the system one gets exposed. diff --git a/gcc/config/vxworks-c.c b/gcc/config/vxworks-c.c new file mode 100644 index 00000000000..0de94e5eefc --- /dev/null +++ b/gcc/config/vxworks-c.c @@ -0,0 +1,37 @@ +/* C-family target hooks initializer for VxWorks targets. + Copyright (C) 2019 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "c-family/c-target.h" +#include "c-family/c-target-def.h" + +/* Implement TARGET_C_PREINCLUDE for vxworks targets. */ + +static const char * +vxworks_c_preinclude (void) +{ + return "vxworks-predef.h"; +} + +#undef TARGET_C_PREINCLUDE +#define TARGET_C_PREINCLUDE vxworks_c_preinclude + +struct gcc_targetcm targetcm = TARGETCM_INITIALIZER; diff --git a/gcc/config/vxworks/vxworks-predef.h b/gcc/config/vxworks/vxworks-predef.h new file mode 100644 index 00000000000..0ea70fb8c73 --- /dev/null +++ b/gcc/config/vxworks/vxworks-predef.h @@ -0,0 +1,32 @@ +/* This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +#ifndef _VXWORKS_PREDEF_H +#define _VXWORKS_PREDEF_H 1 + +#define __STDC_IEC_559__ 1 +#define __STDC_IEC_559_COMPLEX__ 1 + +/* Define the value of the following macro to match the value + that the OS actually defines it as. */ +#define __STDC_ISO_10646__ 200009L + +#endif -- 2.17.1