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.)