Subject: bug#75157: Grafting inconsistency with multiple outputs is causing problems

From: Dariqq <[email-masked]>
Date: Sat, 28 Dec 2024 08:52:44 +0000

Hello,

Yesterday I was playing around with g-golf and libguile and encountered 
some weird glib issues once I linked my c program to glib/gobject.

After asking about this in #guile the problem was discovered to be 2 
different glibs being in use and the workaround is use them with 
'--no-grafts' instead.

I looked into why grafting is causing this problem and here is what I 
have found:

The following happend on guix commit 
e16cdcf37d8223b3634ec5e658356c3b7f154859

Before grafting:
/gnu/store/digl75knygzqg9lrh8adk3pz0qg9cx8h-guile-g-golf-0.8.0-a.1:
Has a reference to: /gnu/store/zgsphhmliwgmjjv1czmbyjql3gk7ynsx-glib-2.78.0
which is the out output of the hidden (@@ (gnu packages glib) glib) package

After applying grafts:
/gnu/store/2ar2h8d7nk3g7c9965y4n68gjr778prk-guile-g-golf-0.8.0-a.1:
Has reference to /gnu/store/0466q5rlccclzg70f3yprpf9kdvlyfzf-glib-2.78.0

But the hidden glib grafts to
/gnu/store/ls9p0k2chrzviadibzf0iz7rlpkmggms-glib-2.78.0
instead (which is the one I am linking to)

Looking at the grafting derivations the issue seems to be that in one 
case all outputs of glib are grafted and in the other case only the out 
output which leads to the different results.

8<---------------cut here---------------start------------->8---
/gnu/store/ikv0s6dr3yzs398i67vh3p0w8jglxm4w-glib-2.78.0.drv
Derive
([("out","/gnu/store/0466q5rlccclzg70f3yprpf9kdvlyfzf-glib-2.78.0","","")]
  ,[("/gnu/store/0s4qbdir1j1c6yfnhvj3w4kpplsaafik-pcre2-10.42.drv",["out"])
    ,("/gnu/store/1554x8kqj7xjw5an8rzrnfz3v40spiy7-glibc-2.39.drv",["out"])
    ,("/gnu/store/2c70wagxjjxk8lcj3znrqqlvn2dcj024-glibc-2.39.drv",["out"])
    ,("/gnu/store/523ngwgnmyhszf9mqbk537ka41jbzs00-guile-3.0.9.drv",["out"])
    ,("/gnu/store/7lwb609ira5a3rs9ncxk55azvsnwi6vv-glib-2.78.0.drv",["out"])
    ,("/gnu/store/gmp1ciyg5yna6983phnf22pwsivfanwq-zlib-1.3.drv",["out"])
    ,("/gnu/store/gxn87vb8lb1l3yzmnzidmxbn3nk9x3bf-gcc-11.4.0.drv",["lib"])
  
,("/gnu/store/h268dh05da4jfrl94xq5jkvyic7k2h57-libffi-3.4.4.drv",["out"])
    ,("/gnu/store/h50bkx0qkqj7x0f1sbkgkiszkbdq32qg-zlib-1.3.drv",["out"])
  
,("/gnu/store/hkz1acxfcxil4252qw7i25gcn0f852dw-libffi-3.4.4.drv",["out"])
    ,("/gnu/store/jyki6954ps4gnhpznacfws146svldkpf-gcc-11.4.0.drv",["lib"])
  
,("/gnu/store/vhi205g193z01plb6pbhm75b186zrhis-util-linux-2.37.4.drv",["lib"])
  
,("/gnu/store/w5pgbafd9apavpnczcgblbgmwwp0a8y0-util-linux-2.37.4.drv",["lib"])
    ,("/gnu/store/yni45i1ca3ymb8rna09qh038v102zyjj-pcre2-10.42.drv",["out"])
  
,("/gnu/store/zp7byldvi2imbliv154vv87iai65jwxy-module-import-compiled.drv",["out"])]
  ,["/gnu/store/2mml5mrmhmn1424pymllzk18m2z3l44q-glib-2.78.0-builder","/gnu/store/flaxnn4ciba6wd243ahwgrqw11082imp-module-import"]
  ,"x86_64-linux","/gnu/store/xv4cd7qz4yan93zkjisbmbpxfz78hah2-guile-3.0.9/bin/guile",["--no-auto-compile","-L","/gnu/store/flaxnn4ciba6wd243ahwgrqw11082imp-module-import","-C","/gnu/store/5wdfvn4mklppcg5p9i1d14ksbnsd7m8b-module-import-compiled","/gnu/store/2mml5mrmhmn1424pymllzk18m2z3l44q-glib-2.78.0-builder"]
  ,[("allowSubstitutes","0")
    ,("guix properties","((type . graft) (graft (count . 6)))")
    ,("out","/gnu/store/0466q5rlccclzg70f3yprpf9kdvlyfzf-glib-2.78.0")
    ,("preferLocalBuild","1")])
--8<---------------cut here---------------end--------------->8---

The "correctly"  grafted glib derivation looks like this:
/gnu/store/xax79x40lzs4wf2v4ipbxvy2gkc9qq7p-glib-2.78.0.drv
8<---------------cut here---------------start------------->8---
gnu/store/xax79x40lzs4wf2v4ipbxvy2gkc9qq7p-glib-2.78.0.drv
Derive
([("bin","/gnu/store/q3d08x70gcjj99k5dd0jbfc8rj97j9lz-glib-2.78.0-bin","","")
  
,("debug","/gnu/store/pn2mdlc86i7x6vrg2j6pslp5sq551255-glib-2.78.0-debug","","")
   ,("out","/gnu/store/ls9p0k2chrzviadibzf0iz7rlpkmggms-glib-2.78.0","","")
  
,("static","/gnu/store/n5s2s4rg3jax3y7kp93bgn2w6s7vlfrz-glib-2.78.0-static","","")]
  ,[("/gnu/store/0s4qbdir1j1c6yfnhvj3w4kpplsaafik-pcre2-10.42.drv",["out"])
    ,("/gnu/store/1554x8kqj7xjw5an8rzrnfz3v40spiy7-glibc-2.39.drv",["out"])
    ,("/gnu/store/2c70wagxjjxk8lcj3znrqqlvn2dcj024-glibc-2.39.drv",["out"])
    ,("/gnu/store/523ngwgnmyhszf9mqbk537ka41jbzs00-guile-3.0.9.drv",["out"])
  
,("/gnu/store/7lwb609ira5a3rs9ncxk55azvsnwi6vv-glib-2.78.0.drv",["bin","debug","out","static"])
    ,("/gnu/store/gmp1ciyg5yna6983phnf22pwsivfanwq-zlib-1.3.drv",["out"])
    ,("/gnu/store/gxn87vb8lb1l3yzmnzidmxbn3nk9x3bf-gcc-11.4.0.drv",["lib"])
  
,("/gnu/store/h268dh05da4jfrl94xq5jkvyic7k2h57-libffi-3.4.4.drv",["out"])
    ,("/gnu/store/h50bkx0qkqj7x0f1sbkgkiszkbdq32qg-zlib-1.3.drv",["out"])
  
,("/gnu/store/hkz1acxfcxil4252qw7i25gcn0f852dw-libffi-3.4.4.drv",["out"])
    ,("/gnu/store/jyki6954ps4gnhpznacfws146svldkpf-gcc-11.4.0.drv",["lib"])
  
,("/gnu/store/piymwc0w49ylyz69ikq6vnj32xhl96h6-bash-minimal-5.1.16.drv",["out"])
  
,("/gnu/store/vhi205g193z01plb6pbhm75b186zrhis-util-linux-2.37.4.drv",["lib"])
  
,("/gnu/store/w5pgbafd9apavpnczcgblbgmwwp0a8y0-util-linux-2.37.4.drv",["lib"])
  
,("/gnu/store/wqa52jpxmv1xiibdxvfls7dnphq83jb5-bash-minimal-5.1.16.drv",["out"])
  
,("/gnu/store/yhxc842f6arm91w4vhdmgazw2nvkn7g7-python-3.10.7.drv",["out"])
  
,("/gnu/store/yig8rg8bjy599m49kia7nph8393x5j2g-python-3.10.7.drv",["out"])
    ,("/gnu/store/yni45i1ca3ymb8rna09qh038v102zyjj-pcre2-10.42.drv",["out"])
  
,("/gnu/store/zp7byldvi2imbliv154vv87iai65jwxy-module-import-compiled.drv",["out"])]
  ,["/gnu/store/65ym8q6k1adkz4d4xalrsdq409r8k8r8-glib-2.78.0-builder","/gnu/store/flaxnn4ciba6wd243ahwgrqw11082imp-module-import"]
  ,"x86_64-linux","/gnu/store/xv4cd7qz4yan93zkjisbmbpxfz78hah2-guile-3.0.9/bin/guile",["--no-auto-compile","-L","/gnu/store/flaxnn4ciba6wd243ahwgrqw11082imp-module-import","-C","/gnu/store/5wdfvn4mklppcg5p9i1d14ksbnsd7m8b-module-import-compiled","/gnu/store/65ym8q6k1adkz4d4xalrsdq409r8k8r8-glib-2.78.0-builder"]
  ,[("allowSubstitutes","0")
    ,("bin","/gnu/store/q3d08x70gcjj99k5dd0jbfc8rj97j9lz-glib-2.78.0-bin")
  
,("debug","/gnu/store/pn2mdlc86i7x6vrg2j6pslp5sq551255-glib-2.78.0-debug")
    ,("guix properties","((type . graft) (graft (count . 8)))")
    ,("out","/gnu/store/ls9p0k2chrzviadibzf0iz7rlpkmggms-glib-2.78.0")
    ,("preferLocalBuild","1")
  
,("static","/gnu/store/n5s2s4rg3jax3y7kp93bgn2w6s7vlfrz-glib-2.78.0-static")])
--8<---------------cut here---------------end--------------->8---

I think it would be good if grafts are only applied per output (which 
might also help resolve #69653).