Page MenuHome GnuPG

libgcrypt: gpgrt-config not found in $PREFIX if there are no less-preferred options found via $CC
Testing, NormalPublic


We came across a build problem in libgcrypt, concerning finding gpgrt-config from $PREFIX.

We have a slightly unusual build environment, in which $CC is pointing to a compiler we have built (not the system install). In particular, none of the directories on the compiler's libraries search path contain a pkgconfig directory.

We have built our previous dependencies (including libgpg-error 1.46) and installed them in $PREFIX. $PREFIX/lib/pkgconfig exists. Therefore we expect that libgcrpyt's configure script would be able to find gpgrt-config within $PREFIX.

However, the most preferred directories (set as possible_libdir1, possible_libdir2) are searched within a loop of candidates (set as libdir_candidates), generated from the output of $CC -print-search-dirs and filtered on the existence of a pkgconfig directory contained within. If there are no possible results in libdir_candidates, then possible_libdir1 will never be considered even though it is preferred.

I propose a patch in which one entry is always added to libdir_candidates, so that the loop is always executed at least once. (If this entry is not valid, then test -f ${possible_libdir0}/pkgconfig/gpg-error.pc will never be true, gpgrt_libdir is not set and there is no change in behaviour.)



Event Timeline

werner added subscribers: gniibe, werner.

@gniibe: Would you mind to look at this?

werner triaged this task as Normal priority.Tue, Mar 21, 3:24 PM

Thank you for the bug report.

I see your problem. We need to improve the patch, as we cannot use Bash-only feature in configure.

To be as small as possible, change is like:

diff --git a/gpg-error.m4 b/gpg-error.m4
index 908e604..0259c10 100644
--- a/gpg-error.m4
+++ b/gpg-error.m4
@@ -115,7 +115,7 @@ AC_DEFUN([_AM_PATH_GPGRT_CONFIG],[dnl
         if test -n "$gpgrt_libdir"; then break; fi
-      if test -z "$libdir_candidates"; then
+      if test -z "$gpgrt_libdir"; then
         # No valid pkgconfig dir in any of the system directories, fallback

That is, prefer possible_libdir1 when not used. Please test this.

gniibe changed the task status from Open to Testing.Thu, Mar 23, 6:51 AM
gniibe added a project: gpgrt.

Fixed in master (of libgpg-error).
Pushed the change to libgcrypt (master and 1.10 branch).

Trying to crosscompile newer 2.4 gpg toolstack from Heads OSF under PR

That is
-gpg2_version := 2.4.0
-libassuan_version := 2.5.5
-libgcrypt_version := 1.10.1
-libgpg-error_version := 1.46
-libksba_version := 1.6.3

I attempted to test some of your fixes, without success, which is why i'm here (hello!)

You can see build failing at, for some reason, pkg-config is used but fails against not being found, which doesn't make any sense.

Without additional fixes, "/root/project/install/x86/bin/gpg-error-config" is found, but not gpgrt-config in the same directory:

The main Makefile of Heads project attempts to do the right thing with pkg-config around
Of course, some fixes still need to be applied against configure scripts for crosscompilation, as can be seen as example at:

Any patches you would recommend to be directly applied on top of extracted libgcrypt as defined per module config:

@tlaurion Thank you for the report, but your particular problem is irrelevant to this ticket.
I lightly looked the log and noticed that the cross build would have some confusions for pkg-config, however, that's not our problem but yours.
For the particular failures in your build, the issues look like a problem of musl linker. It seems that it requires all dependency of libraries to be used, even if an executable doesn't use a library directly.
If it is the case, we need a patch... something like:

diff --git a/tests/ b/tests/
index 75aa5cf7..f8e50dae 100644
--- a/tests/
+++ b/tests/
@@ -83,9 +83,6 @@ EXTRA_DIST = README rsa-16k.key \
 pkbench_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
-prime_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
-t_mpi_bit_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
-t_secmem_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
 testapi_LDADD = $(standard_ldadd) @LDADD_FOR_TESTS_KLUDGE@
 t_lock_LDADD = $(standard_ldadd) $(GPG_ERROR_MT_LIBS) @LDADD_FOR_TESTS_KLUDGE@

... for musl linker.

If you continue, please open your ticket for musl build.