On Wed, 8 Nov 2023 at 15:30, Alexandre Oliva <ol...@adacore.com> wrote: > > On Nov 7, 2023, Jonathan Wakely <jwak...@redhat.com> 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.