Re: Linking of libdar64

John Goerzen <[email protected]> Tue, 11 Jul 2023 21:39:36 -0500
Newsgroups gmane.comp.sysutils.backup.dar.support
Message-ID <[email protected]>
On Tue, Jul 11 2023, Denis Corbin wrote:

> I've fixed that by merging those other *_LIBS/CXXFLAGS/CPPFLAGS into their
> LIBS/CXXFLAGS/CPPFLAGS counterparts... the result seems fixing the issue.
>
> If you have the opportunity/possibility to test the 2.7.11.RC1 available at
> https://dar.edrusb.org/dar.linux.free.fr/Interim_releases/ for confirmation, I
> will then release 2.7.11 at next week-end.

I took a quick look and ran into a stumbling block.  I may not have the
chance to investigate this for a day or two, but from what you've said,
it sounds like you've got the solution.

Debian has been carrying this patch for awhile:

--- dar-2.7.8.orig/src/dar_suite/Makefile.am
+++ dar-2.7.8/src/dar_suite/Makefile.am
@@ -92,7 +92,7 @@ endif
 #

 bin_PROGRAMS = dar dar_xform dar_slave dar_manager dar_cp dar_split $(ALSO_BUILD)
-LDADD = ../libdar/$(MYLIB).la $(LIBCURL_LIBS) $(GPGME_LIBS) $(LIBTHREADAR_LIBS) $(LTLIBINTL)
+LDADD = ../libdar/$(MYLIB).la $(LIBCURL_LIBS) $(GPGME_LIBS) -lassuan $(LIBTHREADAR_LIBS) $(LTLIBINTL)
 if DEBUG_STATIC
 AM_LDFLAGS = -all-static $(LD_PROF)
 else

This is because libgpgme needs libassuan.  TBH, this is another case of
"I'm not sure why this is working for others".  Well that patch of
course no longer applies and LDADD doesn't look like the right place to
add this anymore either.  I just need to find the right place to add
-lassuan.

... but I mention it here because this got me thinking: why are we
patching this specially in Debian?  Maybe this should be upstream?

It's probably not a problem with the dynamically-linked version:

$ ldd /usr/lib/x86_64-linux-gnu/libgpgme.so
        linux-vdso.so.1 (0x00007ffdc50f5000)
        libassuan.so.0 => /lib/x86_64-linux-gnu/libassuan.so.0 (0x00007f5e9577e000)
        libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f5e95756000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5e95575000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f5e95821000)

But with the static linking, it pops up:

libtool: link: g++ -g -O2 -ffile-prefix-map=/home/jgoerzen/work/dartmp/dar=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,
-z -Wl,relro -Wl,-z -Wl,now -o dar_manager dar_suite.o dar_manager.o line_tools.o no_comment.o hide_file.o  ../libdar/.libs/libdar64.a -lar
gon2 -lthreadar -lpthread -L/usr/lib/x86_64-linux-gnu -lgpgme -lrsync -lgcrypt -lgpg-error -llz4 -lzstd -llzma -llzo2 -lbz2 -lz -ldl -lcap
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libgpg-error.a(libgpg_error_la-sysutils.o): in function `_gpgrt_getpwdir':
(.text+0x2ca): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/bin/ld: (.text+0x2e8): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the g
libc version used for linking
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libgpgme.a(engine-gpgsm.o): in function `gpgsm_assuan_simple_command':
(.text+0x14f): undefined reference to `assuan_write_line'
/usr/bin/ld: (.text+0x172): undefined reference to `assuan_read_line'
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libgpgme.a(engine-gpgsm.o): in function `gpgsm_cancel':
(.text+0x4eb): undefined reference to `assuan_release'
... and more ...

I certainly don't mind adapting this Debian patch to the new layout, but
thought I'd mention in case you're interested also.

- John