Subject: bug#75510: Building grub-image.png.drv fails with rsvg

From: Efraim Flashner <[email-masked]>
Date: Fri, 24 Jan 2025 10:41:32 +0200

On Wed, Jan 22, 2025 at 12:52:25AM +0100, vicvbcun wrote:
> Hi,
> 
> below are my current findings.
> 
> As of commit
>     87045f0982 (gnu: paritwine: Update to 0.2.1., 2025-01-17)
> guile-rsvg depends on a version of guile-cairo different from the one I get
> by simply building guile-cairo:
> 
>     $ ./pre-inst-env guix build guile-cairo
>     ⇒ /gnu/store/k4kglplg98098y78flnw0f9wjyyc9zk2-guile-cairo-1.11.2
> 
> whereas
> 
>     $ guix gc --references "$(./pre-inst-env guix build guile-rsvg)" | grep guile-cairo
>     ⇒ /gnu/store/lz8cv73yzzrbwrhafzadixnwgmspz2cg-guile-cairo-1.11.2
> 
> (gnu build svg) loads both (rsvg) and (cairo) which causes two different
> libguile-cairo.so's to be loaded (interestingly enough the order matters:
> loading (cairo) first would hide the issue):
> --8<---------------cut here---------------start------------->8---
> ./pre-inst-env guix shell --no-cwd -C guile guile-cairo guile-rsvg -- \
>     guile -s /dev/stdin <<EOF | grep libguile-cairo
> 
> (begin
>  (use-modules (ice-9 textual-ports)
>               ;; order matters!
>               (rsvg)
> 	            (cairo))
> 
> (display (call-with-input-file "/proc/self/maps" get-string-all)))
> EOF
> --8<---------------cut here---------------end--------------->8---
> shows two different libguile-cairo.so's.  The only difference between the
> two guile-cairo derivation is that they graft cairo to different
> derivations, which in turn differ only in grafting fontconfig-minimal to
> different versions which finally only graft glibc and expat in different
> order.
> 
> All this confirms the hypothesis Mark expressed in [0].
> 
> My guess is that the change to rust-ring somehow changes how it interacts
> with grafting.  Perhaps it is added / not added to some hashtable, causing
> iteration order to change?
> 
> 0: https://issues.guix.gnu.org/47115#23

I tried setting rust-ring's sources to #:target #f but that didn't make
any difference.  I feel like it shouldn't make a difference, and should
probably be #:target #f anyway, but that can be a different time.

I'm attaching a patch that creates the grub image using ungrafted
inputs.  I think it would make sense to go through and figure out which
derivations actually need to use grafted inputs and which ones don't
matter, but I'm not sure it's worth the maintenance burden to check them
regularly.

The image also seems like something that could be #:target #f and we
could cheat by getting a generated image built on a different
architecture, but that's never seemed to work that way, only for
cross-building.

-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
From 5d617f45c32834fb645975787c4e364fc603e2cb Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Efraim Flashner <[email-masked]>
Date: Fri, 24 Jan 2025 10:36:16 +0200
Subject: [PATCH] bootloader/grub: Create grub background image with ungrafted
 inputs.

This fixes bug https://issues.guix.gnu.org/75510.

* gnu/bootloader/grub.scm (image->png): Create the grub-image using
ungrafted inputs.

Change-Id: Ia23dd081d9711c703b7bf795dc376e024bb5caff
---
 gnu/bootloader/grub.scm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index c2462d5d036..e136482c541 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -140,7 +140,12 @@ (define* (image->png image #:key width height)
                              (svg->png #+image #$output
                                        #:width #$width
                                        #:height #$height))
-                           (copy-file #+image #$output))))))
+                           (copy-file #+image #$output))))
+                 ;; Work around a bug in grafts where different versions of
+                 ;; guile-cairo are loaded from (gnu build svg).
+                 ;; As seen in https://issues.guix.gnu.org/47115#23 and
+                 ;; in https://issues.guix.gnu.org/75510.
+                 #:options '(#:graft? #f)))
 
 (define* (grub-background-image config)
   "Return the GRUB background image defined in CONFIG or #f if none was found.

base-commit: 97fe03d53635de996028562da9e65b697eedf0f5
-- 
Efraim Flashner   <[email-masked]>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted