[PATCH] libstdc++: Install <bits/indirect.h> for freestanding builds [PR127476]

Jonathan Wakely jwakely@redhat.com
Mon Oct 19 21:08:39 GMT 2026


On Mon, 19 Oct 2026 at 11:59, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Sat, 17 Oct 2026 at 17:20, Bourbon Yang <bin.macchiato@gmail.com> 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.



More information about the Libstdc++ mailing list