Subject: 29.1; Build fails with "configure --without-all --with-tree-sitter"
From: Ulrich Mueller <[email-masked]>
To: [email-masked]
Date: Mon, 07 Aug 2023 12:44:38 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Forwarding downstream bug: https://bugs.gentoo.org/911826

Linking of temacs fails with undefined references to symbols
dynlib_error, dynlib_open and dynlib_sym when using configure options
--without-all --with-tree-sitter. To reproduce:

emacs-29.1 $ ./configure --without-all --without-x --with-tree-sitter
[...]
emacs-29.1 $ make V=1
[...]
gcc -o temacs.tmp \
  -Demacs  -I. -I. -I../lib -I../lib                          -MMD -MF deps/.d -MP             -g3 -O2     \
    dispnew.o frame.o scroll.o xdisp.o menu.o  window.o charset.o coding.o category.o ccl.o character.o chartab.o bidi.o cm.o term.o terminal.o xfaces.o    emacs.o keyboard.o macros.o keymap.o sysdep.o bignum.o buffer.o filelock.o insdel.o marker.o minibuf.o fileio.o dired.o cmds.o casetab.o casefiddle.o indent.o search.o regex-emacs.o undo.o alloc.o pdumper.o data.o doc.o editfns.o callint.o eval.o floatfns.o fns.o sort.o font.o print.o lread.o  syntax.o  bytecode.o comp.o  process.o gnutls.o callproc.o region-cache.o sound.o timefns.o atimer.o doprnt.o intervals.o textprop.o composite.o xml.o lcms.o   profiler.o decompress.o thread.o systhread.o sqlite.o  treesit.o itree.o          json.o     terminfo.o lastfile.o      ../lib/libgnu.a                              -ltinfo           -lanl   -lm    -ljansson  -lgmp    -ltree-sitter    
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: treesit.o: in function `treesit_load_language':
/local/home/ulm/emacs-29.1/src/treesit.c:617:(.text+0x4a6a): undefined reference to `dynlib_error'
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: /local/home/ulm/emacs-29.1/src/treesit.c:618:(.text+0x4a72): undefined reference to `dynlib_open'
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: /local/home/ulm/emacs-29.1/src/treesit.c:619:(.text+0x4a7a): undefined reference to `dynlib_error'
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: /local/home/ulm/emacs-29.1/src/treesit.c:634:(.text+0x4d41): undefined reference to `dynlib_error'
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: /local/home/ulm/emacs-29.1/src/treesit.c:644:(.text+0x4d68): undefined reference to `dynlib_sym'
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: /local/home/ulm/emacs-29.1/src/treesit.c:646:(.text+0x4d78): undefined reference to `dynlib_error'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:704: temacs] Error 1
make[2]: Leaving directory '/local/home/ulm/emacs-29.1/src'
make[1]: *** [Makefile:544: src] Error 2
make[1]: Leaving directory '/local/home/ulm/emacs-29.1'
make[1]: Entering directory '/local/home/ulm/emacs-29.1'
***
*** "make all" failed with exit status 2.
***
*** You could try to:
*** - run "make bootstrap", which might fix the problem
*** - run "make V=1", which displays the full commands invoked by make,
***   to further investigate the problem
***
make[1]: *** [Makefile:414: advice-on-failure] Error 2
make[1]: Leaving directory '/local/home/ulm/emacs-29.1'
make: *** [Makefile:370: all] Error 2
emacs-29.1 $ 

Looks like configure.ac should set NEED_DYNLIB=yes when tree-sitter
is requested. It already does so in one code path, but it doesn't for
tree-sitter >= 0.20.2.

$ pkg-config --modversion tree-sitter
0.20.9

(The above build failure will also occur with a simple "configure
--without-all", because it leaves both json and tree-sitter enabled.
Is this intentional? I'd have expected --without-all to turn these
features off.)