Thanks for the clarification!

Just to briefly mention, I'm Bourbon who sent the patch based on the earlier 
suggestion, not Charlie who originally filed the bug report, but I completely 
understand the rationale — installing a header that ends up essentially empty 
in freestanding isn't the right way to go.

Regarding making <bits/indirect.h> actually work in freestanding: if no one is 
currently tackling this, I would be very interested in taking a look and 
working on it. 

Before diving into the code, are there any known major roadblocks (e.g. 
allocator/exception dependencies or WG21 freestanding wording details) that I 
should pay particular attention to, or would you recommend simply starting with 
stripping out hosted-only headers/features under #if _GLIBCXX_HOSTED?

Thanks again for your time and guidance!


________________________________________
From: Jonathan Wakely <[email protected]>
Sent: Monday, October 19, 2026 2:08 PM
To: Bourbon Yang
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] libstdc++: Install <bits/indirect.h> for freestanding 
builds [PR127476]

On Mon, 19 Oct 2026 at 11:59, Jonathan Wakely <[email protected]> wrote:
>
> On Sat, 17 Oct 2026 at 17:20, Bourbon Yang <[email protected]> wrote:
> >
> > Hi,
> >
> > In freestanding mode, <memory> includes <bits/indirect.h> under C++26,
> > but the header was previously categorized under hosted bits_headers,
> > causing compilation failures due to missing header in freestanding
> > installations (PR libstdc++/127476).
> >
> > This patch moves <bits/indirect.h> to the bits_freestanding list in
> > libstdc++-v3/include/Makefile.am and regenerates Makefile.in.
> >
> > Tested on x86_64-linux, verified that bits/indirect.h is now correctly
> > generated into the freestanding include tree, and all tests under
> > 20_util/memory/* pass.
> >
> > Please let me know if any adjustment is needed.
>
> The patch looks good, thanks. I'll take care of pushing it.


Actually this doesn't make std::indirect available for freestanding,
it only makes the header available. But including it is always empty.
If we're not actually making the header contents work in freestanding,
it should not be installed.

So the right fix is your original suggestion in bugzilla:

--- a/libstdc++-v3/include/std/memory
+++ b/libstdc++-v3/include/std/memory
@@ -97,7 +97,7 @@
#  include <bits/out_ptr.h>
#endif

-#if __cplusplus > 202302L
+#if __cplusplus > 202302L && _GLIBCXX_HOSTED
#  include <bits/indirect.h>
#endif


What I meant is that we should make the header contents work for
freestanding, but that takes more work. We can do that in future, but
for now I'll just push the change above.

Reply via email to