From: Edd Barrett Subject: Re: [update] textproc/tree-sitter 0.26.7 To: Laurent Cheylus Cc: ports , jca@openbsd.org Date: Wed, 1 Apr 2026 16:54:25 +0100 CC jca@, maintainer of emacs, On Tue, Mar 31, 2026 at 12:15:50PM +0100, Edd Barrett wrote: > Did you check that emacs (the ony other consumer of this afaics) builds? Yeah, this breaks emacs: ``` >>> referenced by treesit.c:749 >>> treesit.o:(treesit_load_language) >>> referenced by treesit.c:820 >>> treesit.o:(Ftreesit_language_abi_version) cc: error: linker command failed with exit code 1 (use -v to see invocation) ``` There's no new emacs release that fixes it, but below is a patch that makes it build. (I've only build tested emacs and checked it at least starts. I know nothing about emacs!) OK? Index: Makefile =================================================================== RCS file: /cvs/ports/editors/emacs/Makefile,v diff -u -p -r1.127 Makefile --- Makefile 1 Nov 2025 11:16:41 -0000 1.127 +++ Makefile 1 Apr 2026 15:48:46 -0000 @@ -2,7 +2,7 @@ COMMENT= GNU editor: extensible, custom VERSION= 30.2 DISTNAME= emacs-${VERSION} -REVISION= 0 +REVISION= 1 CATEGORIES= editors Index: patches/patch-src_treesit_c =================================================================== RCS file: patches/patch-src_treesit_c diff -N patches/patch-src_treesit_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_treesit_c 1 Apr 2026 15:43:50 -0000 @@ -0,0 +1,96 @@ +Fix linkage with treesitter-0.26. + +https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-emacs/006-tree-sitter-0.26.patch + +Index: src/treesit.c +--- src/treesit.c.orig ++++ src/treesit.c +@@ -34,7 +34,11 @@ along with GNU Emacs. If not, see = 15 ++#undef ts_language_abi_version ++#else + #undef ts_language_version ++#endif + #undef ts_node_child + #undef ts_node_child_by_field_name + #undef ts_node_child_count +@@ -89,7 +93,11 @@ along with GNU Emacs. If not, see = 15 ++DEF_DLL_FN (uint32_t, ts_language_abi_version, (const TSLanguage *)); ++#else + DEF_DLL_FN (uint32_t, ts_language_version, (const TSLanguage *)); ++#endif + DEF_DLL_FN (TSNode, ts_node_child, (TSNode, uint32_t)); + DEF_DLL_FN (TSNode, ts_node_child_by_field_name, + (TSNode, const char *, uint32_t)); +@@ -166,7 +174,11 @@ init_treesit_functions (void) + if (!library) + return false; + ++#if TREE_SITTER_LANGUAGE_VERSION >= 15 ++ LOAD_DLL_FN (library, ts_language_abi_version); ++#else + LOAD_DLL_FN (library, ts_language_version); ++#endif + LOAD_DLL_FN (library, ts_node_child); + LOAD_DLL_FN (library, ts_node_child_by_field_name); + LOAD_DLL_FN (library, ts_node_child_count); +@@ -224,7 +236,11 @@ init_treesit_functions (void) + return true; + } + ++#if TREE_SITTER_LANGUAGE_VERSION >= 15 ++#define ts_language_abi_version fn_ts_language_abi_version ++#else + #define ts_language_version fn_ts_language_version ++#endif + #define ts_node_child fn_ts_node_child + #define ts_node_child_by_field_name fn_ts_node_child_by_field_name + #define ts_node_child_count fn_ts_node_child_count +@@ -632,6 +648,22 @@ treesit_load_language_push_for_each_suffix (Lisp_Objec + } + } + ++/* This function is a compatibility shim. Tree-sitter 0.25 introduced ++ ts_language_abi_version as a replacement for ts_language_version, and ++ tree-sitter 0.26 removed ts_language_version. Here we use the fact ++ that 0.25 bumped TREE_SITTER_LANGUAGE_VERSION to 15, to use the new ++ function instead of the old one, when Emacs is compiled against ++ tree-sitter version 0.25 or newer. */ ++static uint32_t ++treesit_language_abi_version (const TSLanguage *ts_lang) ++{ ++#if TREE_SITTER_LANGUAGE_VERSION >= 15 ++ return ts_language_abi_version (ts_lang); ++#else ++ return ts_language_version (ts_lang); ++#endif ++} ++ + /* Load the dynamic library of LANGUAGE_SYMBOL and return the pointer + to the language definition. + +@@ -746,7 +778,7 @@ treesit_load_language (Lisp_Object language_symbol, + { + *signal_symbol = Qtreesit_load_language_error; + *signal_data = list2 (Qversion_mismatch, +- make_fixnum (ts_language_version (lang))); ++ make_fixnum (ts_language_abi_version (lang))); + return NULL; + } + return lang; +@@ -817,7 +849,7 @@ Return nil if a grammar library for LANGUAGE is not av + &signal_data); + if (ts_language == NULL) + return Qnil; +- uint32_t version = ts_language_version (ts_language); ++ uint32_t version = treesit_language_abi_version (ts_language); + return make_fixnum((ptrdiff_t) version); + } + } -- Best Regards Edd Barrett https://www.theunixzoo.co.uk