This change fixes latent failures actually observed when activating
libstdc++ for VxWorks on aarch46 VxWorks 7 and powerpc VxWorks 6.

    The system limits.h is dated on some configurations, so we
    provide our own version to expose constants required by more
    recent C standards.  Our version includes the system
    one nevertheless, which has its own specificities. As the system
    version sometimes originates from GCC, we need to be careful
    that the two files use distinct macro names to protect against
    recursive inclusions. 

    We achieve this by setting up an alternate header where we update
    the inclusion protection macro name:
    
Tested in accordance with the description in
https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00911.html

Committing to mainline.

2019-12-13  Olivier Hainque  <hain...@adacore.com>
            Jerome Lambourg  <labo...@adacore.com>
    
        * config/t-vxworks: Arrange to alter/restore glimits.h
        before/after stmp-int-hdrs, so it uses a different macro
        name to protect itself against recursive inclusions.

 gcc/config/t-vxworks | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/gcc/config/t-vxworks b/gcc/config/t-vxworks
index d3a350f5f8a..86b26cc1ecc 100644
--- a/gcc/config/t-vxworks
+++ b/gcc/config/t-vxworks
@@ -16,9 +16,40 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-# Both the kernel and RTP headers provide limits.h.
-LIMITS_H_TEST = true
-
 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) $<
+
+# 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.
+
+LIMITS_H_TEST = true
+STMP_FIXINC = stmp-fixinc
+
+# VxWorks system environments have been GCC based for a long time and we need
+# to make sure that our files and the system ones use distinct macro names to
+# protect against recursive inclusions.  We achieve this by temporarily
+# substituting the headers used by stmp-int-headers with alternative versions
+# where we add some version indication in the inclusion-protection macro
+# names.
+
+# Before the standard stmp-int-headers operations take place, arrange to
+# copy the current version of the relevant header files locally, generate
+# the alternate version and replace the original version with ours:
+
+stmp-int-hdrs: subst-glimits.h
+
+subst-%.h:
+       cp -p $(srcdir)/$*.h orig-$*.h
+       ID=$$(echo $(BASEVER_c) | sed -e 's/\./_/g'); \
+       sed -e "s/_LIMITS_H__/_LIMITS_H_$${ID}_/" < $(srcdir)/$*.h > $@
+       cp $@ $(srcdir)/$*.h
+
+# Then arrange to restore the original versions after the standard
+# operations have taken place:
+
+INSTALL_HEADERS += restore-glimits.h
+
+restore-glimits.h: stmp-int-hdrs
+       cp -p orig-glimits.h $(srcdir)/glimits.h
-- 
2.17.1

Reply via email to