package/znc: Fix build with SWIG 4.4
PATCH 1/2 package/znc: Fix build with SWIG 4.4
Signed-off-by Bernd Kuhls <[email protected]>
--- .../znc/0001-Fix-build-with-SWIG-4.4.patch | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 package/znc/0001-Fix-build-with-SWIG-4.4.patch
package/znc/0001-Fix-build-with-SWIG-4.4.patch new file +150 -0
@@ -0,0 +1,150 @@ +From e39adff11522e43468627aec8d315224e3057df3 Mon Sep 17 00:00:00 2001 +From: Dominique Leuenberger <[email protected]> +Date: Tue, 2 Dec 2025 11:10:27 +0100 +Subject: [PATCH] Fix build with SWIG 4.4 + +SWIG 4.4 has dropped the usage of SWIG_NULLPTR again, which means we can't +rely on its presence to identify SWIG >= 4.2.0 + +Generate a swig_version.h by parsing the output of `swig -version` and +writing this in a hex representation + +Fixes #1979 + +Upstream: https://github.com/znc/znc/commit/49af1c8d53031e83877d3a378682dee9b834123b + +Signed-off-by: Bernd Kuhls <[email protected]> +--- + modules/modpython/CMakeLists.txt | 17 ++++-- + modules/modpython/codegen.pl | 9 ++-- + modules/modpython/generate_swig_version.cmake | 53 +++++++++++++++++++ + 3 files changed, 71 insertions(+), 8 deletions(-) + create mode 100644 modules/modpython/generate_swig_version.cmake + +diff --git a/modules/modpython/CMakeLists.txt b/modules/modpython/CMakeLists.txt +index e65cc8607c..7184f42ff3 100644 +--- a/modules/modpython/CMakeLists.txt ++++ b/modules/modpython/CMakeLists.txt +@@ -29,6 +29,17 @@ if(APPLE) + endif() + + if(SWIG_FOUND) ++ set(SWIG_VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/swig_version.h") ++ ++ add_custom_command( ++ OUTPUT "${SWIG_VERSION_HEADER}" ++ COMMAND ${CMAKE_COMMAND} ++ -DSWIG_EXECUTABLE=${SWIG_EXECUTABLE} ++ -DSWIG_VERSION_HEADER=${SWIG_VERSION_HEADER} ++ -P "${CMAKE_CURRENT_SOURCE_DIR}/generate_swig_version.cmake" ++ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generate_swig_version.cmake" ++ ) ++ + add_custom_command( + OUTPUT "pyfunctions.cpp" + COMMAND "${PERL_EXECUTABLE}" +@@ -36,7 +47,7 @@ if(SWIG_FOUND) + "${CMAKE_CURRENT_SOURCE_DIR}/functions.in" + "pyfunctions.cpp" + VERBATIM +- DEPENDS codegen.pl functions.in) ++ DEPENDS codegen.pl functions.in "${SWIG_VERSION_HEADER}") + + add_custom_command( + OUTPUT "swigpyrun.h" +@@ -98,7 +109,7 @@ endfunction() + add_custom_target(modpython_dist + COMMAND "${CMAKE_COMMAND}" -E tar cz + "${CMAKE_CURRENT_SOURCE_DIR}/generated.tar.gz" +- "swigpyrun.h" "znc_core.py" "modpython_biglib.cpp" "pyfunctions.cpp" +- DEPENDS swigpyrun.h znc_core.py modpython_biglib.cpp pyfunctions.cpp ++ "swigpyrun.h" "znc_core.py" "modpython_biglib.cpp" "pyfunctions.cpp" "${SWIG_VERSION_HEADER}" ++ DEPENDS swigpyrun.h znc_core.py modpython_biglib.cpp pyfunctions.cpp "${SWIG_VERSION_HEADER}" + VERBATIM) + add_dependencies(modpython_dist copy_csocket_h) +diff --git a/modules/modpython/codegen.pl b/modules/modpython/codegen.pl +index 1f01dd8124..bbd8e2d588 100755 +--- a/modules/modpython/codegen.pl ++++ b/modules/modpython/codegen.pl +@@ -49,6 +49,8 @@ + * Don't change it manually. * + ***************************************************************************/ + ++#include "swig_version.h" ++ + namespace { + inline swig_type_info* ZNC_SWIG_pchar_descriptor(void) { + static int init = 0; +@@ -60,11 +62,8 @@ + return info; + } + +-// SWIG 4.2.0 replaced SWIG_Python_str_AsChar with SWIG_PyUnicode_AsUTF8AndSize. +-// SWIG doesn't provide any good way to detect SWIG version (other than parsing +-// `swig -version`), but it also introduced SWIG_NULLPTR in 4.2.0. +-// So let's abuse that define to do different code for new SWIG. +-#ifdef SWIG_NULLPTR ++// SWIG_VERSION is defined as 0x040200 for 4.2.0. ++#if defined(SWIG_VERSION) && SWIG_VERSION >= 0x040200 + // This is copied/adapted from SWIG 4.2.0 from pystrings.swg + inline int ZNC_SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { + #if PY_VERSION_HEX>=0x03000000 +diff --git a/modules/modpython/generate_swig_version.cmake b/modules/modpython/generate_swig_version.cmake +new file mode 100644 +index 0000000000..2d52501c62 +--- /dev/null ++++ b/modules/modpython/generate_swig_version.cmake +@@ -0,0 +1,53 @@ ++# generate_swig_version.cmake ++execute_process( ++ COMMAND ${SWIG_EXECUTABLE} -version ++ OUTPUT_VARIABLE SWIG_OUTPUT ++ ERROR_VARIABLE SWIG_ERROR ++ OUTPUT_STRIP_TRAILING_WHITESPACE ++ ERROR_STRIP_TRAILING_WHITESPACE ++) ++ ++set(FULL_OUTPUT "${SWIG_OUTPUT}\n${SWIG_ERROR}") ++ ++string(REGEX MATCH "SWIG Version ([0-9]+)\\.([0-9]+)\\.([0-9]+)" MATCH_FOUND "${FULL_OUTPUT}") ++ ++if(MATCH_FOUND) ++ # Extract capture groups ++ set(SWIG_VERSION_MAJOR ${CMAKE_MATCH_1}) ++ set(SWIG_VERSION_MINOR ${CMAKE_MATCH_2}) ++ set(SWIG_VERSION_PATCH ${CMAKE_MATCH_3}) ++ ++ message(STATUS "Found SWIG Version: ${SWIG_VERSION_MAJOR}.${SWIG_VERSION_MINOR}.${SWIG_VERSION_PATCH}") ++ ++ # Format: 0x<MAJ><MIN><PATCH> (assuming 8 bits per component) ++ # Calculation: (Major << 16) | (Minor << 8) | Patch ++ ++ math(EXPR VERSION_NUM ++ "(${SWIG_VERSION_MAJOR} << 16) + (${SWIG_VERSION_MINOR} << 8) + ${SWIG_VERSION_PATCH}" ++ OUTPUT_FORMAT HEXADECIMAL ++ ) ++ ++ set(HEADER_FILE "swig_version.h") ++ ++ file(WRITE ${SWIG_VERSION_HEADER} ++"// Auto-generated by CMake ++#ifndef SWIG_VERSION_META_H ++#define SWIG_VERSION_META_H ++ ++#define SWIG_VERSION_MAJOR ${SWIG_VERSION_MAJOR} ++#define SWIG_VERSION_MINOR ${SWIG_VERSION_MINOR} ++#define SWIG_VERSION_PATCH ${SWIG_VERSION_PATCH} ++ ++// Hex format 0xMAJMINPAT (e.g. 4.1.0 -> 0x40100) ++#define SWIG_VERSION ${VERSION_NUM} ++ ++#endif // SWIG_VERSION_META_H ++" ++ ) ++ ++ message(STATUS "Generated ${HEADER_FILE} with version ${VERSION_NUM}") ++ ++else() ++ message(WARNING "Could not parse SWIG version from output:\n${FULL_OUTPUT}") ++endif() ++
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 package/swig: bump version to 4.4.1
Release notes: https://sourceforge.net/p/swig/news/
Needed for python 3.14.
Added upstream sha1 hash.
Signed-off-by Bernd Kuhls <[email protected]>
--- package/swig/swig.hash | 4 +++- package/swig/swig.mk | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
package/swig/swig.hash +3 -1
@@ -1,5 +1,7 @@ +# From https://sourceforge.net/projects/swig/files/swig/swig-4.4.1 +sha1 da62a4e797d09bc1a1febb0618c98249d69d3557 swig-4.4.1.tar.gz # Locally computed: -sha256 2af08aced8fcd65cdb5cc62426768914bedc735b1c250325203716f78e39ac9b swig-4.1.1.tar.gz +sha256 40162a706c56f7592d08fd52ef5511cb7ac191f3593cf07306a0a554c6281fcf swig-4.4.1.tar.gz sha256 f53abaeed775018d519a1b9615f0ca17894772bd9ca21c2a156bf340ac41c13e LICENSE sha256 8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903 LICENSE-GPL sha256 7f50d942373a871211c5efee03f3db2f9efd1cff1002b0ef8e3748baa611a5c2 LICENSE-UNIVERSITIES
package/swig/swig.mk +1 -1
@@ -4,7 +4,7 @@ # ################################################################################ -SWIG_VERSION_MAJOR = 4.1 +SWIG_VERSION_MAJOR = 4.4 SWIG_VERSION = $(SWIG_VERSION_MAJOR).1 SWIG_SITE = http://downloads.sourceforge.net/project/swig/swig/swig-$(SWIG_VERSION) HOST_SWIG_DEPENDENCIES = host-bison host-pcre2
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/2] package/swig: bump version to 4.4.1
Hello Bernd,
Quoted 7 lines · On Wed, 17 Dec 2025 20:32:44 +0100 Bernd Kuhls <[email protected]> wrote:
Release notes: https://sourceforge.net/p/swig/news/
Needed for python 3.14.
Added upstream sha1 hash.
Signed-off-by Bernd Kuhls <[email protected]>
Thanks for the bump! I see in PATCH 1/2 you fixed one package that would otherwise be broken by this version bump. Are other packages likely to also be broken by this swig bump? How much testing did you do of packages that depend on host-swig?
Thanks a lot!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot