libpq does use libldap, coming from openldap. In the release
announcement for Openldap 2.5 ,
https://www.openldap.org/software/release/announce.html , is written
that libldap_r has been merged with libldap . In turn on a system
with OpenLDAP 2.4, after installing OpenLDAP 2.5, libldap is for v2.5
and libldap_r i for v2.4 . On such systems Libpq links with
libldap_r-2.4-releng.so.2 , while Postgresql Postgresql 13.4 is linked
with libldap-2.5 .
The release notes for Postgresql 13.4 ,
https://www.postgresql.org/docs/13/release-13-4.html, contain:
<!--
Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master [d0a02bdb8] 2021-07-09 12:38:55 -0400
Branch: REL_14_STABLE [5620ec833] 2021-07-09 12:38:55 -0400
Branch: REL_13_STABLE [55cccdfdf] 2021-07-09 12:38:55 -0400
Branch: REL_12_STABLE [a5377e7f7] 2021-07-09 12:38:55 -0400
Branch: REL_11_STABLE [b69e8ad6c] 2021-07-09 12:38:55 -0400
Branch: REL_10_STABLE [7e0b53ad6] 2021-07-09 12:38:55 -0400
Branch: REL9_6_STABLE [cd5d3aefa] 2021-07-09 12:38:55 -0400
Branch: master [31e8cfac5] 2021-07-09 14:15:41 -0400
Branch: REL_14_STABLE [7f2eca6f9] 2021-07-09 14:15:41 -0400
Branch: REL_13_STABLE [cbcf5ffb1] 2021-07-09 14:15:41 -0400
Branch: REL_12_STABLE [83a8bf24e] 2021-07-09 14:15:41 -0400
Branch: REL_11_STABLE [29a4fbd46] 2021-07-09 14:15:41 -0400
Branch: REL_10_STABLE [911488b42] 2021-07-09 14:15:41 -0400
Branch: REL9_6_STABLE [8c9c20899] 2021-07-09 14:15:41 -0400
Branch: master [53c38a086] 2021-07-09 16:59:07 -0400
Branch: REL_14_STABLE [9ffad7ae7] 2021-07-09 16:59:07 -0400
Branch: REL_13_STABLE [32d0bdbfc] 2021-07-09 16:59:07 -0400
Branch: REL_12_STABLE [e82cde74d] 2021-07-09 16:59:08 -0400
Branch: REL_11_STABLE [2c28c689f] 2021-07-09 16:59:08 -0400
Branch: REL_10_STABLE [56533fce7] 2021-07-09 16:59:08 -0400
Branch: REL9_6_STABLE [3c612d9f6] 2021-07-09 16:59:08 -0400
Branch: master [9f6be2e79] 2021-07-10 13:19:30 -0400
Branch: REL_14_STABLE [ebc346e5b] 2021-07-10 13:19:31 -0400
Branch: REL_13_STABLE [9fca23c1d] 2021-07-10 13:19:31 -0400
Branch: REL_12_STABLE [03fc042eb] 2021-07-10 13:19:31 -0400
Branch: REL_11_STABLE [946f62f2f] 2021-07-10 13:19:31 -0400
-->
<para>
Fix <application>configure</application> to work with OpenLDAP 2.5,
which no longer has a separate <filename>libldap_r</filename>
library (Adrian Ho, Tom Lane)
</para>
<para>
If there is no <filename>libldap_r</filename> library, we now
silently assume that <filename>libldap</filename> is thread-safe.
</para>
</listitem>
The current postgres’/configure.ac logic is: if libldap_r is availabe,
then use it, otherwise use libldap.
Searching with nm -D in libldap-2.4-releng.so,
libldap_r-2.4-releng.so, and libldap-2.5.releng.so I find that in the
former the symbol ldap_compare is not versioned, while the latter
contains ldap_compare@@OPENLDAP_2.5.releng . This could be used as
criterion, whether to skip ldap_r .
Moreover, the installed ldap_features.h file contains:
/* is -lldap reentrant or not */
#define LDAP_API_FEATURE_X_OPENLDAP_REENTRANT 1
/* is -lldap thread safe or not */
#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1
I propose, instead of looking for the presence of libldap_r, to check
the feature macro, and if libldap is reentrant, not to use libldap_r .
Greetings
Дилян