diff options
author | Olivier Hainque <hainque@adacore.com> | 2021-11-26 21:37:46 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@adacore.com> | 2021-12-13 13:54:01 +0000 |
commit | f3f923e51391d279adace7ae24260d87e94b1108 (patch) | |
tree | 8dc16865ed3772d51c706522289ff5d376124731 /gcc/config/vxworks.h | |
parent | 7bf710b5116e6186204edd6a0168202fd8ef0389 (diff) | |
download | gcc-f3f923e51391d279adace7ae24260d87e94b1108.zip gcc-f3f923e51391d279adace7ae24260d87e94b1108.tar.gz gcc-f3f923e51391d279adace7ae24260d87e94b1108.tar.bz2 |
Leverage sysroot for VxWorks
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 also 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.
2021-12-09 Olivier Hainque <hainque@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.
Diffstat (limited to 'gcc/config/vxworks.h')
-rw-r--r-- | gcc/config/vxworks.h | 74 |
1 files changed, 49 insertions, 25 deletions
diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h index 8210de4..a89e3d6 100644 --- a/gcc/config/vxworks.h +++ b/gcc/config/vxworks.h @@ -28,45 +28,70 @@ along with GCC; see the file COPYING3. If not see like a traditional Unix, with more external files. Most of our specs must be aware of the difference. */ -/* We look for the VxWorks header files using the environment - variables that are set in VxWorks to indicate the location of the - system header files. We use -idirafter so that the GCC's own - header-file directories (containing <stddef.h>, etc.) come before - the VxWorks system header directories. */ +/* Help locate system headers, assuming $sysroot set to $VSB_DIR on vx7 and + $WIND_BASE/target prior to that. Specs allow tailoring for RTP vs kernel, + and -idirafter allows putting system directories after GCC's own directories + for standard headers such as <stddef.h> or fixed include. + + Regarding fixed includes, note the effect of sysroot_headers_suffix_spec: + + For the case of VxWorks prior to 7 below, we have: + + #define SYSROOT_HEADERS_SUFFIX_SPEC "%{mrtp:/usr/h;:/h}" + + This results in + + $build_sysroot/h ---> $prefix/include-fixed + $build_sysroot/usr/h ---> $prefix/include-fixed/mrtp for -mrtp + + This is very different from what we'd get without a headers_suffix, + which would be: + + $build_sysroot ---> $prefix/include-fixed/h + /usr/h + + From (say) #include <assert.h>, we would find the fixed version + in the first case, not in the second. */ /* Since we provide a default -isystem, expand -isystem on the command - line early. */ + line early. Then restrict the amount of references we add when compiling + self-tests, as these may be run in contexts where the VxWorks environment + isn't available. */ -/* Self-tests may be run in contexts where the VxWorks environment isn't - available. Prevent attempts at designating the location of runtime header - files, libraries or startfiles, which would fail on unset environment - variables and aren't needed for such tests. */ #if TARGET_VXWORKS7 +/* We arrange not rely on fixed includes for vx7 and the headers spread over + common kernel/rtp directories in addition to specific ones for each mode. + Setup sysroot_headers_suffix_spec to deal with kernel/rtp distinction. */ + +#undef SYSROOT_HEADERS_SUFFIX_SPEC +#define SYSROOT_HEADERS_SUFFIX_SPEC "%{mrtp:/usr/h;:/krnl/h}" + #undef VXWORKS_ADDITIONAL_CPP_SPEC #define VXWORKS_ADDITIONAL_CPP_SPEC \ "%{!nostdinc:%{!fself-test=*: \ %{isystem*} \ - %{mrtp: -idirafter %:getenv(VSB_DIR /h) \ - -idirafter %:getenv(VSB_DIR /share/h) \ - -idirafter %:getenv(VSB_DIR /usr/h/public) \ - -idirafter %:getenv(VSB_DIR /usr/h) \ - ;: -idirafter %:getenv(VSB_DIR /h) \ - -idirafter %:getenv(VSB_DIR /share/h) \ - -idirafter %:getenv(VSB_DIR /krnl/h/system) \ - -idirafter %:getenv(VSB_DIR /krnl/h/public)}}}" + -idirafter %:getenv(VSB_DIR /h) \ + -idirafter %:getenv(VSB_DIR /share/h) \ + -idirafter =/system \ + -idirafter =/public \ + }}" #else /* TARGET_VXWORKS7 */ +/* Prior to vx7, rtp and kernel headers are fairly segregated and fixincludes + is needed on each set of headers to cope with expectations of not so old + libstdc++. A perfect use case for sysroot_headers_suffix. */ + +#undef SYSROOT_HEADERS_SUFFIX_SPEC +#define SYSROOT_HEADERS_SUFFIX_SPEC "%{mrtp:/usr/h;:/h}" + #undef VXWORKS_ADDITIONAL_CPP_SPEC #define VXWORKS_ADDITIONAL_CPP_SPEC \ "%{!nostdinc:%{!fself-test=*: \ %{isystem*} \ - %{mrtp: -idirafter %:getenv(WIND_USR /h) \ - -idirafter %:getenv(WIND_USR /h/wrn/coreip) \ - ;: -idirafter %:getenv(WIND_BASE /target/h) \ - -idirafter %:getenv(WIND_BASE /target/h/wrn/coreip) \ -}}}" + -idirafter =/wrn/coreip \ + }}" #endif @@ -119,8 +144,7 @@ along with GCC; see the file COPYING3. If not see #if TARGET_VXWORKS7 #undef STARTFILE_PREFIX_SPEC -#define STARTFILE_PREFIX_SPEC \ - "%{!fself-test=*:%:getenv(VSB_DIR /usr/lib/common)}" +#define STARTFILE_PREFIX_SPEC "/usr/lib/common" #define TLS_SYM "-u __tls__" #else #define TLS_SYM "" |