Subject: bug#54378: Still build failed with USE='gtk -X gui'

From: Robert Pluim <[email-masked]>
Date: Tue, 15 Mar 2022 19:59:13 +0100

>>>>> On Tue, 15 Mar 2022 18:17:54 +0100, Robert Pluim <[email-masked]> said:

>>>>> On Tue, 15 Mar 2022 18:58:40 +0200, Eli Zaretskii <[email-masked]> said:
    >>> This is the error I got:
    >>> /usr/bin/x86_64-pc-linux-gnu-ld: pgtkterm.o: undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
    >>> /usr/bin/x86_64-pc-linux-gnu-ld: /lib64/libdl.so.2: error adding symbols: DSO missing from command line
    >>> clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

    Eli> I guess this means that configuration needs a configure-time test for
    Eli> linking against libdl, as some systems do need that separate library
    Eli> to have dlopen/dlsym/etc.

    Robert> dlsym is part of glibc, so thereʼs something else going on.

Eli's right and Iʼm wrong: itʼs part of glibc, but requires libdl (but
only on Gnu/Linux).

    Robert> The complete link line would be useful, can you run 'make V=1' and
    Robert> show the error log?

so I can reproduce this with

configure --with-pgtk --without-modules

and this fixes it:

diff --git a/configure.ac b/configure.ac
index a315eeb6bd..df00c98e36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3940,10 +3940,16 @@ AC_DEFUN
   darwin) MODULES_SECONDARY_SUFFIX='.so' ;;
   *) MODULES_SECONDARY_SUFFIX='' ;;
 esac
+
+case $opsys in
+  gnu|gnu-linux)
+  LIBMODULES="-ldl"
+  ;;
+esac
+
 if test "${with_modules}" != "no"; then
   case $opsys in
     gnu|gnu-linux)
-      LIBMODULES="-ldl"
       HAVE_MODULES=yes
       ;;
     cygwin|mingw32|darwin)