[PATCH] gcc: vxworks: fix providing stdint.h header

Rasmus Villemoes rv@rasmusvillemoes.dk
Fri Nov 12 10:15:41 GMT 2021


Commit bbbc05957e (Arrange to preinclude yvals.h ahead of stdint on
VxWorks 7) breaks the build of libstdc++ for our VxWorks 5 platform.

In file included from .../gcc-build/powerpc-wrs-vxworks/libstdc++-v3/include/memory:72,
                 from .../gcc-src/libstdc++-v3/include/precompiled/stdc++.h:82:
.../gcc-build/powerpc-wrs-vxworks/libstdc++-v3/include/bits/align.h:36:10: fatal error: stdint.h: No such file or directory
   36 | #include <stdint.h>     // uintptr_t
      |          ^~~~~~~~~~
compilation terminated.
Makefile:1861: recipe for target 'powerpc-wrs-vxworks/bits/stdc++.h.gch/O2ggnu++0x.gch' failed
make[5]: *** [powerpc-wrs-vxworks/bits/stdc++.h.gch/O2ggnu++0x.gch] Error 1

The problem is that the stdint.h header does not exist (in the
gcc/include/ directory) during the build, but is only added at "make
install" time.

For the approach with an extra makefile fragment to work, that rule
would have to fire after stmp-int-hdrs as it does now (i.e., after the
common logic has removed stdint.h), but it must also run before we
actually start building target libraries that depend on having a
stdint.h - and I can't find something reasonable to make the rule a
dependency of.

I agree with the intent of avoiding "altering the common stdint-gcc.h
with unpleasant vxworks specific bits". The best approach I could come
up with is adding another variant of "use_gcc_stdint", "preserve",
meaning "leave whatever the target's extra_headers settings put inside
gcc/include/ alone". There's no change in behaviour for any of the
existing values "none", "wrap" or "provide".

gcc/ChangeLog:

	* Makefile.in (stmp-int-hdrs): Only remove include/stdint.h when
	$(USE_GCC_STDINT) != "preserve".
	* config.gcc: Document new possible value of use_gcc_stdint:
	"preserve".
	* config.gcc (vxworks): Add ../vxworks/stdint.h to
	extra_headers and set use_gcc_stdint=preserve.
	* config/t-vxworks: Remove install-stdint.h rule.
---

I have previously sent something similar to Olivier privately, hoping
I could come up with a better/cleaner fix. But I have failed, so now
I've taken what I had and added the necesary documentation and
changelog bits.

Better ideas are of course welcome. I thought of using "custom"
instead of "preserve", but chose the latter since "wrap" and "provide"
are verbs.

 gcc/Makefile.in      |  4 +++-
 gcc/config.gcc       | 11 ++++++-----
 gcc/config/t-vxworks | 12 ------------
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 571e9c28e29..759982f1d7d 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3132,7 +3132,9 @@ stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(USER_H) fixinc_list
 	    chmod a+r include/$$file; \
 	  fi; \
 	done
-	rm -f include/stdint.h
+	if [ $(USE_GCC_STDINT) != preserve ]; then \
+	  rm -f include/stdint.h; \
+	fi
 	if [ $(USE_GCC_STDINT) = wrap ]; then \
 	  rm -f include/stdint-gcc.h; \
 	  cp $(srcdir)/ginclude/stdint-gcc.h include/stdint-gcc.h; \
diff --git a/gcc/config.gcc b/gcc/config.gcc
index edd12655c4a..7a236e1a967 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -129,8 +129,9 @@
 #  use_gcc_stdint	If "wrap", install a version of stdint.h that
 #			wraps the system's copy for hosted compilations;
 #			if "provide", provide a version of systems without
-#			such a system header; otherwise "none", do not
-#			provide such a header at all.
+#			such a system header; if "preserve", keep the copy
+#			installed via the target's extra_headers; otherwise
+#			"none", do not provide such a header at all.
 #
 #  extra_programs	List of extra executables compiled for this target
 #			machine, used when linking.
@@ -1024,11 +1025,11 @@ case ${target} in
   tm_file="${tm_file} vxworks-stdint.h"
 
   # .. only through the yvals conditional wrapping mentioned above
-  # to abide by the VxWorks 7 expectations.  The final copy is performed
-  # explicitly by a t-vxworks Makefile rule.
+  # to abide by the VxWorks 7 expectations.
 
-  use_gcc_stdint=none
+  use_gcc_stdint=preserve
   extra_headers="${extra_headers} ../../ginclude/stdint-gcc.h"
+  extra_headers="${extra_headers} ../vxworks/stdint.h"
 
   case ${enable_threads} in
     no) ;;
diff --git a/gcc/config/t-vxworks b/gcc/config/t-vxworks
index 5a06ebe1b87..a544bedf634 100644
--- a/gcc/config/t-vxworks
+++ b/gcc/config/t-vxworks
@@ -24,18 +24,6 @@ vxworks-c.o: $(srcdir)/config/vxworks-c.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-# Arrange to install our stdint.h wrapper, by copying it in the
-# build-time include dir before this include dir is installed and after
-# stmp-int-hdrs removes it (because it was told we don't provide it).
-
-INSTALL_HEADERS += install-stdint.h
-
-install-stdint.h: stmp-int-hdrs
-	cp -p $(srcdir)/config/vxworks/stdint.h include/stdint.h
-	chmod a+r include/stdint.h
-
-$(INSTALL_HEADERS_DIR): install-stdint.h
-
 # 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.
-- 
2.31.1



More information about the Gcc-patches mailing list