<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Aug 18, 2026 at 10:46 AM Jonathan Wakely <<a href="mailto:jwakely@redhat.com">jwakely@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 18 Aug 2026 at 09:20, Tomasz Kaminski <<a href="mailto:tkaminsk@redhat.com" target="_blank">tkaminsk@redhat.com</a>> wrote:<br>
><br>
><br>
><br>
> On Mon, Aug 17, 2026 at 10:27 PM Jonathan Wakely <<a href="mailto:jwakely@redhat.com" target="_blank">jwakely@redhat.com</a>> wrote:<br>
>><br>
>> As described in the bug report, when compilation of std.cc or<br>
>> <a href="http://std.compat.cc" rel="noreferrer" target="_blank">std.compat.cc</a> fails we overwrite the source file with an empty file, and<br>
>> then compile that (so that bootstrap doesn't fail). Then when the module<br>
>> definition files are installed, we install the empty file.<br>
>><br>
>> We should install the original source, not an empty file. We can create<br>
>> an empty file and compile it, but leave the original source untouched so<br>
>> that it can still be installed.<br>
>><br>
>> libstdc++-v3/ChangeLog:<br>
>><br>
>> PR libstdc++/126786<br>
>> * src/c++23/Makefile.am (std.lo, std.compat.lo): Do not<br>
>> overwrite original sources in error-recovery steps.<br>
>> * src/c++23/Makefile.in: Regenerate.<br>
>> ---<br>
>><br>
>> Tested x86_64-linux.<br>
>><br>
>> Also checked by injecting errors into <a href="http://std.cc.in" rel="noreferrer" target="_blank">std.cc.in</a> and <a href="http://std.compat.cc.in" rel="noreferrer" target="_blank">std.compat.cc.in</a> to<br>
>> ensure that the build completes as expected.<br>
>><br>
>> libstdc++-v3/src/c++23/Makefile.am | 12 ++++--------<br>
>> libstdc++-v3/src/c++23/Makefile.in | 12 ++++--------<br>
>> 2 files changed, 8 insertions(+), 16 deletions(-)<br>
>><br>
>> diff --git a/libstdc++-v3/src/c++23/Makefile.am b/libstdc++-v3/src/c++23/Makefile.am<br>
>> index 92691c502a94..87c0108b52d0 100644<br>
>> --- a/libstdc++-v3/src/c++23/Makefile.am<br>
>> +++ b/libstdc++-v3/src/c++23/Makefile.am<br>
>> @@ -104,29 +104,25 @@ std.lo: std.cc<br>
>> if ! $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(LTCXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
><br>
> Any reason for switching the name of the helper file from std.cc.tmp to xstd.cc?<br>
<br>
That's not what the patch does.<br>
<br>
The code that's on trunk now writes to a new file called std.cc.tmp<br>
but then moves that to std.cc<br>
That means the file has the correct .cc extension, so will be treated<br>
as C++ source by g++. If it was called std.cc.tmp it would assume it's<br>
a library or object file to be passed to the linker:<br>
<br>
$ g++ std.cc.tmp -c<br>
g++: warning: std.cc.tmp: linker input file unused because linking not done<br></blockquote><div>We could pass -x c++ to override the extension-based selector, but I think it is</div><div>better to use the same compilation flags. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
So I'm switching the name of the helper file from std.cc to xstd.cc<br>
and <a href="http://std.compat.cc" rel="noreferrer" target="_blank">std.compat.cc</a> to <a href="http://xstd.compat.cc" rel="noreferrer" target="_blank">xstd.compat.cc</a>, which avoids overwriting the<br>
original std.cc and <a href="http://std.compat.cc" rel="noreferrer" target="_blank">std.compat.cc</a> files, which is the point of the<br>
patch.<br>
<br>
> I think the later is more likely to conflict with something, so would preffer to use $<.tmp<br>
> here. Or is this common practice for these makefiles?<br>
<br>
Using a .tmp extension won't work.<br>
<br>
It could be tmp-std.cc or empty-std.cc or something like that, but<br>
whatever change we make needs to be a prefix not a suffix.<br></blockquote><div>"empty-" prefix sounds better to me. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
>><br>
>> fi<br>
>> std.o: std.cc<br>
>> if ! $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(CXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
>> fi<br>
>> std.compat.lo: <a href="http://std.compat.cc" rel="noreferrer" target="_blank">std.compat.cc</a> std.lo<br>
>> if ! $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std.compat module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(LTCXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
>> fi<br>
>> std.compat.o: <a href="http://std.compat.cc" rel="noreferrer" target="_blank">std.compat.cc</a> std.o<br>
>> if ! $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std.compat module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(CXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
>> fi<br>
>><br>
>> # AM_CXXFLAGS needs to be in each subdirectory so that it can be<br>
>> diff --git a/libstdc++-v3/src/c++23/Makefile.in b/libstdc++-v3/src/c++23/Makefile.in<br>
>> index 0ce93f812d25..63e5cb4e2a1c 100644<br>
>> --- a/libstdc++-v3/src/c++23/Makefile.in<br>
>> +++ b/libstdc++-v3/src/c++23/Makefile.in<br>
>> @@ -888,29 +888,25 @@ std.lo: std.cc<br>
>> if ! $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(LTCXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
>> fi<br>
>> std.o: std.cc<br>
>> if ! $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(CXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
>> fi<br>
>> std.compat.lo: <a href="http://std.compat.cc" rel="noreferrer" target="_blank">std.compat.cc</a> std.lo<br>
>> if ! $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std.compat module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(LTCXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(LTCXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
>> fi<br>
>> std.compat.o: <a href="http://std.compat.cc" rel="noreferrer" target="_blank">std.compat.cc</a> std.o<br>
>> if ! $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; then \<br>
>> echo "Cannot compile std.compat module" >&2; \<br>
>> echo "Module initialization function will be missing" >&2; \<br>
>> - echo > $<.tmp && mv $<.tmp $< && \<br>
>> - $(CXXCOMPILE) $(MODULES_FLAGS) -c $< ; \<br>
>> + echo > x$< && $(CXXCOMPILE) $(MODULES_FLAGS) -c x$< -o $@; \<br>
>> fi<br>
>><br>
>> # Tell versions [3.59,3.63) of GNU make to not export all variables.<br>
>> --<br>
>> 2.55.0<br>
>><br>
<br>
</blockquote></div></div>