Re: [PATCH v2] testsuite: introduce hostedlib effective target

2024-09-12 Thread Mike Stump
On Sep 3, 2024, at 11:44 PM, Alexandre Oliva  wrote:
> 
> Here's an updated and refreshed version that gets trunk built with
> --disable-hosted-libstdcxx on x86_64-linux-gnu to not get any spurious
> fails during in-tree testing.  Also bootstrapped on hosted
> x86_64-linux-gnu.  Ok to install?

Ok.



Re: [PATCH v2] testsuite: introduce hostedlib effective target

2024-09-04 Thread Mike Stump
On Sep 3, 2024, at 11:44 PM, Alexandre Oliva  wrote:
> 
> On Nov  9, 2023, Mike Stump  wrote:
> 
>> On Nov 8, 2023, at 8:29 AM, Alexandre Oliva  wrote:
>>> 
>>> On Nov  5, 2023, Mike Stump  wrote:
>>> 
 that, otherwise, I'll approve this version.
>>> 
>>> FWIW, this version is not usable as is.  Something went wrong
> 
>> Updates and fixes to the original plan are fine.
> 
>> I'm still planning on letting you decide based upon input from everyone.  :-)
> 
> Here's an updated and refreshed version that gets trunk built with
> --disable-hosted-libstdcxx on x86_64-linux-gnu to not get any spurious
> fails during in-tree testing.  Also bootstrapped on hosted
> x86_64-linux-gnu.  Ok to install?

Can I ask a global person and/or Jason to weigh in?

The little details are fine, but I like consensus on the larger plan, since 
this ripples so far across the testsuite.

I suppose this is just a knock on of the existence of the 
--disable-hosted-libstdcxx flag.

> Several C++ tests fail with --disable-hosted-libstdcxx, whether
> because stdc++exp gets linked in despite not being built, because
> standard headers are included but that are unavailable in this mode,
> or because headers are (mistakenly?) expected to introduce
> declarations such as for abort, malloc, etc, but in this mode they
> don't.
> 
> This patch introduces an effective target for GCC test, equivalent to
> one that's available in the libstdc++-v3 testsuite, and arranges for
> all such tests to be skipped when libstdc++-v3 is not hosted.
> 
> 
> Co-Authored-By: Olivier Hainque 
> 
> for  gcc/ChangeLog
> 
>   * doc/sourcebuild.texi (hostedlib): New effective target.
> 
> for  gcc/testsuite/ChangeLog
> 
>   * lib/target-supports.exp (check_effective_target_hostedlib):
>   New.
>   * g++.dg/contracts/contracts-access1.C: Skip if !hostedlib
>   because of libstdc++exp.
>   * g++.dg/contracts/contracts-assume3.C: Likewise.
>   * g++.dg/contracts/contracts-assume4.C: Likewise.
>   * g++.dg/contracts/contracts-config1.C: Likewise.
>   * g++.dg/contracts/contracts-constexpr1.C: Likewise.
>   * g++.dg/contracts/contracts-deduced2.C: Likewise.
>   * g++.dg/contracts/contracts-externC.C: Likewise.
>   * g++.dg/contracts/contracts-friend1.C: Likewise.
>   * g++.dg/contracts/contracts-multiline1.C: Likewise.
>   * g++.dg/contracts/contracts-nested-class2.C: Likewise.
>   * g++.dg/contracts/contracts-post2.C: Likewise.
>   * g++.dg/contracts/contracts-post3.C: Likewise.
>   * g++.dg/contracts/contracts-pre2a2.C: Likewise.
>   * g++.dg/contracts/contracts10.C: Likewise.
>   * g++.dg/contracts/contracts18.C: Likewise.
>   * g++.dg/contracts/contracts19.C: Likewise.
>   * g++.dg/contracts/contracts2.C: Likewise.
>   * g++.dg/contracts/contracts24.C: Likewise.
>   * g++.dg/contracts/contracts25.C: Likewise.
>   * g++.dg/contracts/contracts3.C: Likewise.
>   * g++.dg/contracts/contracts4.C: Likewise.
>   * g++.dg/contracts/contracts5.C: Likewise.
>   * g++.dg/contracts/contracts6.C: Likewise.
>   * g++.dg/contracts/contracts7.C: Likewise.
>   * g++.dg/contracts/contracts9.C: Likewise.
>   * g++.dg/contracts/pr110159.C: Likewise.
>   * g++.dg/contracts/pr115434.C: Likewise.  Adjust line numbers.
>   * c-c++-common/pr36513-2.c: Skip if !hostedlib because of
>   unavailable headers.
>   * c-c++-common/analyzer/pr93290.c: Likewise.
>   * g++.dg/analyzer/pr93212.C: Likewise.
>   * g++.dg/analyzer/vfunc-2.C: Likewise.
>   * g++.dg/cdce3.C: Likewise.  Adjust line numbers.
>   * g++.dg/concepts/expression.C: Likewise.
>   * g++.dg/concepts/fn3.C: Likewise.
>   * g++.dg/concepts/fn9.C: Likewise.
>   * g++.dg/concepts/generic-fn.C: Likewise.
>   * g++.dg/contracts/contracts-assume2.C: Likewise.
>   * g++.dg/contracts/contracts-ignore2.C: Likewise.
>   * g++.dg/contracts/contracts-post7.C: Likewise.
>   * g++.dg/contracts/contracts-pre10.C: Likewise.
>   * g++.dg/contracts/contracts-pre2.C: Likewise.
>   * g++.dg/contracts/contracts-pre3.C: Likewise.
>   * g++.dg/contracts/contracts-pre4.C: Likewise.
>   * g++.dg/contracts/contracts-pre5.C: Likewise.
>   * g++.dg/contracts/contracts-pre7.C: Likewise.
>   * g++.dg/contracts/contracts-pre9.C: Likewise.
>   * g++.dg/contracts/contracts-redecl3.C: Likewise.
>   * g++.dg/contracts/contracts-redecl4.C: Likewise.
>   * g++.dg/contracts/contracts-redecl6.C: Likewise.
>   * g++.dg/contracts/contracts-redecl7.C: Likewise.
>   * g++.dg/contracts/contracts-tmpl-spec1.C: Likewise.
>   * g++.dg/contracts/contracts-tmpl-spec2.C: Likewise.
>   * g++.dg/contracts/contracts-tmpl-spec3.C: Likewise.
>   * g++.dg/contracts/contracts14.C: Likewise.
>   * g++.dg/contracts/contracts15.C: Likewise.
>   * g++.dg/contracts/contracts16.C: Likewise.
>   * g++.dg/contracts/contracts17.C: Likewise.
>   * g++

[PATCH v2] testsuite: introduce hostedlib effective target

2024-09-03 Thread Alexandre Oliva
On Nov  9, 2023, Mike Stump  wrote:

> On Nov 8, 2023, at 8:29 AM, Alexandre Oliva  wrote:
>> 
>> On Nov  5, 2023, Mike Stump  wrote:
>> 
>>> that, otherwise, I'll approve this version.
>> 
>> FWIW, this version is not usable as is.  Something went wrong

> Updates and fixes to the original plan are fine.

> I'm still planning on letting you decide based upon input from everyone.  :-)

Here's an updated and refreshed version that gets trunk built with
--disable-hosted-libstdcxx on x86_64-linux-gnu to not get any spurious
fails during in-tree testing.  Also bootstrapped on hosted
x86_64-linux-gnu.  Ok to install?


Several C++ tests fail with --disable-hosted-libstdcxx, whether
because stdc++exp gets linked in despite not being built, because
standard headers are included but that are unavailable in this mode,
or because headers are (mistakenly?) expected to introduce
declarations such as for abort, malloc, etc, but in this mode they
don't.

This patch introduces an effective target for GCC test, equivalent to
one that's available in the libstdc++-v3 testsuite, and arranges for
all such tests to be skipped when libstdc++-v3 is not hosted.


Co-Authored-By: Olivier Hainque 

for  gcc/ChangeLog

* doc/sourcebuild.texi (hostedlib): New effective target.

for  gcc/testsuite/ChangeLog

* lib/target-supports.exp (check_effective_target_hostedlib):
New.
* g++.dg/contracts/contracts-access1.C: Skip if !hostedlib
because of libstdc++exp.
* g++.dg/contracts/contracts-assume3.C: Likewise.
* g++.dg/contracts/contracts-assume4.C: Likewise.
* g++.dg/contracts/contracts-config1.C: Likewise.
* g++.dg/contracts/contracts-constexpr1.C: Likewise.
* g++.dg/contracts/contracts-deduced2.C: Likewise.
* g++.dg/contracts/contracts-externC.C: Likewise.
* g++.dg/contracts/contracts-friend1.C: Likewise.
* g++.dg/contracts/contracts-multiline1.C: Likewise.
* g++.dg/contracts/contracts-nested-class2.C: Likewise.
* g++.dg/contracts/contracts-post2.C: Likewise.
* g++.dg/contracts/contracts-post3.C: Likewise.
* g++.dg/contracts/contracts-pre2a2.C: Likewise.
* g++.dg/contracts/contracts10.C: Likewise.
* g++.dg/contracts/contracts18.C: Likewise.
* g++.dg/contracts/contracts19.C: Likewise.
* g++.dg/contracts/contracts2.C: Likewise.
* g++.dg/contracts/contracts24.C: Likewise.
* g++.dg/contracts/contracts25.C: Likewise.
* g++.dg/contracts/contracts3.C: Likewise.
* g++.dg/contracts/contracts4.C: Likewise.
* g++.dg/contracts/contracts5.C: Likewise.
* g++.dg/contracts/contracts6.C: Likewise.
* g++.dg/contracts/contracts7.C: Likewise.
* g++.dg/contracts/contracts9.C: Likewise.
* g++.dg/contracts/pr110159.C: Likewise.
* g++.dg/contracts/pr115434.C: Likewise.  Adjust line numbers.
* c-c++-common/pr36513-2.c: Skip if !hostedlib because of
unavailable headers.
* c-c++-common/analyzer/pr93290.c: Likewise.
* g++.dg/analyzer/pr93212.C: Likewise.
* g++.dg/analyzer/vfunc-2.C: Likewise.
* g++.dg/cdce3.C: Likewise.  Adjust line numbers.
* g++.dg/concepts/expression.C: Likewise.
* g++.dg/concepts/fn3.C: Likewise.
* g++.dg/concepts/fn9.C: Likewise.
* g++.dg/concepts/generic-fn.C: Likewise.
* g++.dg/contracts/contracts-assume2.C: Likewise.
* g++.dg/contracts/contracts-ignore2.C: Likewise.
* g++.dg/contracts/contracts-post7.C: Likewise.
* g++.dg/contracts/contracts-pre10.C: Likewise.
* g++.dg/contracts/contracts-pre2.C: Likewise.
* g++.dg/contracts/contracts-pre3.C: Likewise.
* g++.dg/contracts/contracts-pre4.C: Likewise.
* g++.dg/contracts/contracts-pre5.C: Likewise.
* g++.dg/contracts/contracts-pre7.C: Likewise.
* g++.dg/contracts/contracts-pre9.C: Likewise.
* g++.dg/contracts/contracts-redecl3.C: Likewise.
* g++.dg/contracts/contracts-redecl4.C: Likewise.
* g++.dg/contracts/contracts-redecl6.C: Likewise.
* g++.dg/contracts/contracts-redecl7.C: Likewise.
* g++.dg/contracts/contracts-tmpl-spec1.C: Likewise.
* g++.dg/contracts/contracts-tmpl-spec2.C: Likewise.
* g++.dg/contracts/contracts-tmpl-spec3.C: Likewise.
* g++.dg/contracts/contracts14.C: Likewise.
* g++.dg/contracts/contracts15.C: Likewise.
* g++.dg/contracts/contracts16.C: Likewise.
* g++.dg/contracts/contracts17.C: Likewise.
* g++.dg/contracts/contracts22.C: Likewise.
* g++.dg/contracts/contracts35.C: Likewise.
* g++.dg/coroutines/pr100611.C: Likewise.
* g++.dg/coroutines/pr100772-b.C: Likewise.
* g++.dg/coroutines/pr101133.C: Likewise.
* g++.dg/coroutines/pr101367.C: Likewise.
* g++.dg/coroutines/pr101976.C: Likewise.
* g++.dg/coroutines/pr102454.C: Lik

Re: testsuite: introduce hostedlib effective target

2023-11-09 Thread Mike Stump
On Nov 8, 2023, at 8:29 AM, Alexandre Oliva  wrote:
> 
> On Nov  5, 2023, Mike Stump  wrote:
> 
>> that, otherwise, I'll approve this version.
> 
> FWIW, this version is not usable as is.  Something went wrong in my
> testing, and several regressions only visible in hosted mode made to the
> version I posted, that adds some missing end-of-comment markers for the
> added dg directives, and moving the new dg directive to the end so as to
> not disturb line numbers.  I've got a fully fixed and properly tested
> version, but since it's about as big as the original patch, I'll only
> post it upon request.

Updates and fixes to the original plan are fine.

I'm still planning on letting you decide based upon input from everyone.  :-)


Re: testsuite: introduce hostedlib effective target

2023-11-08 Thread Alexandre Oliva
On Nov  5, 2023, Mike Stump  wrote:

> that, otherwise, I'll approve this version.

FWIW, this version is not usable as is.  Something went wrong in my
testing, and several regressions only visible in hosted mode made to the
version I posted, that adds some missing end-of-comment markers for the
added dg directives, and moving the new dg directive to the end so as to
not disturb line numbers.  I've got a fully fixed and properly tested
version, but since it's about as big as the original patch, I'll only
post it upon request.

(in case anyone's interested, it's one of the changes in
refs/users/aoliva/heads/testme that's not in
refs/users/aoliva/headers/testbase right now)

-- 
Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/
   Free Software Activist   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive


Re: testsuite: introduce hostedlib effective target

2023-11-08 Thread Jonathan Wakely
On Wed, 8 Nov 2023 at 15:48, Jonathan Wakely  wrote:
>
> On Wed, 8 Nov 2023 at 15:30, Alexandre Oliva  wrote:
> >
> > On Nov  7, 2023, Jonathan Wakely  wrote:
> >
> > > An alternative approach for the g++ testsuite would be to provide a
> > > set of dummy headers for the non-freestanding ones, so that all the
> > > hosted-only headers are provided by the testsuite itself, but consist
> > > of a single line:
> >
> > > #error not available in freestanding
> >
> > > Then match on that and XFAIL. So the individual tests themselves
> > > wouldn't need the dg-skip-if added to them, they would just
> > > automatically XFAIL if they use a hosted-only header.
> >
> > *nod*.  That wouldn't cover all the circumstances, alas: there are tests
> > that fail in freestanding mode not because of headers, but because
> > -fcontracts (currently?) links libstdc++exp in, and that library is not
> > even built in freestanding mode.
>
> Hmm, yes, that seems like a bug. Either we should provide
> libstdc++exp.a for freestanding builds (with a simplified contract
> violation handler that doesn't print to stdout), or the front end
> should not add -lstdc++exp when -ffreestanding is used (which would
> require teh user, or the testsuite in your case, to provide a custom
> contract violation handler), or it should be an error to use
> -fcontracts and -ffreestanding together.
>
> The libstdc++-v3/src/experimental/contract.cc file *already* supports
> freestanding, we just don't actually build it for freestanding. We can
> do that.

Which might be as simple as:

--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -34,14 +34,13 @@ backtrace_dir = libbacktrace
else
backtrace_dir =
endif
-
-experimental_dir = experimental
else
filesystem_dir =
backtrace_dir =
-experimental_dir =
endif

+experimental_dir = experimental
+
## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE.
SUBDIRS = c++98 c++11 c++17 c++20 c++23 \
   $(filesystem_dir) $(backtrace_dir) $(experimental_dir)



Re: testsuite: introduce hostedlib effective target

2023-11-08 Thread Jonathan Wakely
On Wed, 8 Nov 2023 at 15:30, Alexandre Oliva  wrote:
>
> On Nov  7, 2023, Jonathan Wakely  wrote:
>
> > An alternative approach for the g++ testsuite would be to provide a
> > set of dummy headers for the non-freestanding ones, so that all the
> > hosted-only headers are provided by the testsuite itself, but consist
> > of a single line:
>
> > #error not available in freestanding
>
> > Then match on that and XFAIL. So the individual tests themselves
> > wouldn't need the dg-skip-if added to them, they would just
> > automatically XFAIL if they use a hosted-only header.
>
> *nod*.  That wouldn't cover all the circumstances, alas: there are tests
> that fail in freestanding mode not because of headers, but because
> -fcontracts (currently?) links libstdc++exp in, and that library is not
> even built in freestanding mode.

Hmm, yes, that seems like a bug. Either we should provide
libstdc++exp.a for freestanding builds (with a simplified contract
violation handler that doesn't print to stdout), or the front end
should not add -lstdc++exp when -ffreestanding is used (which would
require teh user, or the testsuite in your case, to provide a custom
contract violation handler), or it should be an error to use
-fcontracts and -ffreestanding together.

The libstdc++-v3/src/experimental/contract.cc file *already* supports
freestanding, we just don't actually build it for freestanding. We can
do that.



Re: testsuite: introduce hostedlib effective target

2023-11-08 Thread Alexandre Oliva
On Nov  7, 2023, Jonathan Wakely  wrote:

> An alternative approach for the g++ testsuite would be to provide a
> set of dummy headers for the non-freestanding ones, so that all the
> hosted-only headers are provided by the testsuite itself, but consist
> of a single line:

> #error not available in freestanding

> Then match on that and XFAIL. So the individual tests themselves
> wouldn't need the dg-skip-if added to them, they would just
> automatically XFAIL if they use a hosted-only header.

*nod*.  That wouldn't cover all the circumstances, alas: there are tests
that fail in freestanding mode not because of headers, but because
-fcontracts (currently?) links libstdc++exp in, and that library is not
even built in freestanding mode.

> The difficulty would be where to add those dummy headers for
> ,  etc. so that they're only found when testing a
> non-hosted build. Maybe libstdc++ could provide them in the build dir
> for the purposes of the testsuite, but not install them?

We run install-tree testing, so that wouldn't quite work for us.  If the
headers are in some subdirectory in the source tree, that we (or the
testsuite machinery) would just add to the -I set, that would help.

-- 
Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/
   Free Software Activist   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive


Re: testsuite: introduce hostedlib effective target

2023-11-07 Thread Jonathan Wakely
On Tue, 7 Nov 2023 at 10:24, Jonathan Wakely  wrote:
>
> On Tue, 7 Nov 2023 at 10:18, Jonathan Wakely  wrote:
> >
> > On Tue, 7 Nov 2023 at 10:04, Alexandre Oliva  wrote:
> > >
> > > [adding libstdc++@]
> > >
> > > On Nov  5, 2023, Mike Stump  wrote:
> > >
> > > > Ick.
> > >
> > > Indeed ;-)
> > >
> > > > I wish there were fewer changed lines and not 1 per test
> > > > case. It feels like we've painted ourselves into a corner.
> > >
> > > The libstdc++ testsuite took a different approach, detecting missing
> > > headers (and libraries?) at error pruning time, and xfailing the tests,
> > > which seems to be more in line with what you are looking for.
> > >
> > > That approach, though more expedient, seems more fragile to me, in that
> > > an actual bug that caused headers to go missing would cause tests to be
> > > silently skipped rather than fail.
> >
> > I don't think we XFAIL based on missing headers. We XFAIL based on a
> > specific #error message in certain headers.
> >
> > If a header goes missing, we'll still XFAIL.
> >
> > >
> > > I expect the set of headers, and thus of affected tests, won't by very
> > > dynamic, so it's kind of a one-shot change.
> > >
> > > Of course new tests might be added that rely on such headers, and would
> > > likely go unnoticed until someone tries them on a non-hosted libstdc++.
> >
> > Since GCC 13 you don't need to build a non-hosted libstdc++ to test
> > it, you can just add -ffreestanding to the runtestflags.
> >
> > > We could alleviate this if libstdc++ headers that are not installed on
> > > hosted systems issued a warning (conditional on some macro defined by
> > > the testsuite, say -D_GLIBCXX_WARN_HOSTED_ONLY).
> >
> > That's exactly what happens (except #error not #warning) when you
> > compile with -ffreestanding.
> >
> > >  For tests aimed
> > > exclusively at hosted libstdc++, we'd then use a dg directive that both
> > > implied this requirement, and changed the macro definition to suppress
> > > the warning.  Then anyone who added a testcase that included hosted
> > > headers without indicating its hostedlib requirement would get a fail
> > > even when testing with a hosted libstdc++.
> >
> > I don't think we need to add checks for a new macro and then use that
> > when testing, you can just test with -ffreestanding instead. This
> > already works today.
>
> Ah, reading back in the thread for  the context I missed, I see that
> you're specifically testing a --disable-hosted-libstdcxx build. In
> that case some headers really will be absent, not just
> present-with-#error. But I am still not concerned about failing to
> notice if a header goes unintentionally missing, because the libstdc++
> testsuite will still notice that.
>
> We don't prune based on "no such header" errors, so would still get
> FAILs for those tests that depend on headers which are supposed to be
> present for freestanding.

An alternative approach for the g++ testsuite would be to provide a
set of dummy headers for the non-freestanding ones, so that all the
hosted-only headers are provided by the testsuite itself, but consist
of a single line:

#error not available in freestanding

Then match on that and XFAIL. So the individual tests themselves
wouldn't need the dg-skip-if added to them, they would just
automatically XFAIL if they use a hosted-only header.

The difficulty would be where to add those dummy headers for
,  etc. so that they're only found when testing a
non-hosted build. Maybe libstdc++ could provide them in the build dir
for the purposes of the testsuite, but not install them?



Re: testsuite: introduce hostedlib effective target

2023-11-07 Thread Jonathan Wakely
On Tue, 7 Nov 2023 at 10:18, Jonathan Wakely  wrote:
>
> On Tue, 7 Nov 2023 at 10:04, Alexandre Oliva  wrote:
> >
> > [adding libstdc++@]
> >
> > On Nov  5, 2023, Mike Stump  wrote:
> >
> > > Ick.
> >
> > Indeed ;-)
> >
> > > I wish there were fewer changed lines and not 1 per test
> > > case. It feels like we've painted ourselves into a corner.
> >
> > The libstdc++ testsuite took a different approach, detecting missing
> > headers (and libraries?) at error pruning time, and xfailing the tests,
> > which seems to be more in line with what you are looking for.
> >
> > That approach, though more expedient, seems more fragile to me, in that
> > an actual bug that caused headers to go missing would cause tests to be
> > silently skipped rather than fail.
>
> I don't think we XFAIL based on missing headers. We XFAIL based on a
> specific #error message in certain headers.
>
> If a header goes missing, we'll still XFAIL.
>
> >
> > I expect the set of headers, and thus of affected tests, won't by very
> > dynamic, so it's kind of a one-shot change.
> >
> > Of course new tests might be added that rely on such headers, and would
> > likely go unnoticed until someone tries them on a non-hosted libstdc++.
>
> Since GCC 13 you don't need to build a non-hosted libstdc++ to test
> it, you can just add -ffreestanding to the runtestflags.
>
> > We could alleviate this if libstdc++ headers that are not installed on
> > hosted systems issued a warning (conditional on some macro defined by
> > the testsuite, say -D_GLIBCXX_WARN_HOSTED_ONLY).
>
> That's exactly what happens (except #error not #warning) when you
> compile with -ffreestanding.
>
> >  For tests aimed
> > exclusively at hosted libstdc++, we'd then use a dg directive that both
> > implied this requirement, and changed the macro definition to suppress
> > the warning.  Then anyone who added a testcase that included hosted
> > headers without indicating its hostedlib requirement would get a fail
> > even when testing with a hosted libstdc++.
>
> I don't think we need to add checks for a new macro and then use that
> when testing, you can just test with -ffreestanding instead. This
> already works today.

Ah, reading back in the thread for  the context I missed, I see that
you're specifically testing a --disable-hosted-libstdcxx build. In
that case some headers really will be absent, not just
present-with-#error. But I am still not concerned about failing to
notice if a header goes unintentionally missing, because the libstdc++
testsuite will still notice that.

We don't prune based on "no such header" errors, so would still get
FAILs for those tests that depend on headers which are supposed to be
present for freestanding.



Re: testsuite: introduce hostedlib effective target

2023-11-07 Thread Jonathan Wakely
On Tue, 7 Nov 2023 at 10:04, Alexandre Oliva  wrote:
>
> [adding libstdc++@]
>
> On Nov  5, 2023, Mike Stump  wrote:
>
> > Ick.
>
> Indeed ;-)
>
> > I wish there were fewer changed lines and not 1 per test
> > case. It feels like we've painted ourselves into a corner.
>
> The libstdc++ testsuite took a different approach, detecting missing
> headers (and libraries?) at error pruning time, and xfailing the tests,
> which seems to be more in line with what you are looking for.
>
> That approach, though more expedient, seems more fragile to me, in that
> an actual bug that caused headers to go missing would cause tests to be
> silently skipped rather than fail.

I don't think we XFAIL based on missing headers. We XFAIL based on a
specific #error message in certain headers.

If a header goes missing, we'll still XFAIL.

>
> I expect the set of headers, and thus of affected tests, won't by very
> dynamic, so it's kind of a one-shot change.
>
> Of course new tests might be added that rely on such headers, and would
> likely go unnoticed until someone tries them on a non-hosted libstdc++.

Since GCC 13 you don't need to build a non-hosted libstdc++ to test
it, you can just add -ffreestanding to the runtestflags.

> We could alleviate this if libstdc++ headers that are not installed on
> hosted systems issued a warning (conditional on some macro defined by
> the testsuite, say -D_GLIBCXX_WARN_HOSTED_ONLY).

That's exactly what happens (except #error not #warning) when you
compile with -ffreestanding.

>  For tests aimed
> exclusively at hosted libstdc++, we'd then use a dg directive that both
> implied this requirement, and changed the macro definition to suppress
> the warning.  Then anyone who added a testcase that included hosted
> headers without indicating its hostedlib requirement would get a fail
> even when testing with a hosted libstdc++.

I don't think we need to add checks for a new macro and then use that
when testing, you can just test with -ffreestanding instead. This
already works today.



Re: testsuite: introduce hostedlib effective target

2023-11-07 Thread Alexandre Oliva
[adding libstdc++@]

On Nov  5, 2023, Mike Stump  wrote:

> Ick.

Indeed ;-)

> I wish there were fewer changed lines and not 1 per test
> case. It feels like we've painted ourselves into a corner.

The libstdc++ testsuite took a different approach, detecting missing
headers (and libraries?) at error pruning time, and xfailing the tests,
which seems to be more in line with what you are looking for.

That approach, though more expedient, seems more fragile to me, in that
an actual bug that caused headers to go missing would cause tests to be
silently skipped rather than fail.

I expect the set of headers, and thus of affected tests, won't by very
dynamic, so it's kind of a one-shot change.

Of course new tests might be added that rely on such headers, and would
likely go unnoticed until someone tries them on a non-hosted libstdc++.
We could alleviate this if libstdc++ headers that are not installed on
hosted systems issued a warning (conditional on some macro defined by
the testsuite, say -D_GLIBCXX_WARN_HOSTED_ONLY).  For tests aimed
exclusively at hosted libstdc++, we'd then use a dg directive that both
implied this requirement, and changed the macro definition to suppress
the warning.  Then anyone who added a testcase that included hosted
headers without indicating its hostedlib requirement would get a fail
even when testing with a hosted libstdc++.

-- 
Alexandre Oliva, happy hackerhttps://FSFLA.org/blogs/lxo/
   Free Software Activist   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive


Re: testsuite: introduce hostedlib effective target

2023-11-05 Thread Mike Stump
On Nov 1, 2023, at 6:11 PM, Alexandre Oliva  wrote:
> 
> Several C++ tests fail with --disable-hosted-libstdcxx, whether
> because stdc++ext gets linked in despite not being built, because
> standard headers are included but that are unavailable in this mode,
> or because headers are (mistakenly?) expected to introduce
> declarations such as for ::abort, but in this mode they don't.
> 
> This patch introduces an effective target for GCC test, equivalent to
> one that's available in the libstdc++-v3 testsuite, and arranges for
> all such tests to be skipped when libstdc++-v3 is not hosted.
> 
> This patch was tested with arm-eabi, with libstdc++-v3 configured with
> --disable-hosted-libstdcxx, on gcc-13, and with x86_64-linux-gnu
> likewise on trunk.  In the latter, there are a number of additional
> fails that appear to be related, and that I'm yet to investigate, but
> this is big enough already, so I figured I'd post this and see whether
> the approach is regarded as sound and acceptable before proceeding any
> further.  WDYT?  Ok to install, to deal with other targets
> incrementally?

Ick.  I wish there were fewer changed lines and not 1 per test case. It feels 
like we've painted ourselves into a corner.

That said, I'd rather have a nice solid game plan that is better and suggest it 
over this approach but, the best I can think of it something that can notice 
after the fact during an error, and during error processing, trim or expect, 
which is awfully vague.

So, instead of commenting more, I'd ask if anyone has a nice, good concrete 
idea and say I want to withdraw from the vague.

If someone comes up with something you think is better, easy, smaller and or 
other goodness and you want to go that direction, I'd encourage that, 
otherwise, I'll approve this version.