Subject: bug#76110: Broken i686 package on x86_64 since commit 28e4018e59

From: Denis 'GNUtoo' Carikli <[email-masked]>
Date: Fri, 7 Feb 2025 01:15:41 +0100

Hi,

I run a 32bit version of PostgreSQL that I compile with the package
definition below:
> ;; Copyright (C) 2024 Denis 'GNUtoo' Carikli
> ;; <[email-masked]>
> ;; This file is free software; you can redistribute it and/or modify
> ;; it under the terms of the GNU General Public License as
> ;; published by the Free Software Foundation; either version 3 of the
> ;; License, or (at your option) any later version.
> ;;
> ;; This file is distributed in the hope that it will be useful, but
> ;; WITHOUT ANY WARRANTY; without even the implied warranty of
> ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ;; GNU General Public License for more details.
> ;;
> ;; You should have received a copy of the GNU General Public License
> ;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
> 
> (define-module (postgresql-i686-linux)
>   #:use-module (gnu packages databases)
>   #:use-module (guix packages)
>   #:use-module (guix utils))
> 
> (define-public postgresql-14-i686-linux
>   (package
>    (inherit postgresql-14)
>    (name "postgresql-14-i686-linux")
>    (arguments
>     (ensure-keyword-arguments
>      (package-arguments postgresql-14)
>      '(#:system "i686-linux")))))
> 
> (list postgresql-14-i686-linux)

Here's why it is broken:
> $ guix build -f postgresql-i686-linux.scm
> [...]
> /gnu/store/[...]-postgresql-14-i686-linux-14.13

> $ file /gnu/store/[...]-postgresql-14-i686-linux-14.13/bin/psql
> /gnu/store/[...]-postgresql-14-i686-linux-14.13/bin/psql:
> ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically
> linked, interpreter
> /gnu/store/[...]-glibc-2.39/lib/ld-linux.so.2,

> $ ls -l /gnu/store/[...]-postgresql-14-i686-linux-14.13/bin/psql
> -r-xr-xr-x 2 root root 674532 Jan  1  1970
> /gnu/store/jb8jdcyf8q4whlczhp76kdgpqs007jz9-postgresql-14-i686-linux-14.13/bin/psql

> $ /gnu/store/[...]-postgresql-14-i686-linux-14.13/bin/psql --help
> bash:
> /gnu/store/jb8jdcyf8q4whlczhp76kdgpqs007jz9-postgresql-14-i686-linux-14.13/bin/psql:
> No such file or directory

Before the commit 28e4018e59d30efb3d52aa950ce2261f11b69b33, the same
command printed the help of the psql program.

So I bisected with the script below (ran manually, not with git bisect
run):

> #!/usr/bin/env bash
> $(guix time-machine \
> --commit=$(git show HEAD --no-patch --pretty="%H") -- \
> build -f \
> ~/work/setup/configs/packages/postgresql-i686-linux.scm )/bin/psql
> --help

And the process gave the commit 28e4018e59d30efb3d52aa950ce2261f11b69b33
("grafts: Allow file-like objects in the ‘replacement’ field of
<graft>.").

However I didn't look into how to repair the behavior above as I'm not
familiar at all with the code that the 28e4018e59 patch touches.

Denis.