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’.
  

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))