Subject: Fakechroot execution engine can fail to find libraries
From: Ludovic Courtès <[email-masked]>
To: <[email-masked]>
Date: Fri, 18 Sep 2020 15:28:18 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Using the ‘fakechroot’ execution engine of ‘guix pack -RR’, I found a
case where an executable’s NEEDED library is not found.

--8<---------------cut here---------------start------------->8---
$ guix describe
Generacio 159	Sep 18 2020 08:55:27	(nuna)
  guix 98b89f4
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 98b89f432103b66efacee0bcba41a94148b8e870
$ mkdir /tmp/fakechroot-test
$ (cd /tmp/fakechroot-test; tar xf $(guix pack -RR openmpi -S /bin=bin -v0))
$ unshare -m -U -r -f sh -c 'mount -t tmpfs none /gnu; echo /gnu/*; GUIX_EXECUTION_ENGINE=fakechroot /tmp/fakechroot-test/bin/orterun'
/gnu/*
/tmp/fakechroot-test/gnu/store/rm1d9z3z3iwsv779vqlg7q5z7pdk5k12-openmpi-4.0.5/bin//orterun: error while loading shared libraries: libevent_core-2.1.so.7: cannot open shared object file: No such file or directory
--8<---------------cut here---------------end--------------->8---

That library is in the RUNPATH of the original executable though:

--8<---------------cut here---------------start------------->8---
$ objdump -x $(guix build openmpi)/bin/orterun | grep PATH
objdump: Advertiment: '/gnu/store/3ign6b3i5ambjgqqiyman4mqw0wljlvl-openmpi-4.0.5-debug' és un directori
  RUNPATH              /gnu/store/rm1d9z3z3iwsv779vqlg7q5z7pdk5k12-openmpi-4.0.5/lib:/gnu/store/xk22b03jb0c0b6vkadqbkr9d4556rwxh-hwloc-2.2.0-lib/lib:/gnu/store/i1smdd4r44c5wwi03g40dvc6wfnqgdwq-libpciaccess-0.16/lib:/gnu/store/c7wscymmk379v16invi8m68f6v5c8gsv-libevent-2.1.11/lib:/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib:/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib:/gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/lib:/gnu/store/01b4w3m6mp55y531kyi1g8shh722kwqm-gcc-7.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.5.0/../../..
$ objdump -x $(guix build openmpi)/bin/orterun | grep NEED.*libevent
objdump: Advertiment: '/gnu/store/3ign6b3i5ambjgqqiyman4mqw0wljlvl-openmpi-4.0.5-debug' és un directori
  NEEDED               libevent_core-2.1.so.7
  NEEDED               libevent_pthreads-2.1.so.7
--8<---------------cut here---------------end--------------->8---

Ludo’.