libgcrypt1.9.0: Failure on linking test executables

Kasumi Fukuda kasumi at rollingapple.net
Fri Jan 22 06:09:39 CET 2021


On Fri, Jan 22, 2021 at 12:59 PM NIIBE Yutaka <gniibe at fsij.org> wrote:
>
> Kasumi Fukuda <kasumi at rollingapple.net> writes:
> > Let me share a repro step using docker:
>
> Thanks a lot.
>
> I think that it's better practice to do "make check" before
> installation.

Thank you for the advice. It ensures the linked executables are
actually executable.

> And to do that, we need to specify LD_LIBRARY_PATH too (as well as
> PATH), so that testing programs in the build procedure run correctly.

My understanding is that libgcypt and libgpg-error use libtool, so
RPATH (or RUNPATH) for the dependent libraries can be automatically
injected into the executable when linked.
We usually don't need to set LD_LIBRARY_PATH to run such an executable.

If I comment out the t_secmem_LDADD, the link command for t-secmem has
the necessary -rpath for libgpg-error as follows:
----
libtool: link: gcc -I/opt/libgpg-error/include -g -O2
-fvisibility=hidden -fno-delete-null-pointer-checks -Wall -o t-secmem
t-secmem.o -Wl,--disable-new-dtags  ../src/.libs/libgcrypt.so
../compat/.libs/libcompat.a -L/opt/libgpg-error/lib /
opt/libgpg-error/lib/libgpg-error.so -Wl,-rpath
-Wl,/tmp/libgcrypt-1.9.0/src/.libs -Wl,-rpath
-Wl,/opt/libgpg-error/lib -Wl,-rpath -Wl,/opt/libgcrypt/lib -Wl,-rpath
-Wl,/opt/libgpg-error/lib
----
instead of:
----
libtool: link: gcc -I/opt/libgpg-error/include -g -O2
-fvisibility=hidden -fno-delete-null-pointer-checks -Wall -o t-secmem
t-secmem.o  ../src/.libs/libgcrypt.so ../compat/.libs/libcompat.a
-Wl,-rpath -Wl,/tmp/libgcrypt-1.9.0/src/.libs -Wl,-rpath
-Wl,/opt/libgcrypt/lib
----
and `make check` works without LD_LIBRARY_PATH.

This can be virtually tested by:
  sed -i.bak 's/^\([a-z_]\+_LDADD = \)\$(standard_ldadd)$/\1$(LDADD)/'
tests/Makefile.in
before ./configure for libgcrypt.

I'm not sure I understand RPATH/RUNPATH things correctly.
But this way of building GnuPG suite has been working for older
versions and it would be inconvenient if LD_LIBRARY_PATH were required
to be set.

> Like this:
>
> --- libgcrypt-test-install-orig.sh      2021-01-22 11:06:34.329216354 +0900
> +++ libgcrypt-test-install-fixed.sh     2021-01-22 12:29:42.725628836 +0900
> @@ -11,12 +11,13 @@
>
>  cd /tmp/libgpg-error-1.41
>  ./configure --prefix=/opt/libgpg-error --disable-doc
> -make && make install
> +make && make check && make install
>
>  export PATH=/opt/libgpg-error/bin:$PATH
> +export LD_LIBRARY_PATH=/opt/libgpg-error/lib
>
>  cd /tmp/libgcrypt-1.9.0
>  ./configure --prefix=/opt/libgcrypt --disable-doc
> -make && make install
> +make && make check && make install
>
>  EOF
>
>
> And... this works, with no linking errors.
>
> The problem is somehow complicated.  The linker checks runtime libraries
> under LD_LIBRARY_PATH.
>
>
> In your case, even if you don't need 'make check', please specify
> LD_LIBRARY_PATH.
> --



More information about the Gcrypt-devel mailing list