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

Message ID 878qo7ni3v.fsf@gnu.org
State New
Headers
Series bug#75620: [PATCH core-packages-team] gnu: gcc-6: Use libstdc++ headers appropriate for each GCC. |

Commit Message

Ludovic Courtès April 11, 2025, 9:49 a.m. UTC
Hi Leo,

Leo Nikkilä <hello@lnikki.la> 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’.
  

Comments

Greg Hogan April 15, 2025, 1:39 p.m. UTC | #1
On Fri, Apr 11, 2025 at 5:50 AM Ludovic Courtès <ludo@gnu.org> wrote:
>
> Hi Leo,
>
> Leo Nikkilä <hello@lnikki.la> 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
  

Patch

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index 0eec6452f6..5273aa2ce3 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -52,6 +52,7 @@  (define-module (gnu packages gcc)
   #:use-module (gnu packages perl)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix memoization)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (guix gexp)
@@ -1081,27 +1082,28 @@  (define-public (make-libstdc++ gcc)
     (propagated-inputs '())
     (synopsis "GNU C++ standard library")))
 
-(define (make-libstdc++-headers gcc)
-  ;; XXX: This package is for internal use to work around
-  ;; <https://bugs.gnu.org/42392> (see above).  The main difference compared
-  ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>
-  ;; is right under include/c++ and not under
-  ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).
-  (let ((libstdc++ (make-libstdc++ gcc)))
-    (package
-      (inherit libstdc++)
-      (name "libstdc++-headers")
-      (outputs '("out"))
-      (build-system trivial-build-system)
-      (arguments
-       '(#:builder (let* ((out       (assoc-ref %outputs "out"))
-                          (libstdc++ (assoc-ref %build-inputs "libstdc++")))
-                     (mkdir out)
-                     (mkdir (string-append out "/include"))
-                     (symlink (string-append libstdc++ "/include")
-                              (string-append out "/include/c++")))))
-      (inputs `(("libstdc++" ,libstdc++)))
-      (synopsis "Headers of GNU libstdc++"))))
+(define make-libstdc++-headers
+  (mlambdaq (gcc)      ;memoize to play well with the object cache
+    ;; XXX: This package is for internal use to work around
+    ;; <https://bugs.gnu.org/42392> (see above).  The main difference compared
+    ;; to the libstdc++ headers that come with 'gcc' is that <bits/c++config.h>
+    ;; is right under include/c++ and not under
+    ;; include/c++/x86_64-unknown-linux-gnu (aka. GPLUSPLUS_TOOL_INCLUDE_DIR).
+    (let ((libstdc++ (make-libstdc++ gcc)))
+      (package
+        (inherit libstdc++)
+        (name "libstdc++-headers")
+        (outputs '("out"))
+        (build-system trivial-build-system)
+        (arguments
+         '(#:builder (let* ((out       (assoc-ref %outputs "out"))
+                            (libstdc++ (assoc-ref %build-inputs "libstdc++")))
+                       (mkdir out)
+                       (mkdir (string-append out "/include"))
+                       (symlink (string-append libstdc++ "/include")
+                                (string-append out "/include/c++")))))
+        (inputs `(("libstdc++" ,libstdc++)))
+        (synopsis "Headers of GNU libstdc++")))))
 
 (define-public libstdc++-4.9
   (make-libstdc++ gcc-4.9))