Hello,

The build of a VxWorks toolchain relies a lot on system headers
and VxWorks has a few very specific features that require special
processing. For example, different sets of headers for the kernel
vs the rtp modes, which the compiler knows about by way of -mrtp
on the command line.

If we manage to avoid the need for fixincludes on recent versions
of VxWorks (>= 7), we still need to handle at least VxWorks 6.9 at
this stage.

We sort of get away with locating the correct headers at
run-time thanks to environment variables and various tests for
-mrtp in cpp specs, but getting fixincludes to work for old
configurations has always been tricky and getting a toolchain
to build with c++/libstdc++ support gets trickier with every
move to a more recent release.

sysroot_headers_suffix_spec is a pretty powerful device to help
address such issues, and this patch introduces changes that let
us get advantage of it.

The general idea is to leverage the assumption that compilations
occur with --sysroot=$VSB_DIR on vx7 or --sysroot=$WIND_BASE/target
prior to that.

For the toolchains we build, this is achieved with a few
configure options like:

  --with-sysroot
  --with-build-sysroot=${WIND_BASE}/target
  --with-specs=%{!sysroot=*:--sysroot=%:getenv(WIND_BASE /target)}

This allows simplifying the libgcc compilation flags control
and we take the opportunity to merge t-vxworks7 into t-vxworks as
the two files were differing only on the libgcc2 flags part.

This also makes sure that we don't set inhibit_libc true
during the build, which is sane since the build really relies a
lot on system headers.

Preliminary tests showed that a build from mainline sources
now actually fail if the build configuration somehow gets to
inhibit_libc=true.

I have had very good results with this for several ports on a
gcc-11 branch, for both VxWorks 6.9 and two variants of 7.2,
for both kernel and rtp modes, including with shared libs on
two targets for 7.2 (powerpc64 and x86_64).

I was also able to get a successful build of c, c++
and libstdc++ on mainline for VxWorks 6.9, with a few fixincludes
adjustments as expected.

This touches only VxWorks related items and, all in all, I
believe this robustifies the family of ports and helps avoid
build failure with mainline sources so remains applicable
to the current stage. 

Olivier

---

2021-12-09  Olivier Hainque  <hain...@adacore.com>

gcc/
        * config/t-vxworks: Clear NATIVE_SYSTEM_HEADER_DIR.
        * config/vxworks.h (SYSROOT_HEADERS_SUFFIX_SPEC): Define, for
        VxWorks 7 and earlier.
        (VXWORKS_ADDITIONAL_CPP_SPEC): Simplify accordingly.
        (STARTFILE_PREFIX_SPEC): Adjust accordingly.
        * config/rs6000/vxworks.h (STARTFILE_PREFIX_SPEC): Adjust.

libgcc/
        * config/t-vxworks (LIBGCC2_INCLUDES): Simplify and handle
        both VxWorks7 and earlier.
        * config/t-vxworks7: Remove.
        * config.host: Remove special case for vxworks7.

Attachment: 0001-Leverage-sysroot-for-VxWorks.patch
Description: Binary data



Reply via email to