Subject: [bug#75620] [PATCH core-packages-team] gnu: gcc-6: Use libstdc++ headers appropriate for each GCC.

From: Greg Hogan <[email-masked]>
Date: Tue, 15 Apr 2025 09:39:01 -0400

On Fri, Apr 11, 2025 at 5:50 AM Ludovic Courtès <[email-masked]> wrote:
>
> Hi Leo,
>
> Leo Nikkilä <[email-masked]> skribis:
>
> > After the "hack" introduced for <https://issues.guix.gnu.org/42392>, all GCCs
> > are built with the current GCC's libstdc++ headers. This results in subtly
> > broken C++ headers in older versions, which aren't necessarily compatible with
> > libstdc++s from other versions.
>
> [...]
>
> > * gnu/packages/gcc.scm (libstdc++, libstdc++-headers): Remove variables.
> > (make-libstdc++-headers): New procedure.
> > (gcc-6)[native-inputs]: Use it with `this-package'.
> > ---
> >  gnu/packages/gcc.scm | 38 ++++++++++++++++++--------------------
> >  1 file changed, 18 insertions(+), 20 deletions(-)
>
> Somehow this patch fell into the cracks.
>
> I’ve now applied it with the change below (using ‘mlambdaq’ for
> ‘make-libstdc++-headers’); I also shortened the commit log.
>
> Thanks!
>
> Ludo’.

With this patch I now get build errors on gcc older than 14. CI is
returning 504 when viewing evaluations, but I am getting:

libtool: compile:  g++
-I/tmp/guix-build-libstdc++-13.3.0.drv-0/gcc-13.3.0/libstdc++-v3/../libgcc
-I/tmp/guix-build-libstdc++-13.3.0.drv-0/gcc-13.3.0/build/include/
-I/tmp/guix-build-libstdc++-13.3.0.drv-0/gcc-13.3.0/build/include
-I/tmp/guix-build-libstdc++-13.3.0.drv-0/gcc-13.3.0/libstdc++-v3/libsupc++
-D_GLIBCXX_SHARED -fno-implicit-templates -Wall -Wextra
-Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once
-ffunction-sections -fdata-sections -frandom-seed=eh_call.lo
-fcf-protection -mshstk -c ../../libstdc++-v3/libsupc++/eh_call.cc
-fPIC -DPIC -D_GLIBCXX_SHARED -o eh_call.o
../../libstdc++-v3/libsupc++/eh_call.cc:39:1: warning: new declaration
‘void __cxa_call_terminate(_Unwind_Exception*)’ ambiguates built-in
declaration ‘void __cxa_call_terminate(void*)’
[-Wbuiltin-declaration-mismatch]
   39 | __cxa_call_terminate(_Unwind_Exception* ue_header) throw ()
      | ^~~~~~~~~~~~~~~~~~~~
../../libstdc++-v3/libsupc++/eh_call.cc: In function ‘void
__cxa_call_terminate(_Unwind_Exception*)’:
../../libstdc++-v3/libsupc++/eh_call.cc:39:1: internal compiler error:
in gimple_build_eh_must_not_throw, at gimple.cc:730
0x7ffff7ced956 __libc_start_call_main
        ???:0
0x7ffff7ceda14 __libc_start_main_alias_1
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [Makefile:777: eh_call.lo] Error 1
make[2]: Leaving directory
'/tmp/guix-build-libstdc++-13.3.0.drv-0/gcc-13.3.0/build/libsupc++'
make[1]: *** [Makefile:576: all-recursive] Error 1
make[1]: Leaving directory
'/tmp/guix-build-libstdc++-13.3.0.drv-0/gcc-13.3.0/build'
make: *** [Makefile:501: all] Error 2