Subject: bug#60061: 30.0.50; Build fails in separate directory for ../configure --without-all --with-mailutils

From: Eli Zaretskii <[email-masked]>
Date: Wed, 21 Dec 2022 21:54:40 +0200

> Date: Wed, 21 Dec 2022 21:48:56 +0300
> From: Jean Louis <[email-masked]>
> Cc: [email-masked]
> 
> /usr/bin/ld: treesit.o: in function `treesit_load_language':
> /home/data1/protected/Programming/Software/emacs/without-all/src/../../src/treesit.c:577: undefined reference to `dynlib_error'
> /usr/bin/ld: /home/data1/protected/Programming/Software/emacs/without-all/src/../../src/treesit.c:578: undefined reference to `dynlib_open'
> /usr/bin/ld: /home/data1/protected/Programming/Software/emacs/without-all/src/../../src/treesit.c:579: undefined reference to `dynlib_error'
> /usr/bin/ld: /home/data1/protected/Programming/Software/emacs/without-all/src/../../src/treesit.c:594: undefined reference to `dynlib_error'
> /usr/bin/ld: /home/data1/protected/Programming/Software/emacs/without-all/src/../../src/treesit.c:600: undefined reference to `dynlib_sym'
> /usr/bin/ld: /home/data1/protected/Programming/Software/emacs/without-all/src/../../src/treesit.c:602: undefined reference to `dynlib_error'
> collect2: error: ld returned 1 exit status
> make[2]: *** [Makefile:704: temacs] Error 1

This is a completely different error message, and it points out a real
problem, which has nothing to do with building in a separate
directory.  The problem is triggered by --without-all, which includes
 --without-modules, and that causes us not to compile dynlib.c, which
is needed by the tree-sitter support.

I installed a fix on the emacs-29 branch.  The patch is below if you
want to try it before it gets merged to master.

diff --git a/configure.ac b/configure.ac
index 432638f..ac29f35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3220,6 +3220,7 @@ AC_DEFUN
 
 HAVE_TREE_SITTER=no
 TREE_SITTER_OBJ=
+NEED_DYNLIB=no
 
 if test "${with_tree_sitter}" != "no"; then
    dnl Tree-sitter 0.20.2 added support to change the malloc it uses
@@ -3245,6 +3246,7 @@ AC_DEFUN
       LIBS=$OLD_LIBS
       if test "$ac_cv_func_ts_set_allocator" = yes; then
         AC_DEFINE(HAVE_TREE_SITTER, 1, [Define if using tree-sitter.])
+	NEED_DYNLIB=yes
       else
         AC_MSG_ERROR([Tree-sitter library exists but its version is too old]);
         TREE_SITTER_CFLAGS=
@@ -4154,7 +4156,6 @@ AC_DEFUN
 LIBMODULES=
 HAVE_MODULES=no
 MODULES_OBJ=
-NEED_DYNLIB=no
 MODULES_SUFFIX="${DYNAMIC_LIB_SUFFIX}"
 MODULES_SECONDARY_SUFFIX="${DYNAMIC_LIB_SECONDARY_SUFFIX}"