Subject: bug#70349: Clang fails to communicate RUNPATH?

From: Ludovic Courtès <[email-masked]>
Date: Sat, 25 May 2024 11:26:42 +0200

Hi Liliana,

Liliana Marie Prikler <[email-masked]> skribis:

> I've noticed a strange error when attempting to build my software
> against clang-toolchain.  I've attached a minimally breaking example,
> but the gist of it is that RUNPATH validation fails as shown below.
>
>   starting phase `validate-runpath'
>   validating RUNPATH of 1 binaries in
>   "/gnu/store/sd1zjjf13mi448qbqaphhcvf9ap5jxji-why-hello-0/bin"...
>   /gnu/store/sd1zjjf13mi448qbqaphhcvf9ap5jxji-why-hello-0/bin/hello:
>   error: depends on 'libfmt.so.9', which cannot be found in RUNPATH
>   ("/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib")
>
> Is this expected?  I know that the -for-system have historically
> disregarded the existence of clang-toolchain and hence led to issues,
> but I think this is something else…

Could this be an issue specific to ‘meson-build-system’?

For instance, this works fine (both mpfr and mpc use
‘gnu-build-system’):

  guix build mpc --with-c-toolchain=mpfr=clang-toolchain

If we add this to the example you posted:

   (arguments
    (list #:phases #~(modify-phases %standard-phases
                       (add-after 'unpack 'debug-ld-wrapper
                         (lambda _
                           (setenv "GUIX_LD_WRAPPER_DEBUG" "yes"))))))

… we see:

--8<---------------cut here---------------start------------->8---

[…]

starting phase `shrink-runpath'
/gnu/store/g9wxj9a27jhnxa40zafh0ff33dd8906y-why-hello-0/bin/hello: stripping RUNPATH to ("/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib") (removed ("/gnu/store/g9wxj9a27jhnxa40zafh0ff33dd8906y-why-hello-0/lib" "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../.."))
phase `shrink-runpath' succeeded after 0.0 seconds
starting phase `validate-runpath'
validating RUNPATH of 1 binaries in "/gnu/store/g9wxj9a27jhnxa40zafh0ff33dd8906y-why-hello-0/bin"...
/gnu/store/g9wxj9a27jhnxa40zafh0ff33dd8906y-why-hello-0/bin/hello: error: depends on 'libfmt.so.9', which cannot be found in RUNPATH ("/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib")
--8<---------------cut here---------------end--------------->8---

So the ‘ld’ wrapper is indeed passing ‘-rpath /path/to/fmt’ but down the
road that gets lost.  Could it be that Meson removes it when it install
files?

Ludo’.