Hi Alex, As we discussed through another channel, the VxWorks bits are good for me. Thanks!
On Fri, 9 May 2025 at 04:39, Alexandre Oliva <[email protected]> wrote: > > 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. > > Tested with gcc-14 targeting ppc-vx7r2 and ppc64-vx7r2. Also tested > with trunk on ppc64le-linux-gnu, and with gcc-14 targeting powerpc-elf. > Ok to install? > > > 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 | 28 ++++++++++++++++++++++++++++ > gcc/doc/sourcebuild.texi | 5 ++++- > 4 files changed, 51 insertions(+), 6 deletions(-) > create mode 100644 gcc/config/vxworks/base/b_NULL.h > > diff --git a/gcc/Makefile.in b/gcc/Makefile.in > index 55b4cd7dbed3f..251c1ed3f006c 100644 > --- a/gcc/Makefile.in > +++ b/gcc/Makefile.in > @@ -3475,9 +3475,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. > # > @@ -3488,10 +3489,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 afbf82fd2b8f2..6c453192de0cb 100644 > --- a/gcc/config.gcc > +++ b/gcc/config.gcc > @@ -1126,6 +1126,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..d398ff265b72e > --- /dev/null > +++ b/gcc/config/vxworks/base/b_NULL.h > @@ -0,0 +1,28 @@ > +/* 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_next <base/b_NULL.h> > +#define __need_NULL > +#include <stddef.h> > diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi > index 65eeeccb264ca..38ca16fa6ecf9 100644 > --- a/gcc/doc/sourcebuild.texi > +++ b/gcc/doc/sourcebuild.texi > @@ -342,7 +342,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! >
