Subject: bug#63258: [PATCH] gnu: gcc-toolchain: Add empty librt.a.

From: Josselin Poiret <[email-masked]>
Date: Thu, 4 May 2023 21:50:37 +0200

From: Josselin Poiret <[email-masked]>

* gnu/packages/commencememnt.scm (make-gcc-toolchain): Add empty librt.a.
* gnu/packages/base.scm (gcc): Add a warning regarding the missing librt.a.
---
Hi,

This patch should be enough for -lrt to work with gcc-toolchain.  This doesn't
fix the underlying issue for the gcc package though, as it would incur a world
rebuild.

Best,
Josselin

 gnu/packages/base.scm         | 4 ++++
 gnu/packages/commencement.scm | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 6911ea78be..4350fd4041 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -945,6 +945,10 @@ (define-public glibc
                      ;; library is empty by some criterion (such as their file
                      ;; size equaling eight bytes) rather than hardcoding them
                      ;; by name.
+
+                     ;; XXX: We forgot librt.a for the current version!  In
+                     ;; the meantime, gcc-toolchain provides it, but remove
+                     ;; that fix once librt.a is added here.
                      (define empty-static-libraries
                        '("libpthread.a" "libdl.a" "libutil.a" "libanl.a"))
                      (define (empty-static-library? file)
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index 25e96b1aa6..26d5eb3819 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -3452,6 +3452,13 @@ (define* (make-gcc-toolchain gcc
                        (union-build (assoc-ref %outputs "static")
                                     (list (assoc-ref %build-inputs
                                                      "libc-static")))
+                       ;; XXX Remove once an empty librt.a is added to
+                       ;; libc:out.
+                       (copy-file
+                        (string-append (assoc-ref %outputs "out")
+                                       "/lib/libpthread.a")
+                        (string-append (assoc-ref %outputs "out")
+                                       "/lib/librt.a"))
                        #t))))
 
       (native-search-paths

base-commit: f14d3944cc699d1426c31b304fb49b72a579666a
-- 
2.39.2