From 70ab2f6574d666e994265d540f32ecaceb5b3ed9 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Tue, 23 Jan 2024 21:57:38 -0500 Subject: [PATCH] Fix build with GCC 14 and libxml2 2.12.0 --- postgresql-libxml2.patch | 37 +++++++++++++++++++++++++++++++++++++ postgresql15-libxml2.patch | 37 +++++++++++++++++++++++++++++++++++++ postgresql16.spec | 5 +++++ 3 files changed, 79 insertions(+) create mode 100644 postgresql-libxml2.patch create mode 100644 postgresql15-libxml2.patch diff --git a/postgresql-libxml2.patch b/postgresql-libxml2.patch new file mode 100644 index 0000000..98a53f4 --- /dev/null +++ b/postgresql-libxml2.patch @@ -0,0 +1,37 @@ +Fixes for GCC 14 and libxml2 2.12.0 "error: Make more xmlError structs constant" + +xml.c: In function ‘pg_xml_init’: +xml.c:1177:52: error: passing argument 2 of ‘xmlSetStructuredErrorFunc’ from incompatible pointer type [-Wincompatible-pointer-types] + 1177 | xmlSetStructuredErrorFunc((void *) errcxt, xml_errorHandler); + | ^~~~~~~~~~~~~~~~ + | | + | void (*)(void *, xmlError *) {aka void (*)(void *, struct _xmlError *)} +In file included from /usr/include/libxml2/libxml/valid.h:15, + from /usr/include/libxml2/libxml/parser.h:19, + from xml.c:50: +/usr/include/libxml2/libxml/xmlerror.h:898:57: note: expected ‘xmlStructuredErrorFunc’ {aka ‘void (*)(void *, const struct _xmlError *)’} but argument is of type ‘void (*)(void *, xmlError *)’ {aka ‘void (*)(void *, struct _xmlError *)’} + 898 | xmlStructuredErrorFunc handler); + | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ + +diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c +index d3db75eb87..619f908c6d 100644 +--- a/src/backend/utils/adt/xml.c ++++ b/src/backend/utils/adt/xml.c +@@ -124,7 +124,7 @@ static xmlParserInputPtr xmlPgEntityLoader(const char *URL, const char *ID, + xmlParserCtxtPtr ctxt); + static void xml_errsave(Node *escontext, PgXmlErrorContext *errcxt, + int sqlcode, const char *msg); +-static void xml_errorHandler(void *data, xmlErrorPtr error); ++static void xml_errorHandler(void *data, const xmlError *error); + static int errdetail_for_xml_code(int code); + static void chopStringInfoNewlines(StringInfo str); + static void appendStringInfoLineSeparator(StringInfo str); +@@ -2044,7 +2044,7 @@ xml_errsave(Node *escontext, PgXmlErrorContext *errcxt, + * Error handler for libxml errors and warnings + */ + static void +-xml_errorHandler(void *data, xmlErrorPtr error) ++xml_errorHandler(void *data, const xmlError *error) + { + PgXmlErrorContext *xmlerrcxt = (PgXmlErrorContext *) data; + xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt; diff --git a/postgresql15-libxml2.patch b/postgresql15-libxml2.patch new file mode 100644 index 0000000..ffc87ef --- /dev/null +++ b/postgresql15-libxml2.patch @@ -0,0 +1,37 @@ +Fixes for GCC 14 and libxml2 2.12.0 "error: Make more xmlError structs constant" + +xml.c: In function ‘pg_xml_init’: +xml.c:1177:52: error: passing argument 2 of ‘xmlSetStructuredErrorFunc’ from incompatible pointer type [-Wincompatible-pointer-types] + 1177 | xmlSetStructuredErrorFunc((void *) errcxt, xml_errorHandler); + | ^~~~~~~~~~~~~~~~ + | | + | void (*)(void *, xmlError *) {aka void (*)(void *, struct _xmlError *)} +In file included from /usr/include/libxml2/libxml/valid.h:15, + from /usr/include/libxml2/libxml/parser.h:19, + from xml.c:50: +/usr/include/libxml2/libxml/xmlerror.h:898:57: note: expected ‘xmlStructuredErrorFunc’ {aka ‘void (*)(void *, const struct _xmlError *)’} but argument is of type ‘void (*)(void *, xmlError *)’ {aka ‘void (*)(void *, struct _xmlError *)’} + 898 | xmlStructuredErrorFunc handler); + | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ + +diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c +index 6411f56b99..0eb39fcfc2 100644 +--- a/src/backend/utils/adt/xml.c ++++ b/src/backend/utils/adt/xml.c +@@ -119,7 +119,7 @@ struct PgXmlErrorContext + + static xmlParserInputPtr xmlPgEntityLoader(const char *URL, const char *ID, + xmlParserCtxtPtr ctxt); +-static void xml_errorHandler(void *data, xmlErrorPtr error); ++static void xml_errorHandler(void *data, const xmlError *error); + static void xml_ereport_by_code(int level, int sqlcode, + const char *msg, int errcode); + static void chopStringInfoNewlines(StringInfo str); +@@ -1749,7 +1749,7 @@ xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode, const char *msg) + * Error handler for libxml errors and warnings + */ + static void +-xml_errorHandler(void *data, xmlErrorPtr error) ++xml_errorHandler(void *data, const xmlError *error) + { + PgXmlErrorContext *xmlerrcxt = (PgXmlErrorContext *) data; + xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt; diff --git a/postgresql16.spec b/postgresql16.spec index e1a04f6..73943e9 100644 --- a/postgresql16.spec +++ b/postgresql16.spec @@ -95,6 +95,8 @@ Patch9: postgresql-server-pg_config.patch # rhbz#1940964 Patch10: postgresql-datalayout-mismatch-on-s390.patch Patch12: postgresql-no-libecpg.patch +Patch13: postgresql-libxml2.patch +Patch14: postgresql15-libxml2.patch # This macro is used for package names in the files section %if %?postgresql_default @@ -533,6 +535,7 @@ goal of accelerating analytics queries. %endif %patch 9 -p1 %patch 10 -p1 +%patch 13 -p1 %if ! %external_libpq @@ -549,6 +552,8 @@ tar xfj %{SOURCE3} find . -type f -name Makefile -exec sed -i -e "s/SO_MAJOR_VERSION=\s\?\([0-9]\+\)/SO_MAJOR_VERSION= %{private_soname}-\1/" {} \; %endif +%patch 14 -p1 -d postgresql-%{prevversion} + # apply once SOURCE3 is extracted %endif