Bug 279968 - devel/tclxml: Fails to build with libxml2 2.13.1 and libxslt 1.1.41
Summary: devel/tclxml: Fails to build with libxml2 2.13.1 and libxslt 1.1.41
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-tcltk (Nobody)
URL:
Keywords:
Depends on:
Blocks: 279705 279741
  Show dependency treegraph
 
Reported: 2024-06-24 18:40 UTC by Daniel Engberg
Modified: 2024-07-01 06:51 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (tcltk)


Attachments
Patch for tclxml (1.94 KB, patch)
2024-06-29 06:45 UTC, Daniel Engberg
no flags Details | Diff
Fix tclxml build with libxml2 2.11 and 2.13 (2.35 KB, patch)
2024-06-30 17:51 UTC, Pietro Cerutti
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Pietro Cerutti freebsd_committer freebsd_triage 2024-06-25 06:16:46 UTC
Hi - thanks for the report. I don't have libxml2 2.13.1 and libxslt 1.1.41, but I think I have a patch. Can you please try this?

--- docObj.c.orig       2024-06-25 06:16:01 UTC
+++ docObj.c
@@ -1854,7 +1854,7 @@ TclXML_libxml2_ErrorHandler (ctx, error)
 void
 TclXML_libxml2_ErrorHandler (ctx, error)
      void *ctx; /* ignore - depends on context */
-     xmlErrorPtr error;
+     const xmlErrorPtr error;
 {
   ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
   Tcl_Obj *objPtr;
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2024-06-29 06:45:24 UTC
Created attachment 251767 [details]
Patch for tclxml

Sources:
https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-tcltk/tclxml/files/tclxml-3.2-fix-implicit-declarations.patch
https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-tcltk/tclxml/files/tclxml-3.3.1-funcPointer.patch

With PR 279705 and 279741 applied
Poudriere testport OK 13.2-RELEASE (amd64)
Poudriere testport OK 14.0-RELEASE (amd64)

Without PRs applied
Poudriere testport OK 13.2-RELEASE (amd64)
Poudriere testport OK 14.0-RELEASE (amd64)
Comment 3 Pietro Cerutti freebsd_committer freebsd_triage 2024-06-30 08:11:14 UTC
Two things:

1) I think the patch to should include this second chunk too:

--- include/tclxml-libxml2/tclxml-libxml2Decls.h.orig   2013-03-30 17:17:07 UTC
+++ include/tclxml-libxml2/tclxml-libxml2Decls.h
@@ -55,7 +55,7 @@ EXTERN void           TclXML_libxml2_ErrorHandler _ANSI_ARGS_((
                                TclXML_libxml2_DocumentHandling keep));
 /* 10 */
 EXTERN void            TclXML_libxml2_ErrorHandler _ANSI_ARGS_((void * ctx, 
-                               xmlErrorPtr error));
+                               const xmlError *error));
 /* 11 */
 EXTERN void            TclXML_libxml2_ResetError _ANSI_ARGS_((
                                Tcl_Interp * interp));
@@ -93,7 +93,7 @@ typedef struct Tclxml_libxml2Stubs {
     int (*tclXML_libxml2_GetTclDocFromNode) _ANSI_ARGS_((Tcl_Interp * interp, xmlNodePtr nodePtr, TclXML_libxml2_Document ** tDocPtrPtr)); /* 7 */
     void (*tclXML_libxml2_DestroyDocument) _ANSI_ARGS_((TclXML_libxml2_Document * tDocPtr)); /* 8 */
     void (*tclXML_libxml2_DocKeep) _ANSI_ARGS_((Tcl_Obj * objPtr, TclXML_libxml2_DocumentHandling keep)); /* 9 */
-    void (*tclXML_libxml2_ErrorHandler) _ANSI_ARGS_((void * ctx, xmlErrorPtr error)); /* 10 */
+    void (*tclXML_libxml2_ErrorHandler) _ANSI_ARGS_((void * ctx, const xmlError * error)); /* 10 */
     void (*tclXML_libxml2_ResetError) _ANSI_ARGS_((Tcl_Interp * interp)); /* 11 */
     Tcl_Obj * (*tclXML_libxml2_GetErrorObj) _ANSI_ARGS_((Tcl_Interp * interp)); /* 12 */
     void (*tclXML_libxml2_SetErrorNodeFunc) _ANSI_ARGS_((Tcl_Interp * interp, TclXML_ErrorNodeHandlerProc * proc)); /* 13 */

2) These patches cannot be applied to the current libxml2 2.11.8, as the signature of that function is not backwards compatible.

docObj.c:124:60: error: incompatible function pointer types passing 'void (void *, const xmlError *)' (aka 'void (void *, const struct _xmlError *)') to parameter of type 'xmlStructured
ErrorFunc' (aka 'void (*)(void *, struct _xmlError *)') [-Wincompatible-function-pointer-types]
  xmlSetStructuredErrorFunc((void *) tsdPtr->errorInfoPtr, TclXML_libxml2_ErrorHandler);
                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libxml2/libxml/xmlerror.h:873:29: note: passing argument to parameter 'handler' here
                                 xmlStructuredErrorFunc handler);

Are you planning to commit everything at once? An alternative would be to conditionally change the signatures under LIBXML_VERSION_NUMBER >= 21200
Comment 4 Daniel Engberg freebsd_committer freebsd_triage 2024-06-30 08:24:10 UTC
The preferable solution is to have as much as possible ready in tree supporting  both versions as there will be exp-run requests.
Comment 5 Pietro Cerutti freebsd_committer freebsd_triage 2024-06-30 17:51:53 UTC
Created attachment 251802 [details]
Fix tclxml build with libxml2 2.11 and 2.13
Comment 6 Pietro Cerutti freebsd_committer freebsd_triage 2024-06-30 17:52:12 UTC
Can you please check the attached patch with libxml2 2.13.1?
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-07-01 06:51:03 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=af36765e17ba36d0e86e95d4476b67f894209468

commit af36765e17ba36d0e86e95d4476b67f894209468
Author:     Pietro Cerutti <gahr@FreeBSD.org>
AuthorDate: 2024-07-01 06:39:47 +0000
Commit:     Pietro Cerutti <gahr@FreeBSD.org>
CommitDate: 2024-07-01 06:49:49 +0000

    devel/tclxml: fix build with libxml2 >= 2.12

    Version 2.12 of libxml2 introduced a backwards incompatible change in
    the signature of some functions, notably the second argument to
    xmlStructuredErrorFunc has gained a const qualifier, changing from
    `xmlError *error` to `const xmlError *error`.

    To make the signatures compatible with both pre- and post-2.12, I have
    introduced a check on LIBXML_VERSION.

    PR:             279968
    Reported by:    dizzy

 devel/tclxml/Makefile                              |  2 +-
 devel/tclxml/files/patch-Makefile.in               | 13 ++++++++-
 devel/tclxml/files/patch-configure                 | 19 ++++++++++---
 devel/tclxml/files/patch-docObj.c (new)            | 19 +++++++++++++
 ...lude_tclxml-libxml2_tclxml-libxml2Decls.h (new) | 31 ++++++++++++++++++++++
 devel/tclxml/files/patch-tclxml.c (new)            | 11 ++++++++
 6 files changed, 90 insertions(+), 5 deletions(-)