Toggle quote (107 lines)
> 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---
> ld-wrapper: library search path:
> ("/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib"
> "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../.."
> "/gnu/store/inpy5mz35fwvclynpag5gsp6d1hflfsz-meson-1.1.0/lib"
> "/gnu/store/qhz8n6mxzalifcrml6fwsvnxw92bk7n0-fmt-9.1.0/lib"
> "/gnu/store/j8wlfmlmfvpbza6is9wv9xsd8psrxn00-bzip2-1.0.8/lib"
> "/gnu/store/gr0sy0m1mv36qv54idm6cn10l3mngshq-file-5.44/lib"
> "/gnu/store/hc05d76f1j3iz3v2bs5jz4fpljl1r4dj-gawk-5.2.1/lib"
> "/gnu/store/6k1yys9wqrfn4y41ic1win8gpnimncwj-xz-5.2.8/lib"
> "/gnu/store/visfdda934gvivwihwhlm63fdqhhcc8a-glibc-utf8-locales-
> 2.35/lib" "/gnu/store/0irvg0gvvfwagdjckigvr4g8xap94y1j-clang-
> toolchain-18.1.5/lib")
> ld-wrapper: libraries linked:
> ("/gnu/store/qhz8n6mxzalifcrml6fwsvnxw92bk7n0-fmt-
> 9.1.0/lib/libfmt.so" "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-
> gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-
> gnu/11.3.0/../../../libstdc++.so"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libm.so"
> "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../libgcc_s.so"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/libc.so"
> "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../libgcc_s.so")
> ld-wrapper: invoking `/gnu/store/zh4x65snfis7svs6906gj1z8i7dx2j3m-
> binutils-2.38/bin/ld' with ("--eh-frame-hdr" "-m" "elf_x86_64" "-pie"
> "-dynamic-linker" "//gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-
> glibc-2.35/lib/ld-linux-x86-64.so.2" "-o" "hello"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/Scrt1.o"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/crti.o"
> "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/crtbeginS.o" "-
> L/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0" "-
> L/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib" "-
> L/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../.." "-
> L/gnu/store/inpy5mz35fwvclynpag5gsp6d1hflfsz-meson-1.1.0/lib" "-
> L/gnu/store/qhz8n6mxzalifcrml6fwsvnxw92bk7n0-fmt-9.1.0/lib" "-
> L/gnu/store/j8wlfmlmfvpbza6is9wv9xsd8psrxn00-bzip2-1.0.8/lib" "-
> L/gnu/store/gr0sy0m1mv36qv54idm6cn10l3mngshq-file-5.44/lib" "-
> L/gnu/store/hc05d76f1j3iz3v2bs5jz4fpljl1r4dj-gawk-5.2.1/lib" "-
> L/gnu/store/6k1yys9wqrfn4y41ic1win8gpnimncwj-xz-5.2.8/lib" "-
> L/gnu/store/visfdda934gvivwihwhlm63fdqhhcc8a-glibc-utf8-locales-
> 2.35/lib" "-L/gnu/store/0irvg0gvvfwagdjckigvr4g8xap94y1j-clang-
> toolchain-18.1.5/lib" "hello.p/hello.cpp.o" "--as-needed" "--no-
> undefined" "-rpath=/gnu/store/g9wxj9a27jhnxa40zafh0ff33dd8906y-why-
> hello-0/lib" "-rpath" "/gnu/store/qhz8n6mxzalifcrml6fwsvnxw92bk7n0-
> fmt-9.1.0/lib" "-rpath-link"
> "/gnu/store/qhz8n6mxzalifcrml6fwsvnxw92bk7n0-fmt-9.1.0/lib" "--start-
> group" "/gnu/store/qhz8n6mxzalifcrml6fwsvnxw92bk7n0-fmt-
> 9.1.0/lib/libfmt.so" "--end-group" "-lstdc++" "-lm" "-lgcc_s" "-lgcc"
> "-lc" "-lgcc_s" "-lgcc" "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-
> gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/crtendS.o"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/crtn.o"
> "-rpath" "/gnu/store/qhz8n6mxzalifcrml6fwsvnxw92bk7n0-fmt-9.1.0/lib"
> "-rpath" "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../.." "-rpath"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib" "-rpath"
> "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../.." "-rpath"
> "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib" "-rpath"
> "/gnu/store/l684qgqlrqkbsh8jffp9d8ag6vrpcwgs-gcc-11.3.0-
> lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../..")
>
> […]
>
> 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?
If I recall correctly, Meson performs separate linking on install, so
that certain stuff works from the build directory without resorting to
`./pre-inst-env` or the like.¹ However, why does it not find libfmt.so
when using Clang, but does find it when using GCC? Does our clang-
toolchain prepare the correct wrapper? I feel like lld might be hidden
and unpatched in there – or something else weird is happening.
Cheers
¹ I actually can't support this claim, as the GUIX_LD_WRAPPER_DEBUG
only shows up on build as expected even with the gcc-toolchain variant.