From 63b9c42462e7a55f7ae23e7f0d12d3cf57ac628d Mon Sep 17 00:00:00 2001 From: Jonas Meeuws Date: Tue, 4 Aug 2026 15:12:04 +0200 Subject: =?UTF-8?q?gnu:=20ldc:=20Add=20=E2=80=98rewrite-references-to-boot?= =?UTF-8?q?strap=E2=80=99=20phase.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages/dlang.scm (ldc)[#:phases]: Add ‘rewrite-references-to-bootstrap’. Signed-off-by: Liliana Marie Prikler --- gnu/packages/dlang.scm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/gnu/packages/dlang.scm b/gnu/packages/dlang.scm index d6362cc0321..4669b5bd616 100644 --- a/gnu/packages/dlang.scm +++ b/gnu/packages/dlang.scm @@ -68,6 +68,10 @@ (define-public ldc-bootstrap (package + ;; This package is purposefully named just "ldc" and not "ldc-bootstrap", + ;; as the final ldc package rewrites references from this one to itself, + ;; and their names must have the same length to avoid corrupting the + ;; binary. (name "ldc") (version "1.42.0") (source (origin @@ -439,7 +443,24 @@ This compiler is based on the DMD frontend version 2.112.1.") "-DBUILD_SHARED_LIBS=OFF")) '("-DBUILD_SHARED_LIBS=ON"))) ((#:build-type _ ''()) - "RelWithDebInfo"))) + "RelWithDebInfo") + ((#:phases phases #~%standard-phases) + #~(modify-phases #$phases + (add-after 'create-lib-output 'rewrite-references-to-bootstrap + ;; D compilers can keep references to the include files used to + ;; build a binary in exception messages. For ldc, rewrite the + ;; references to ldc-bootstrap to itself, to reduce its closure + ;; size. + (lambda* (#:key outputs #:allow-other-keys) + (let* ((in-ldc-bootstrap #$(this-package-native-input "ldc")) + (out (assoc-ref outputs "out")) + (out/bin (string-append out "/bin"))) + ;; XXX: Use sed, as replace-store-references wouldn't + ;; replace the references, while substitute* throws an + ;; error. + (apply invoke "sed" "-i" + (format #f "s,~a,~a,g" in-ldc-bootstrap out) + (find-files out/bin))))))))) (native-inputs (modify-inputs (package-native-inputs base) (delete "gdmd") -- cgit v1.2.3