DragonFlyBSD / DPorts

The dedicated application build system for DragonFly BSD
Other
89 stars 46 forks source link

openldap26-client cannot be linked with dbmail due to missing `libldap_r.so` #239

Closed autumnjolitz closed 10 months ago

autumnjolitz commented 1 year ago

It seems openldap26-client deprecated the libdap_r.so.

A build error looks like

libtool: link: (cd ".libs" && rm -f "libsort_sieve.so.0" && ln -s "libsort_sieve.so.0.0.0" "libsort_sieve.so.0")
libtool: link: (cd ".libs" && rm -f "libsort_sieve.so" && ln -s "libsort_sieve.so.0.0.0" "libsort_sieve.so")
/bin/sh ../../libtool  --tag=CC   --mode=link cc  -pipe -D__FreeBSD__=9 -O2 -DLDAP_DEPRECATED -isystem /usr/local/include -fno-strict-aliasing  -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -pthread  -I/usr/local/include/gmime-2.6 -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -pthread  -I/usr/local/include/zdb -I/usr/local/include/jemalloc -I/usr/include/jemalloc -W -Wall -Wpointer-arith -Wstrict-prototypes -module -lssl -lcrypto -Wl,-rpath,/usr/local/lib  -L/usr/local/lib -Wl,--export-dynamic -lgmodule-2.0 -lglib-2.0 -lgthread-2.0 -pthread -lglib-2.0 -lintl  -L/usr/local/lib -lgmime-2.6 -lgio-2.0 -lgobject-2.0 -lgthread-2.0 -pthread -lglib-2.0 -lintl  -lm -lmhash -levent_pthreads -levent -lcrypto -lssl -lzdb -o libauth_sql.la -rpath /usr/local/lib/dbmail authsql.lo -lcrypt -L/usr/local/lib
libtool: link: ( cd ".libs" && rm -f "libsort_sieve.la" && ln -s "../libsort_sieve.la" "libsort_sieve.la" )
libtool: link: cc -shared  -fPIC -DPIC  .libs/authsql.o   -L/usr/local/lib -lgmodule-2.0 -lgmime-2.6 -lgio-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lintl -lm -lmhash -levent_pthreads -levent -lcrypto -lssl -lzdb -lcrypt  -O2 -Wl,-rpath -Wl,/usr/local/lib -Wl,--export-dynamic   -pthread -Wl,-soname -Wl,libauth_sql.so.0 -o .libs/libauth_sql.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libauth_sql.so.0" && ln -s "libauth_sql.so.0.0.0" "libauth_sql.so.0")
libtool: link: (cd ".libs" && rm -f "libauth_sql.so" && ln -s "libauth_sql.so.0.0.0" "libauth_sql.so")
libtool: link: ( cd ".libs" && rm -f "libauth_sql.la" && ln -s "../libauth_sql.la" "libauth_sql.la" )
/bin/sh ../../libtool  --tag=CC   --mode=link cc  -pipe -D__FreeBSD__=9 -O2 -DLDAP_DEPRECATED -isystem /usr/local/include -fno-strict-aliasing  -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include -pthread  -I/usr/local/include/gmime-2.6 -I/usr/local/include -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -pthread  -I/usr/local/include/zdb -I/usr/local/include/jemalloc -I/usr/include/jemalloc -W -Wall -Wpointer-arith -Wstrict-prototypes -module -lssl -lcrypto -Wl,-rpath,/usr/local/lib  -L/usr/local/lib -Wl,--export-dynamic -lgmodule-2.0 -lglib-2.0 -lgthread-2.0 -pthread -lglib-2.0 -lintl  -L/usr/local/lib -lgmime-2.6 -lgio-2.0 -lgobject-2.0 -lgthread-2.0 -pthread -lglib-2.0 -lintl  -lm -lmhash -levent_pthreads -levent -lcrypto -lssl -lzdb -o libauth_ldap.la -rpath /usr/local/lib/dbmail authldap.lo -lcrypt -lldap_r  -L/usr/local/lib
libtool: link: cc -shared  -fPIC -DPIC  .libs/authldap.o   -L/usr/local/lib -lgmodule-2.0 -lgmime-2.6 -lgio-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lintl -lm -lmhash -levent_pthreads -levent -lcrypto -lssl -lzdb -lcrypt -lldap_r  -O2 -Wl,-rpath -Wl,/usr/local/lib -Wl,--export-dynamic   -pthread -Wl,-soname -Wl,libauth_ldap.so.0 -o .libs/libauth_ldap.so.0.0.0
/usr/libexec/binutils234/elf/ld.gold: error: cannot find -lldap_r
collect2: error: ld returned 1 exit status
gmake[6]: *** [Makefile:2144: libauth_ldap.la] Error 1
gmake[6]: Leaving directory '/usr/obj/dports/mail/dbmail/dbmail-3.2.6/src/modules'
gmake[5]: *** [Makefile:2780: all-recursive] Error 1
gmake[5]: Leaving directory '/usr/obj/dports/mail/dbmail/dbmail-3.2.6/src'
gmake[4]: *** [Makefile:2089: all-recursive] Error 1
gmake[4]: Leaving directory '/usr/obj/dports/mail/dbmail/dbmail-3.2.6'
gmake[3]: *** [Makefile:2021: all] Error 2
gmake[3]: Leaving directory '/usr/obj/dports/mail/dbmail/dbmail-3.2.6'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[2]: stopped in /usr/dports/mail/dbmail
*** Error code 1

Stop.
make[1]: stopped in /usr/dports/mail/dbmail
*** Error code 1

Stop.
make: stopped in /usr/dports/mail/dbmail

A workaround is (given DragonFly uses a GNU compatible linker) is:

$ echo "INPUT ( libldap.so )" | sudo tee -a /usr/local/lib/libldap_r.so
INPUT ( libldap.so )

With that the port builds correctly.

daftaupe commented 1 year ago

@autumnjolitz it seems that this commit did the trick for openldap24-server but that piece of code disappeared later for 25 and 26 versions, I don't know why.

I found another way of fixing the port using the following patch for building with the LDAP option enabled, that I could include easily include in the DeltaPorts.

--- acinclude.m4.orig   2022-12-12 11:23:45.629913000 +0100
+++ acinclude.m4    2022-12-12 11:23:56.130090000 +0100
@@ -222,7 +222,7 @@ if ( test [ "x$lookforldap" != "xno" ] |
         dnl See if we already have the paths we need in the environment.
    dnl ...but only if --with-ldap was given without a specific path.
         if ( test [ "x$lookforldap" = "xyes" ] || test [ "x$lookforauthldap" = "xyes" ] ); then
-            AC_CHECK_HEADERS([ldap.h],[LDAPLIB="-lldap_r"], [LDAPLIB="failed"])
+            AC_CHECK_HEADERS([ldap.h],[LDAPLIB="-lldap"], [LDAPLIB="failed"])
             if test [ "x$LDAPLIB" != "xfailed" ]; then
                 break
             fi
@@ -234,7 +234,7 @@ if ( test [ "x$lookforldap" != "xno" ] |
             SAVE_CFLAGS=$CFLAGS
        dnl The headers might be in a funny place, so we need to use -Ipath
             CFLAGS="$CFLAGS -L$TEST_PATH $LDAPINC"
-            AC_CHECK_HEADERS([ldap.h],[LDAPLIB="-L$TEST_PATH -lldap_r"], [LDAPLIB="failed"])
+            AC_CHECK_HEADERS([ldap.h],[LDAPLIB="-L$TEST_PATH -lldap"], [LDAPLIB="failed"])
             CFLAGS=$SAVE_CFLAGS
             if test [ "x$LDAPLIB" != "xfailed" ]; then
                 break 2

Because the issue that I see with the solution you provided is that someone will have to also create that libldap_r.so file after installing as that file isn't shipped by openldap26-client anymore. In the built package at least /usr/local/lib/dbmail/libauth_ldap.so will depend on that file.

tuxillo commented 1 year ago

I don't see the libdap_r.so file in the client's plist in the FreeBSD port. Where is that _r file coming from?

daftaupe commented 1 year ago

@tuxillo it was shipped by net/openldap24-client as you can see in https://github.com/freebsd/freebsd-ports/blob/537a9c13bf1ea73564aa51f91d805927e32f7401/net/openldap24-server/pkg-plist.client#L36 but that file has disappeared from next releases such as https://github.com/freebsd/freebsd-ports/blob/main/net/openldap26-server/pkg-plist.client, because of the piece of code in the commit I linked before that created that libldap_r.so for openldap24-server that hasn't been kept in next releases (see the Makefiles of net/openldap25-server and net/openldap26-server lacking this loop).

So as for now there's no libldap_r.so installed anymore, that's why I changed the -lldap_r to -lldap in the patch file provided.

daftaupe commented 1 year ago

What do we do with that one ?

daftaupe commented 10 months ago

As of version 3.3.1 of mail/dbmail, there should be no problem with the LDAP option as they don't try to link with lldap_r anymore.