On Nov 13, 2025, Olivier Hainque <[email protected]> wrote: > As we discussed through another channel, the VxWorks bits are good for me. > Thanks!
Thanks. I took the liberty of merging the ``#undef NULL`` you subsequently added, so that the patch that hit the trunk already gets that right. [vxworks] wrap base/b_NULL.h to override NULL Some versions of vxworks define NULL to __nullptr in C++, assuming C++11, which breaks at least a number of analyzer tests that get exercised in C++98 mode. Wrap the header that defines NULL so that, after including it, we override the NULL definition with the one provided by stddef.h. That required some infrastructure to enable subdirectories in extra headers. Since USER_H filenames appear as dependencies, that limits the possibilities or markup, so I went for a filesystem-transparent sequence that doesn't appear in any extra_headers whatsoever, namely /././, to mark the beginning of the desired install name. Co-Authored-By: Olivier Hainque <[email protected]> for gcc/ChangeLog * config/vxworks/base/b_NULL.h: New. * config.gcc (extra_headers) <*-*-vxworks*>: Add it. * Makefile.in (stmp-int-hdrs): Support /././ markers in USER_H to mark the beginning of the install name. Document. * doc/sourcebuild.texi (Headers): Document /././ marker. --- gcc/Makefile.in | 21 ++++++++++++++++----- gcc/config.gcc | 3 +++ gcc/config/vxworks/base/b_NULL.h | 32 ++++++++++++++++++++++++++++++++ gcc/doc/sourcebuild.texi | 5 ++++- 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 gcc/config/vxworks/base/b_NULL.h diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5c24a9aab00a5..d05e15e2b6ce1 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -3534,9 +3534,10 @@ gcov-tool$(exeext): $(GCOV_TOOL_OBJS) $(LIBDEPS) stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_list # Copy in the headers provided with gcc. # -# The sed command gets just the last file name component; -# this is necessary because VPATH could add a dirname. -# Using basename would be simpler, but some systems don't have it. +# If the sequence /././ appears somewhere after srcdir in a USER_H +# name, install the header with the name after the marker, even if +# that name involves subdirectories. Otherwise, install it as the +# basename (but some systems don't have the basename program). # # The touch command is here to workaround an AIX/Linux NFS bug. # @@ -3547,10 +3548,20 @@ stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_ -if [ -d include-fixed ] ; then true; else mkdir include-fixed; chmod a+rx include-fixed; fi for file in .. $(USER_H); do \ if [ X$$file != X.. ]; then \ - realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \ + case $$file in \ + "$(srcdir)"*/././*) \ + realfile=`echo $$file | sed -e 's|^.*/\./\./||'`; \ + case $$realfile in \ + */*) \ + realdir=`echo $$realfile | sed -e 's|/[^/]*$$||'`; \ + $(install_sh) -d include/$$realdir;; \ + esac;; \ + *) \ + realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`;; \ + esac; \ $(STAMP) include/$$realfile; \ rm -f include/$$realfile; \ - cp $$file include; \ + cp $$file include/$$realfile; \ chmod a+r include/$$realfile; \ fi; \ done diff --git a/gcc/config.gcc b/gcc/config.gcc index b0fa43b5eba73..d2770ea556b2e 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1140,6 +1140,9 @@ case ${target} in extra_headers="${extra_headers} ../vxworks/math.h ../vxworks/complex.h" extra_headers="${extra_headers} ../vxworks/inttypes.h ../vxworks/setjmp.h" + # The /././ sequence marks the beginning of the install name. + extra_headers="${extra_headers} ../vxworks/././base/b_NULL.h" + # We provide (a tailored version of) stdint.h tm_file="${tm_file} vxworks-stdint.h" use_gcc_stdint=provide diff --git a/gcc/config/vxworks/base/b_NULL.h b/gcc/config/vxworks/base/b_NULL.h new file mode 100644 index 0000000000000..3d677f92a2f12 --- /dev/null +++ b/gcc/config/vxworks/base/b_NULL.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/>. */ + +/* This header wrapper addresses the issue that some versions of VxWorks have + started defining NULL in a way that doesn't work with C++ < 11, so we override + it with GCC's own stddef's NULL. Include the VxWorks version of this header + nevertheless, as it might do other things than defining NULL, and beware that + it usually defines NULL unconditionally without undefining it first, unlike + what stddef.h does. */ + +#undef NULL +#include_next <base/b_NULL.h> +#define __need_NULL +#include <stddef.h> diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 29742e26d8b95..fc1d52c42c9ed 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -343,7 +343,10 @@ In addition to these headers and those generated by fixing system headers to work with GCC, some other headers may also be installed in @file{@var{libsubdir}/include}. @file{config.gcc} may set @code{extra_headers}; this specifies additional headers under -@file{config} to be installed on some systems. +@file{config} to be installed on some systems. They're installed at the +top of the @file{include} tree, unless the optional @samp{/././} +sequence appears in the name, marking the beginning of the name under +which the header should be installed. GCC installs its own version of @code{<float.h>}, from @file{ginclude/float.h}. This is done to cope with command-line options that change the -- Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/ Free Software Activist FSFLA co-founder GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity. Excluding neuro-others for not behaving ""normal"" is *not* inclusive!
