Excerpts from Olivier Hainque's message of August 18, 2020 10:01 am:
> Hello Iain,
>
>> On 17 Aug 2020, at 10:08, Iain Buclaw <[email protected]> wrote:
>>
>> Hi,
>>
>> Currently when building a cross-compiler targeting arm-wrs-vxworks7, the
>> selftests fail unless the VSB_DIR environment variable is set.
>
>> The same !nostdinc condition is used for VXWORKS_ADDITIONAL_CPP_SPEC.
>>
>> OK for mainline?
>
> Thanks for proposing this patch.
>
> I'd rather remove the self-tests -> -nostdinc thing, apparently
> introduced explicitly for VxWorks and this dependency on environment
> variables in specs.
>
> Can you please just test for fself-test instead, in both cases, with
> a comment like
>
> "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."
>
Hi Oliver,
Attached is the change as per your proposal.
Iain.
---
gcc/ChangeLog:
* Makefile.in (SELFTEST_FLAGS): Remove -nostdinc.
* config/vxworks.h (VXWORKS_ADDITIONAL_CPP_SPEC): Replace -nostdinc
with -fself-tests.
(STARTFILE_PREFIX_SPEC): Avoid using VSB_DIR if -fself-tests is used.
---
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 79e854aa938..a71585239da 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1995,8 +1995,6 @@ rest.cross: specs
# GCC's selftests.
# Specify a dummy input file to placate the driver.
-# Specify -nostdinc to work around missing WIND_BASE environment variable
-# required for *-wrs-vxworks-* targets.
# Specify -o /dev/null so the output of -S is discarded. More importantly
# It does not try to create a file with the name "null.s" on POSIX and
# "nul.s" on Windows. Because on Windows "nul" is a reserved file name.
@@ -2005,7 +2003,7 @@ rest.cross: specs
# Specify the path to gcc/testsuite/selftests within the srcdir
# as an argument to -fself-test.
DEVNULL=$(if $(findstring mingw,$(build)),nul,/dev/null)
-SELFTEST_FLAGS = -nostdinc $(DEVNULL) -S -o $(DEVNULL) \
+SELFTEST_FLAGS = $(DEVNULL) -S -o $(DEVNULL) \
-fself-test=$(srcdir)/testsuite/selftests
# Run the selftests during the build once we have a driver and the frontend,
diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index d648d2f23cb..4aa1e320743 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -36,11 +36,16 @@ along with GCC; see the file COPYING3. If not see
/* Since we provide a default -isystem, expand -isystem on the command
line early. */
+
+/* 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
#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) \
@@ -55,7 +60,7 @@ along with GCC; see the file COPYING3. If not see
#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) \
@@ -108,7 +113,8 @@ along with GCC; see the file COPYING3. If not see
#if TARGET_VXWORKS7
#undef STARTFILE_PREFIX_SPEC
-#define STARTFILE_PREFIX_SPEC "%:getenv(VSB_DIR /usr/lib/common)"
+#define STARTFILE_PREFIX_SPEC \
+ "%{!fself-test=*:%:getenv(VSB_DIR /usr/lib/common)}"
#define TLS_SYM "-u __tls__"
#else
#define TLS_SYM ""