swig: upgrade 4.4.1 -> 4.5.0
PATCH 1/1 swig: upgrade 4.4.1 -> 4.5.0
ChangeLog: https://www.swig.org/Release/CHANGES.current
Release Notes: https://www.swig.org/Release/RELEASENOTES
CompareLog: https://github.com/swig/swig/compare/v4.4.1...v4.5.0
- Refresh determinism.patch
---
.../swig/swig/determinism.patch | 20 +++++++++----------
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++--
2 files changed, 12 insertions(+), 12 deletions(-)
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)meta/recipes-devtools/swig/swig/determinism.patch +10 -10
@@ -1,26 +1,26 @@ -From 7df78bedb666e49131c48f1854c6be1597bd133c Mon Sep 17 00:00:00 2001 +From 218e2a20ff978cb28fefdf7b35af8a27768df4db Mon Sep 17 00:00:00 2001 From: Richard Purdie <[email protected]> -Date: Mon, 1 Mar 2021 00:11:10 +0000 +Date: Mon, 10 Aug 2026 11:13:20 +0000 Subject: [PATCH] swig: Fix reproducibility issue Remove the compiler commandline/platform from the compiled binary as this breaks reproducibilty. -Upstream-Status: Inappropriate [OE reproducibiity fix upstream unlikely to take] +Upstream-Status: Inappropriate [OE reproducibility fix upstream unlikely to take] RP 2021/3/1 --- Source/Modules/main.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx -index f68b609..0c2aba3 100644 +index 83ab22a..79a513a 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx -@@ -633,7 +633,6 @@ static void getoptions(int argc, char *argv[]) { - } +@@ -642,7 +642,6 @@ static void getoptions(int argc, char *argv[]) { + } } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[1], "--version") == 0) { - fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); -- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); - fprintf(stdout, "\nConfigured options: %cpcre\n", + fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); +- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); + fprintf(stdout, + "\nConfigured options: %cpcre\n", #ifdef HAVE_PCRE - '+'
meta/recipes-devtools/swig/swig_4.5.0.bb renamed from meta/recipes-devtools/swig/swig_4.4.1.bb +2 -2
@@ -13,9 +13,9 @@ SECTION = "devel" DEPENDS = "libpcre2 bison-native" SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \ - file://determinism.patch \ + file://determinism.patch \ " -SRC_URI[sha256sum] = "40162a706c56f7592d08fd52ef5511cb7ac191f3593cf07306a0a554c6281fcf" +SRC_URI[sha256sum] = "22ae0e887f8cca8031a325c67d005207653200b40e71edb3f88780e28e47d0ff" UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/swig/files/swig/" UPSTREAM_CHECK_REGEX = "swig-(?P<pver>\d+(\.\d+)+)"
Quoted 6 lines · Jaipaul Cheernam via lists.openembedded.org
ChangeLog: https://www.swig.org/Release/CHANGES.current
Release Notes: https://www.swig.org/Release/RELEASENOTES
CompareLog: https://github.com/swig/swig/compare/v4.4.1...v4.5.0
Quoted 8 lines
- Refresh determinism.patch
Signed-off-by Jaipaul Cheernam <[email protected]>---
.../swig/swig/determinism.patch | 20 +++++++++---------- .../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++--2 files changed, 12 insertions(+), 12 deletions(-)rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)
Seems to break babeltrace2, e.g.:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/22/builds/4362
Cheers,
Richard
v2 cover swig: upgrade 4.4.1 -> 4.5.0
In reply to Jaipaul CheernamUpgrade swig to 4.5.0 and fix babeltrace2 build breakage caused by removal of Python 2 compatibility macros in the new swig version.
Changes in v2:
- Added babeltrace2 patch to fix SWIG 4.5.0 compatibility
Jaipaul Cheernam (2):
swig: upgrade 4.4.1 -> 4.5.0
babeltrace2: fix build with swig 4.5.0
.../swig/swig/determinism.patch | 20 +++---
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 +-
...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++
.../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 +
4 files changed, 83 insertions(+), 12 deletions(-)
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)
create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patchPATCH v2 1/2 swig: upgrade 4.4.1 -> 4.5.0
ChangeLog: https://www.swig.org/Release/CHANGES.current
Release Notes: https://www.swig.org/Release/RELEASENOTES
CompareLog: https://github.com/swig/swig/compare/v4.4.1...v4.5.0
- Refresh determinism.patch
---
.../swig/swig/determinism.patch | 20 +++++++++----------
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++--
2 files changed, 12 insertions(+), 12 deletions(-)
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)meta/recipes-devtools/swig/swig/determinism.patch +10 -10
@@ -1,26 +1,26 @@ -From 7df78bedb666e49131c48f1854c6be1597bd133c Mon Sep 17 00:00:00 2001 +From 218e2a20ff978cb28fefdf7b35af8a27768df4db Mon Sep 17 00:00:00 2001 From: Richard Purdie <[email protected]> -Date: Mon, 1 Mar 2021 00:11:10 +0000 +Date: Mon, 10 Aug 2026 11:13:20 +0000 Subject: [PATCH] swig: Fix reproducibility issue Remove the compiler commandline/platform from the compiled binary as this breaks reproducibilty. -Upstream-Status: Inappropriate [OE reproducibiity fix upstream unlikely to take] +Upstream-Status: Inappropriate [OE reproducibility fix upstream unlikely to take] RP 2021/3/1 --- Source/Modules/main.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx -index f68b609..0c2aba3 100644 +index 83ab22a..79a513a 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx -@@ -633,7 +633,6 @@ static void getoptions(int argc, char *argv[]) { - } +@@ -642,7 +642,6 @@ static void getoptions(int argc, char *argv[]) { + } } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[1], "--version") == 0) { - fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); -- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); - fprintf(stdout, "\nConfigured options: %cpcre\n", + fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); +- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); + fprintf(stdout, + "\nConfigured options: %cpcre\n", #ifdef HAVE_PCRE - '+'
meta/recipes-devtools/swig/swig_4.5.0.bb renamed from meta/recipes-devtools/swig/swig_4.4.1.bb +2 -2
@@ -13,9 +13,9 @@ SECTION = "devel" DEPENDS = "libpcre2 bison-native" SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \ - file://determinism.patch \ + file://determinism.patch \ " -SRC_URI[sha256sum] = "40162a706c56f7592d08fd52ef5511cb7ac191f3593cf07306a0a554c6281fcf" +SRC_URI[sha256sum] = "22ae0e887f8cca8031a325c67d005207653200b40e71edb3f88780e28e47d0ff" UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/swig/files/swig/" UPSTREAM_CHECK_REGEX = "swig-(?P<pver>\d+(\.\d+)+)"
Quoted 6 lines · Jaipaul Cheernam via lists.openembedded.org
ChangeLog: https://www.swig.org/Release/CHANGES.current
Release Notes: https://www.swig.org/Release/RELEASENOTES
CompareLog: https://github.com/swig/swig/compare/v4.4.1...v4.5.0
Quoted 8 lines
- Refresh determinism.patch
Signed-off-by Jaipaul Cheernam <[email protected]>---
.../swig/swig/determinism.patch | 20 +++++++++---------- .../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++--2 files changed, 12 insertions(+), 12 deletions(-)rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)
I suspect this breaks u-boot-tools:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/25/builds/4370
https://autobuilder.yoctoproject.org/valkyrie/#/builders/17/builds/4214
and maybe python3-dtc:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/89/builds/4188
Cheers,
Richard
Hi Richard,
I will send v3 by fixing dtc and u-boot-tools.
Note: The following recipes in meta-openembedded may also be affected if python/swig bindings are enabled:
- gensio (meta-oe): fix available upstream [1]
- unbound (meta-networking): fix available upstream [2]
- ldns (meta-oe): fix pending upstream [3]
[1]https://github.com/cminyard/gensio/commit/e024df7fc3d21896bd9d2e26964a0b59b7c2a91b [2]https://github.com/NLnetLabs/unbound/commit/93a56205cfa6b9a6d34db7245aa71e5ca67d1fd7 [3]https://github.com/NLnetLabs/ldns/issues/314
As they are not enabled now, will not provide a fix.
Regards,
Jaipaul
Quoted 27 lines · Richard Purdie
Quoted 6 lines · Jaipaul Cheernam via lists.openembedded.org
ChangeLog:https://www.swig.org/Release/CHANGES.current
Release Notes:https://www.swig.org/Release/RELEASENOTES
CompareLog:https://github.com/swig/swig/compare/v4.4.1...v4.5.0
Quoted 8 lines
- Refresh determinism.patch
Signed-off-by Jaipaul Cheernam<[email protected]>--- .../swig/swig/determinism.patch | 20 +++++++++---------- .../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-)rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)
I suspect this breaks u-boot-tools:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/25/builds/4370
https://autobuilder.yoctoproject.org/valkyrie/#/builders/17/builds/4214and maybe python3-dtc:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/89/builds/4188
Cheers,
Richard
PATCH v2 2/2 babeltrace2: fix build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2/3 compatibility macros PyString_FromString and SWIG_Python_str_FromChar. Backport upstream fix that replaces both with PyUnicode_FromString.
--- ...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++ .../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 + 2 files changed, 71 insertions(+) create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch new file +70 -0
@@ -0,0 +1,70 @@ +From 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3 Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Mon, 28 Jul 2026 13:29:18 +0000 +Subject: [PATCH] bt2: replace removed Python 2 C API macros for SWIG 4.5.0 + compatibility + +SWIG 4.5.0 has removed some Python 2/3 compatibility macros. The two +that affect us are `PyString_FromString` and +`SWIG_Python_str_FromChar`, which are both replaced with +`PyUnicode_FromString`. + +Change-Id: I3c74d8ea7257d9cdc0fa4b533ae7b3a5ef9521d1 +Signed-off-by: Simon Marchi <[email protected]> +Signed-off-by: Jitka Plesnikova <[email protected]> +Reviewed-on: https://review.lttng.org/c/babeltrace/+/18423 +Tested-by: jenkins <[email protected]> +(cherry picked from commit 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3) + +Upstream-Status: Backport [https://github.com/efficios/babeltrace/commit/1c59884d4d] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + src/bindings/python/bt2/bt2/native_bt.i | 4 ++-- + src/bindings/python/bt2/bt2/native_bt_error.i.hpp | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i +index 7f8d9f699..1807d8ff6 100644 +--- a/src/bindings/python/bt2/bt2/native_bt.i ++++ b/src/bindings/python/bt2/bt2/native_bt.i +@@ -56,7 +56,7 @@ typedef uint64_t bt_listener_id; + * + * We initialize the output parameter `temp_value` to an invalid but non-zero + * pointer value. This is to make sure we don't rely on its initial value in +- * the epilogue (where we call SWIG_Python_str_FromChar). When they fail, ++ * the epilogue (where we call PyUnicode_FromString). When they fail, + * functions on which we apply this typemap don't guarantee that the value of + * `temp_value` will be unchanged or valid. + */ +@@ -67,7 +67,7 @@ typedef uint64_t bt_listener_id; + %typemap(argout) (const char **) { + if (*$1) { + /* SWIG_AppendOutput() steals the created object */ +- $result = SWIG_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); ++ $result = SWIG_AppendOutput($result, PyUnicode_FromString(*$1)); + } else { + /* SWIG_AppendOutput() steals Py_None */ + Py_INCREF(Py_None); +diff --git a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +index ba8cef097..2be1e347c 100644 +--- a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp ++++ b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +@@ -19,7 +19,7 @@ static PyObject *bt_bt2_format_bt_error_cause(const bt_error_cause *error_cause) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_cause_str); + +- py_error_cause_str = PyString_FromString(error_cause_str); ++ py_error_cause_str = PyUnicode_FromString(error_cause_str); + + g_free(error_cause_str); + +@@ -35,7 +35,7 @@ static PyObject *bt_bt2_format_bt_error(const bt_error *error) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_str); + +- py_error_str = PyString_FromString(error_str); ++ py_error_str = PyUnicode_FromString(error_str); + + g_free(error_str); +
meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb +1 -0
@@ -15,6 +15,7 @@ SRC_URI = "git://git.efficios.com/babeltrace.git;branch=stable-2.1;protocol=http file://0001-Make-bt_field_blob_get_length-return-size_t-instead-.patch \ file://external-python-tests.patch \ file://0001-src-explicitly-only-build-shared-plugins.patch \ + file://0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch \ " SRCREV = "d0e946a71faf5f0c2d7f1fb5b92a369983e9cf10" UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>2(\.\d+)+)$"
v3 cover swig: upgrade 4.4.1 -> 4.5.0
In reply to Jaipaul CheernamUpgrade swig to 4.5.0 and fix build breakage in recipes that used Python 2 C API macros removed in swig 4.5.0.
Note: The following recipes in meta-openembedded may also be affected if python/swig bindings are enabled:
- gensio (meta-oe): fix available upstream [1]
- unbound (meta-networking): fix available upstream [2]
- ldns (meta-oe): fix pending upstream [3]
[1] https://github.com/cminyard/gensio/commit/e024df7fc3d21896bd9d2e26964a0b59b7c2a91b
[2] https://github.com/NLnetLabs/unbound/commit/93a56205cfa6b9a6d34db7245aa71e5ca67d1fd7
[3] https://github.com/NLnetLabs/ldns/issues/314
Changes in v3:
- Added u-boot-tools and python3-dtc patches to fix pylibfdt build
Changes in v2:
- Added babeltrace2 patch to fix SWIG 4.5.0 compatibility
Jaipaul Cheernam (4):
swig: upgrade 4.4.1 -> 4.5.0
babeltrace2: fix build with swig 4.5.0
u-boot-tools: fix pylibfdt build with swig 4.5.0
python3-dtc: fix build with swig 4.5.0
...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++
.../u-boot/u-boot-tools_2026.07.bb | 4 +-
...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++
.../python/python3-dtc_1.8.1.bb | 1 +
.../swig/swig/determinism.patch | 20 +++---
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 +-
...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++
.../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 +
8 files changed, 201 insertions(+), 13 deletions(-)
create mode 100644 meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
create mode 100644 meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)
create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patchPATCH v3 1/4 swig: upgrade 4.4.1 -> 4.5.0
ChangeLog: https://www.swig.org/Release/CHANGES.current
Release Notes: https://www.swig.org/Release/RELEASENOTES
CompareLog: https://github.com/swig/swig/compare/v4.4.1...v4.5.0
- Refresh determinism.patch
---
.../swig/swig/determinism.patch | 20 +++++++++----------
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++--
2 files changed, 12 insertions(+), 12 deletions(-)
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)meta/recipes-devtools/swig/swig/determinism.patch +10 -10
@@ -1,26 +1,26 @@ -From 7df78bedb666e49131c48f1854c6be1597bd133c Mon Sep 17 00:00:00 2001 +From 218e2a20ff978cb28fefdf7b35af8a27768df4db Mon Sep 17 00:00:00 2001 From: Richard Purdie <[email protected]> -Date: Mon, 1 Mar 2021 00:11:10 +0000 +Date: Mon, 10 Aug 2026 11:13:20 +0000 Subject: [PATCH] swig: Fix reproducibility issue Remove the compiler commandline/platform from the compiled binary as this breaks reproducibilty. -Upstream-Status: Inappropriate [OE reproducibiity fix upstream unlikely to take] +Upstream-Status: Inappropriate [OE reproducibility fix upstream unlikely to take] RP 2021/3/1 --- Source/Modules/main.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx -index f68b609..0c2aba3 100644 +index 83ab22a..79a513a 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx -@@ -633,7 +633,6 @@ static void getoptions(int argc, char *argv[]) { - } +@@ -642,7 +642,6 @@ static void getoptions(int argc, char *argv[]) { + } } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[1], "--version") == 0) { - fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); -- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); - fprintf(stdout, "\nConfigured options: %cpcre\n", + fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); +- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); + fprintf(stdout, + "\nConfigured options: %cpcre\n", #ifdef HAVE_PCRE - '+'
meta/recipes-devtools/swig/swig_4.5.0.bb renamed from meta/recipes-devtools/swig/swig_4.4.1.bb +2 -2
@@ -13,9 +13,9 @@ SECTION = "devel" DEPENDS = "libpcre2 bison-native" SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \ - file://determinism.patch \ + file://determinism.patch \ " -SRC_URI[sha256sum] = "40162a706c56f7592d08fd52ef5511cb7ac191f3593cf07306a0a554c6281fcf" +SRC_URI[sha256sum] = "22ae0e887f8cca8031a325c67d005207653200b40e71edb3f88780e28e47d0ff" UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/swig/files/swig/" UPSTREAM_CHECK_REGEX = "swig-(?P<pver>\d+(\.\d+)+)"
PATCH v3 2/4 babeltrace2: fix build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2/3 compatibility macros PyString_FromString and SWIG_Python_str_FromChar. Backport upstream fix that replaces both with PyUnicode_FromString.
--- ...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++ .../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 + 2 files changed, 71 insertions(+) create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch new file +70 -0
@@ -0,0 +1,70 @@ +From 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3 Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Mon, 28 Jul 2026 13:29:18 +0000 +Subject: [PATCH] bt2: replace removed Python 2 C API macros for SWIG 4.5.0 + compatibility + +SWIG 4.5.0 has removed some Python 2/3 compatibility macros. The two +that affect us are `PyString_FromString` and +`SWIG_Python_str_FromChar`, which are both replaced with +`PyUnicode_FromString`. + +Change-Id: I3c74d8ea7257d9cdc0fa4b533ae7b3a5ef9521d1 +Signed-off-by: Simon Marchi <[email protected]> +Signed-off-by: Jitka Plesnikova <[email protected]> +Reviewed-on: https://review.lttng.org/c/babeltrace/+/18423 +Tested-by: jenkins <[email protected]> +(cherry picked from commit 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3) + +Upstream-Status: Backport [https://github.com/efficios/babeltrace/commit/1c59884d4d] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + src/bindings/python/bt2/bt2/native_bt.i | 4 ++-- + src/bindings/python/bt2/bt2/native_bt_error.i.hpp | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i +index 7f8d9f699..1807d8ff6 100644 +--- a/src/bindings/python/bt2/bt2/native_bt.i ++++ b/src/bindings/python/bt2/bt2/native_bt.i +@@ -56,7 +56,7 @@ typedef uint64_t bt_listener_id; + * + * We initialize the output parameter `temp_value` to an invalid but non-zero + * pointer value. This is to make sure we don't rely on its initial value in +- * the epilogue (where we call SWIG_Python_str_FromChar). When they fail, ++ * the epilogue (where we call PyUnicode_FromString). When they fail, + * functions on which we apply this typemap don't guarantee that the value of + * `temp_value` will be unchanged or valid. + */ +@@ -67,7 +67,7 @@ typedef uint64_t bt_listener_id; + %typemap(argout) (const char **) { + if (*$1) { + /* SWIG_AppendOutput() steals the created object */ +- $result = SWIG_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); ++ $result = SWIG_AppendOutput($result, PyUnicode_FromString(*$1)); + } else { + /* SWIG_AppendOutput() steals Py_None */ + Py_INCREF(Py_None); +diff --git a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +index ba8cef097..2be1e347c 100644 +--- a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp ++++ b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +@@ -19,7 +19,7 @@ static PyObject *bt_bt2_format_bt_error_cause(const bt_error_cause *error_cause) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_cause_str); + +- py_error_cause_str = PyString_FromString(error_cause_str); ++ py_error_cause_str = PyUnicode_FromString(error_cause_str); + + g_free(error_cause_str); + +@@ -35,7 +35,7 @@ static PyObject *bt_bt2_format_bt_error(const bt_error *error) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_str); + +- py_error_str = PyString_FromString(error_str); ++ py_error_str = PyUnicode_FromString(error_str); + + g_free(error_str); +
meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb +1 -0
@@ -15,6 +15,7 @@ SRC_URI = "git://git.efficios.com/babeltrace.git;branch=stable-2.1;protocol=http file://0001-Make-bt_field_blob_get_length-return-size_t-instead-.patch \ file://external-python-tests.patch \ file://0001-src-explicitly-only-build-shared-plugins.patch \ + file://0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch \ " SRCREV = "d0e946a71faf5f0c2d7f1fb5b92a369983e9cf10" UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>2(\.\d+)+)$"
PATCH v3 3/4 u-boot-tools: fix pylibfdt build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the dtc upstream fix to u-boot's bundled pylibfdt/libfdt.i to replace them with Python 3 equivalents.
--- ...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++++++ .../u-boot/u-boot-tools_2026.07.bb | 4 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +57 -0
@@ -0,0 +1,57 @@ +From 32378d7b4383a79d13da9005035600d8f0c8c29d Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Tue, 29 Jul 2026 05:55:56 +0000 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong + +The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +Signed-off-by: Jitka Plesnikova <[email protected]> +Signed-off-by: Peter Robinson <[email protected]> +Signed-off-by: David Gibson <[email protected]> +(cherry picked from commit 5008d1d6a356b8d0a78060da2e1021507d529cff) + +Upstream-Status: Backport [https://github.com/dgibson/dtc/commit/5008d1d6a356b8d0a78060da2e1021507d529cff] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + scripts/dtc/pylibfdt/libfdt.i | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/scripts/dtc/pylibfdt/libfdt.i b/scripts/dtc/pylibfdt/libfdt.i +index 1f9c0471..b1cb9873 100644 +--- a/scripts/dtc/pylibfdt/libfdt.i ++++ b/scripts/dtc/pylibfdt/libfdt.i +@@ -1136,7 +1136,7 @@ typedef uint32_t fdt32_t; + PyObject *buff; + + if ($1) { +- resultobj = PyString_FromString( ++ resultobj = PyUnicode_FromString( + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +@@ -1169,13 +1169,13 @@ typedef uint32_t fdt32_t; + } + $1 = PyBytes_AsString($input); + %#else +- $1 = PyString_AsString($input); /* char *str */ ++ $1 = PyBytes_AsString($input); /* char *str */ + %#endif + } + + /* typemaps used for fdt_next_node() */ + %typemap(in, numinputs=1) int *depth (int depth) { +- depth = (int) PyInt_AsLong($input); ++ depth = (int) PyLong_AsLong($input); + $1 = &depth; + } +
meta/recipes-bsp/u-boot/u-boot-tools_2026.07.bb +3 -1
@@ -1,4 +1,6 @@ require u-boot-common.inc require u-boot-tools.inc -SRC_URI += "file://0001-tools-mkeficapsule-Detect-GnuTLS-PKCS-11-support.patch" +SRC_URI += "file://0001-tools-mkeficapsule-Detect-GnuTLS-PKCS-11-support.patch \ + file://0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch \ + "
Re: [OE-core] [PATCH v3 3/4] u-boot-tools: fix pylibfdt build with swig 4.5.0
Quoted 6 lines · Jaipaul Cheernam
SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the dtc upstream fix to u-boot's bundled pylibfdt/libfdt.i to replace them with Python 3 equivalents.
Signed-off-by Jaipaul Cheernam <[email protected]>---
Hi Jaipaul,
Thanks for your patch.
Can you confirm this is based on today master? The u-boot patch fails to apply on my side:
ERROR: u-boot-tools-1_2026.07-r0 do_patch: Applying patch '/srv/pokybuild/yocto-worker/musl-qemux86-64/build/layers/openembedded-core/meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch' on target directory '/srv/pokybuild/yocto-worker/musl-qemux86-64/build/build/tmp/work/x86-64-v3-poky-linux-musl/u-boot-tools/2026.07/sources/u-boot-tools-2026.07' CmdError('quilt --quiltrc /srv/pokybuild/yocto-worker/musl-qemux86-64/build/build/tmp/work/x86-64-v3-poky-linux-musl/u-boot-tools/2026.07/recipe-sysroot-native/etc/quiltrc push', 1, "stdout: Applying patch 0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
can't find file to patch at input line 33
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|From 32378d7b4383a79d13da9005035600d8f0c8c29d Mon Sep 17 00:00:00 2001 |From: Jitka Plesnikova <[email protected]> |Date: Tue, 29 Jul 2026 05:55:56 +0000 |Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros | |SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) |from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace |them with their Python 3 C API equivalents: | |- PyString_FromString -> PyUnicode_FromString |- PyString_AsString -> PyBytes_AsString |- PyInt_AsLong -> PyLong_AsLong | |The replacements are safe since the macros were already aliased to |these exact functions in SWIG's Python 3 code path. | |Signed-off-by: Jitka Plesnikova <[email protected]> |Signed-off-by: Peter Robinson <[email protected]> |Signed-off-by: David Gibson <[email protected]> |(cherry picked from commit 5008d1d6a356b8d0a78060da2e1021507d529cff) | |Upstream-Status: Backport [https://github.com/dgibson/dtc/commit/5008d1d6a356b8d0a78060da2e1021507d529cff] | |Signed-off-by: Jaipaul Cheernam <[email protected]> |--- | scripts/dtc/pylibfdt/libfdt.i | 6 +++--- | 1 file changed, 3 insertions(+), 3 deletions(-) | |diff --git a/scripts/dtc/pylibfdt/libfdt.i b/scripts/dtc/pylibfdt/libfdt.i |index 1f9c0471..b1cb9873 100644 |--- a/scripts/dtc/pylibfdt/libfdt.i |+++ b/scripts/dtc/pylibfdt/libfdt.i
--------------------------
No file to patch. Skipping patch.
2 out of 2 hunks ignored
Patch 0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch does not apply (enforce with -f)
https://autobuilder.yoctoproject.org/valkyrie/#/builders/17/builds/4216
https://autobuilder.yoctoproject.org/valkyrie/#/builders/3/builds/4423
Thanks,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [OE-core] [PATCH v3 3/4] u-boot-tools: fix pylibfdt build with swig 4.5.0
In reply to Jaipaul CheernamHi Jaipaul,
Quoted 30 lines · Jaipaul Cheernam via lists.openembedded.org
SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the dtc upstream fix to u-boot's bundled pylibfdt/libfdt.i to replace them with Python 3 equivalents.
Signed-off-by Jaipaul Cheernam <[email protected]>--- ...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++++++ .../u-boot/u-boot-tools_2026.07.bb | 4 +- 2 files changed, 60 insertions(+), 1 deletion(-)create mode 100644
meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patchmeta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +13
-0@@ -0,0 +1,57 @@ +From 32378d7b4383a79d13da9005035600d8f0c8c29d Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Tue, 29 Jul 2026 05:55:56 +0000 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong +
meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch line 23
Quoted 10 lines
meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +10
-0+The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +Signed-off-by: Jitka Plesnikova <[email protected]> +Signed-off-by: Peter Robinson <[email protected]> +Signed-off-by: David Gibson <[email protected]> +(cherry picked from commit 5008d1d6a356b8d0a78060da2e1021507d529cff) + +Upstream-Status: Backport [https://github.com/dgibson/dtc/commit/5008d1d6a356b8d0a78060da2e1021507d529cff] +
Not a backport. This commit doesn't exist in U-Boot. Please work with upstream U-Boot on fixing this so that other build systems/distros don't need to duplicate the work and we don't have to carry this patch forever in Yocto.
Cheers,
Quentin
PATCH v3 4/4 python3-dtc: fix build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the upstream fix to replace them with Python 3 equivalents.
--- ...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++++++ .../python/python3-dtc_1.8.1.bb | 1 + 2 files changed, 58 insertions(+) create mode 100644 meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +57 -0
@@ -0,0 +1,57 @@ +From 32378d7b4383a79d13da9005035600d8f0c8c29d Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Tue, 29 Jul 2026 05:55:56 +0000 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong + +The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +Signed-off-by: Jitka Plesnikova <[email protected]> +Signed-off-by: Peter Robinson <[email protected]> +Signed-off-by: David Gibson <[email protected]> +(cherry picked from commit 5008d1d6a356b8d0a78060da2e1021507d529cff) + +Upstream-Status: Backport [https://github.com/dgibson/dtc/commit/5008d1d6a356b8d0a78060da2e1021507d529cff] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + pylibfdt/libfdt.i | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i +index 1f9c0471..b1cb9873 100644 +--- a/pylibfdt/libfdt.i ++++ b/pylibfdt/libfdt.i +@@ -1136,7 +1136,7 @@ typedef uint32_t fdt32_t; + PyObject *buff; + + if ($1) { +- resultobj = PyString_FromString( ++ resultobj = PyUnicode_FromString( + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +@@ -1169,13 +1169,13 @@ typedef uint32_t fdt32_t; + } + $1 = PyBytes_AsString($input); + %#else +- $1 = PyString_AsString($input); /* char *str */ ++ $1 = PyBytes_AsString($input); /* char *str */ + %#endif + } + + /* typemaps used for fdt_next_node() */ + %typemap(in, numinputs=1) int *depth (int depth) { +- depth = (int) PyInt_AsLong($input); ++ depth = (int) PyLong_AsLong($input); + $1 = &depth; + } +
meta/recipes-devtools/python/python3-dtc_1.8.1.bb +1 -0
@@ -7,6 +7,7 @@ LICENSE = "BSD-2-Clause OR GPL-2.0-only" DEPENDS = "flex-native bison-native swig-native python3-setuptools-scm-native libyaml dtc" SRC_URI = "git://git.kernel.org/pub/scm/utils/dtc/dtc.git;branch=main;protocol=https;tag=v${PV} \ + file://0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch \ " UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"
v4 cover swig: upgrade 4.4.1 -> 4.5.0
In reply to Jaipaul CheernamUpgrade swig to 4.5.0 and fix build breakage in recipes that used Python 2 C API macros removed in swig 4.5.0.
Note: The following recipes in meta-openembedded may also be affected if python/swig bindings are enabled:
- gensio (meta-oe): fix available upstream [1]
- unbound (meta-networking): fix available upstream [2]
- ldns (meta-oe): fix pending upstream [3]
[1] https://github.com/cminyard/gensio/commit/e024df7fc3d21896bd9d2e26964a0b59b7c2a91b
[2] https://github.com/NLnetLabs/unbound/commit/93a56205cfa6b9a6d34db7245aa71e5ca67d1fd7
[3] https://github.com/NLnetLabs/ldns/issues/314
Changes in v4:
- Fixed u-boot-tools patch path (libfdt.i_shipped, not libfdt.i)
- Submitted fix to u-boot upstream [4]
[4] https://patchwork.ozlabs.org/patch/2283713/
Changes in v3:
- Added u-boot-tools and python3-dtc patches to fix pylibfdt build
Changes in v2:
- Added babeltrace2 patch to fix SWIG 4.5.0 compatibility
Jaipaul Cheernam (4):
swig: upgrade 4.4.1 -> 4.5.0
babeltrace2: fix build with swig 4.5.0
u-boot-tools: fix pylibfdt build with swig 4.5.0
python3-dtc: fix build with swig 4.5.0
...-removed-SWIG-Python-2-compatibility.patch | 55 +++++++++++++++
.../u-boot/u-boot-tools_2026.07.bb | 4 +-
...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++
.../python/python3-dtc_1.8.1.bb | 1 +
.../swig/swig/determinism.patch | 20 +++---
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 +-
...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++
.../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 +
8 files changed, 199 insertions(+), 13 deletions(-)
create mode 100644 meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
create mode 100644 meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)
create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patchPATCH v4 1/4 swig: upgrade 4.4.1 -> 4.5.0
ChangeLog: https://www.swig.org/Release/CHANGES.current
Release Notes: https://www.swig.org/Release/RELEASENOTES
CompareLog: https://github.com/swig/swig/compare/v4.4.1...v4.5.0
- Refresh determinism.patch
---
.../swig/swig/determinism.patch | 20 +++++++++----------
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++--
2 files changed, 12 insertions(+), 12 deletions(-)
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)meta/recipes-devtools/swig/swig/determinism.patch +10 -10
@@ -1,26 +1,26 @@ -From 7df78bedb666e49131c48f1854c6be1597bd133c Mon Sep 17 00:00:00 2001 +From 218e2a20ff978cb28fefdf7b35af8a27768df4db Mon Sep 17 00:00:00 2001 From: Richard Purdie <[email protected]> -Date: Mon, 1 Mar 2021 00:11:10 +0000 +Date: Mon, 10 Aug 2026 11:13:20 +0000 Subject: [PATCH] swig: Fix reproducibility issue Remove the compiler commandline/platform from the compiled binary as this breaks reproducibilty. -Upstream-Status: Inappropriate [OE reproducibiity fix upstream unlikely to take] +Upstream-Status: Inappropriate [OE reproducibility fix upstream unlikely to take] RP 2021/3/1 --- Source/Modules/main.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx -index f68b609..0c2aba3 100644 +index 83ab22a..79a513a 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx -@@ -633,7 +633,6 @@ static void getoptions(int argc, char *argv[]) { - } +@@ -642,7 +642,6 @@ static void getoptions(int argc, char *argv[]) { + } } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[1], "--version") == 0) { - fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); -- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); - fprintf(stdout, "\nConfigured options: %cpcre\n", + fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); +- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); + fprintf(stdout, + "\nConfigured options: %cpcre\n", #ifdef HAVE_PCRE - '+'
meta/recipes-devtools/swig/swig_4.5.0.bb renamed from meta/recipes-devtools/swig/swig_4.4.1.bb +2 -2
@@ -13,9 +13,9 @@ SECTION = "devel" DEPENDS = "libpcre2 bison-native" SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \ - file://determinism.patch \ + file://determinism.patch \ " -SRC_URI[sha256sum] = "40162a706c56f7592d08fd52ef5511cb7ac191f3593cf07306a0a554c6281fcf" +SRC_URI[sha256sum] = "22ae0e887f8cca8031a325c67d005207653200b40e71edb3f88780e28e47d0ff" UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/swig/files/swig/" UPSTREAM_CHECK_REGEX = "swig-(?P<pver>\d+(\.\d+)+)"
PATCH v4 2/4 babeltrace2: fix build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2/3 compatibility macros PyString_FromString and SWIG_Python_str_FromChar. Backport upstream fix that replaces both with PyUnicode_FromString.
--- ...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++ .../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 + 2 files changed, 71 insertions(+) create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch new file +70 -0
@@ -0,0 +1,70 @@ +From 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3 Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Mon, 28 Jul 2026 13:29:18 +0000 +Subject: [PATCH] bt2: replace removed Python 2 C API macros for SWIG 4.5.0 + compatibility + +SWIG 4.5.0 has removed some Python 2/3 compatibility macros. The two +that affect us are `PyString_FromString` and +`SWIG_Python_str_FromChar`, which are both replaced with +`PyUnicode_FromString`. + +Change-Id: I3c74d8ea7257d9cdc0fa4b533ae7b3a5ef9521d1 +Signed-off-by: Simon Marchi <[email protected]> +Signed-off-by: Jitka Plesnikova <[email protected]> +Reviewed-on: https://review.lttng.org/c/babeltrace/+/18423 +Tested-by: jenkins <[email protected]> +(cherry picked from commit 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3) + +Upstream-Status: Backport [https://github.com/efficios/babeltrace/commit/1c59884d4d] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + src/bindings/python/bt2/bt2/native_bt.i | 4 ++-- + src/bindings/python/bt2/bt2/native_bt_error.i.hpp | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i +index 7f8d9f699..1807d8ff6 100644 +--- a/src/bindings/python/bt2/bt2/native_bt.i ++++ b/src/bindings/python/bt2/bt2/native_bt.i +@@ -56,7 +56,7 @@ typedef uint64_t bt_listener_id; + * + * We initialize the output parameter `temp_value` to an invalid but non-zero + * pointer value. This is to make sure we don't rely on its initial value in +- * the epilogue (where we call SWIG_Python_str_FromChar). When they fail, ++ * the epilogue (where we call PyUnicode_FromString). When they fail, + * functions on which we apply this typemap don't guarantee that the value of + * `temp_value` will be unchanged or valid. + */ +@@ -67,7 +67,7 @@ typedef uint64_t bt_listener_id; + %typemap(argout) (const char **) { + if (*$1) { + /* SWIG_AppendOutput() steals the created object */ +- $result = SWIG_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); ++ $result = SWIG_AppendOutput($result, PyUnicode_FromString(*$1)); + } else { + /* SWIG_AppendOutput() steals Py_None */ + Py_INCREF(Py_None); +diff --git a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +index ba8cef097..2be1e347c 100644 +--- a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp ++++ b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +@@ -19,7 +19,7 @@ static PyObject *bt_bt2_format_bt_error_cause(const bt_error_cause *error_cause) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_cause_str); + +- py_error_cause_str = PyString_FromString(error_cause_str); ++ py_error_cause_str = PyUnicode_FromString(error_cause_str); + + g_free(error_cause_str); + +@@ -35,7 +35,7 @@ static PyObject *bt_bt2_format_bt_error(const bt_error *error) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_str); + +- py_error_str = PyString_FromString(error_str); ++ py_error_str = PyUnicode_FromString(error_str); + + g_free(error_str); +
meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb +1 -0
@@ -15,6 +15,7 @@ SRC_URI = "git://git.efficios.com/babeltrace.git;branch=stable-2.1;protocol=http file://0001-Make-bt_field_blob_get_length-return-size_t-instead-.patch \ file://external-python-tests.patch \ file://0001-src-explicitly-only-build-shared-plugins.patch \ + file://0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch \ " SRCREV = "d0e946a71faf5f0c2d7f1fb5b92a369983e9cf10" UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>2(\.\d+)+)$"
PATCH v4 3/4 u-boot-tools: fix pylibfdt build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the dtc upstream fix to u-boot's bundled pylibfdt/libfdt.i to replace them with Python 3 equivalents.
--- ...-removed-SWIG-Python-2-compatibility.patch | 55 +++++++++++++++++++ .../u-boot/u-boot-tools_2026.07.bb | 4 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +55 -0
@@ -0,0 +1,55 @@ +From 886616d03b6afcc5ce8b34e7af91f7ccfbb0a5c Mon Sep 17 00:00:00 2001 +From: Jaipaul Cheernam <[email protected]> +Date: Tue, 11 Aug 2026 13:21:01 +0000 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong + +The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +This is a backport of dtc commit 5008d1d6a356 ("pylibfdt: Replace +removed SWIG Python 2 compatibility macros"). + +Upstream-Status: Submitted [https://patchwork.ozlabs.org/patch/2283713/] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + scripts/dtc/pylibfdt/libfdt.i_shipped | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped +index e4659489..326a15c7 100644 +--- a/scripts/dtc/pylibfdt/libfdt.i_shipped ++++ b/scripts/dtc/pylibfdt/libfdt.i_shipped +@@ -1033,7 +1033,7 @@ typedef uint32_t fdt32_t; + PyObject *buff; + + if ($1) { +- resultobj = PyString_FromString( ++ resultobj = PyUnicode_FromString( + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +@@ -1064,13 +1064,13 @@ typedef uint32_t fdt32_t; + } + $1 = PyBytes_AsString($input); + %#else +- $1 = PyString_AsString($input); /* char *str */ ++ $1 = PyBytes_AsString($input); /* char *str */ + %#endif + } + + /* typemaps used for fdt_next_node() */ + %typemap(in, numinputs=1) int *depth (int depth) { +- depth = (int) PyInt_AsLong($input); ++ depth = (int) PyLong_AsLong($input); + $1 = &depth; + } +
meta/recipes-bsp/u-boot/u-boot-tools_2026.07.bb +3 -1
@@ -1,4 +1,6 @@ require u-boot-common.inc require u-boot-tools.inc -SRC_URI += "file://0001-tools-mkeficapsule-Detect-GnuTLS-PKCS-11-support.patch" +SRC_URI += "file://0001-tools-mkeficapsule-Detect-GnuTLS-PKCS-11-support.patch \ + file://0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch \ + "
PATCH v4 4/4 python3-dtc: fix build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the upstream fix to replace them with Python 3 equivalents.
--- ...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++++++ .../python/python3-dtc_1.8.1.bb | 1 + 2 files changed, 58 insertions(+) create mode 100644 meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +57 -0
@@ -0,0 +1,57 @@ +From 32378d7b4383a79d13da9005035600d8f0c8c29d Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Tue, 29 Jul 2026 05:55:56 +0000 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong + +The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +Signed-off-by: Jitka Plesnikova <[email protected]> +Signed-off-by: Peter Robinson <[email protected]> +Signed-off-by: David Gibson <[email protected]> +(cherry picked from commit 5008d1d6a356b8d0a78060da2e1021507d529cff) + +Upstream-Status: Backport [https://github.com/dgibson/dtc/commit/5008d1d6a356b8d0a78060da2e1021507d529cff] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + pylibfdt/libfdt.i | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i +index 1f9c0471..b1cb9873 100644 +--- a/pylibfdt/libfdt.i ++++ b/pylibfdt/libfdt.i +@@ -1136,7 +1136,7 @@ typedef uint32_t fdt32_t; + PyObject *buff; + + if ($1) { +- resultobj = PyString_FromString( ++ resultobj = PyUnicode_FromString( + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +@@ -1169,13 +1169,13 @@ typedef uint32_t fdt32_t; + } + $1 = PyBytes_AsString($input); + %#else +- $1 = PyString_AsString($input); /* char *str */ ++ $1 = PyBytes_AsString($input); /* char *str */ + %#endif + } + + /* typemaps used for fdt_next_node() */ + %typemap(in, numinputs=1) int *depth (int depth) { +- depth = (int) PyInt_AsLong($input); ++ depth = (int) PyLong_AsLong($input); + $1 = &depth; + } +
meta/recipes-devtools/python/python3-dtc_1.8.1.bb +1 -0
@@ -7,6 +7,7 @@ LICENSE = "BSD-2-Clause OR GPL-2.0-only" DEPENDS = "flex-native bison-native swig-native python3-setuptools-scm-native libyaml dtc" SRC_URI = "git://git.kernel.org/pub/scm/utils/dtc/dtc.git;branch=main;protocol=https;tag=v${PV} \ + file://0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch \ " UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"
Re: [OE-core] [PATCH v4 4/4] python3-dtc: fix build with swig 4.5.0
Quoted 6 lines · Jaipaul Cheernam
SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the upstream fix to replace them with Python 3 equivalents.
Signed-off-by Jaipaul Cheernam <[email protected]>---
Hi Jaipaul,
Thanks for the new version.
I suspect this is the source of some selftest fails:
2026-08-12 06:27:00,896 - oe-selftest - INFO - fitimage.UBootFitImageTests.test_sign_uboot_kernel_individual (subunit.RemotedTestCase) 2026-08-12 06:27:00,896 - oe-selftest - INFO - ... FAIL
...
ERROR: u-boot-1_2026.07-r0 do_compile: oe_runmake failed
ERROR: u-boot-1_2026.07-r0 do_compile: Execution of '/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3408129/tmp/work/qemux86_64-poky-linux/u-boot/2026.07/temp/run.do_compile.180130' failed with exit code 1
...
| ImportError: /srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3408129/tmp/work/qemux86_64-poky-linux/u-boot/2026.07/build/scripts/dtc/pylibfdt/_libfdt.so: undefined symbol: PyInt_AsLong | make[1]: *** [/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3408129/tmp/work/qemux86_64-poky-linux/u-boot/2026.07/sources/u-boot-2026.07/Makefile:1395: .binman_stamp] Error 1 | make: Leaving directory '/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3408129/tmp/work/qemux86_64-poky-linux/u-boot/2026.07/sources/u-boot-2026.07' | make: *** [Makefile:189: __sub-make] Error 2 | ERROR: oe_runmake failed | WARNING: exit code 1 from a shell command.
NOTE: recipe u-boot-1_2026.07-r0: task do_compile: Failed
ERROR: Task (/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/recipes-bsp/u-boot/u-boot_2026.07.bb:do_compile) failed with exit code '1'
And other fails:
2026-08-12 06:25:29,098 - oe-selftest - INFO - fitimage.UBootFitImageTests.test_sign_uboot_fit_image_without_spl (subunit.RemotedTestCase) 2026-08-12 06:25:29,124 - oe-selftest - INFO - ... FAIL ... 2026-08-12 06:28:15,880 - oe-selftest - INFO - fitimage.UBootFitImageTests.test_uboot_fit_image (subunit.RemotedTestCase) 2026-08-12 06:28:15,881 - oe-selftest - INFO - ... FAIL ... 2026-08-12 08:27:05,250 - oe-selftest - INFO - uboot.UBootTest.test_uboot_config_initial_env_binary (subunit.RemotedTestCase) 2026-08-12 08:27:05,263 - oe-selftest - INFO - ... FAIL ... 2026-08-12 08:28:04,129 - oe-selftest - INFO - uboot.UBootTest.test_uboot_initial_env_binary (subunit.RemotedTestCase) 2026-08-12 08:28:04,141 - oe-selftest - INFO - ... FAIL
Can you have a look at the issue?
Thanks,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
v5 cover swig: upgrade 4.4.1 -> 4.5.0
In reply to Jaipaul CheernamUpgrade swig to 4.5.0 and fix build breakage in recipes that used Python 2 C API macros removed in swig 4.5.0.
Note: The following recipes in meta-openembedded may also be affected if python/swig bindings are enabled:
- gensio (meta-oe): fix available upstream [1]
- unbound (meta-networking): fix available upstream [2]
- ldns (meta-oe): fix pending upstream [3]
[1] https://github.com/cminyard/gensio/commit/e024df7fc3d21896bd9d2e26964a0b59b7c2a91b
[2] https://github.com/NLnetLabs/unbound/commit/93a56205cfa6b9a6d34db7245aa71e5ca67d1fd7
[3] https://github.com/NLnetLabs/ldns/issues/314
Changes in v5:
- Moved pylibfdt patch to u-boot-common.inc so it applies to both u-boot and u-boot-tools recipes
Changes in v4:
- Fixed u-boot-tools patch path (libfdt.i_shipped, not libfdt.i)
- Submitted fix to u-boot upstream [4]
[4] https://patchwork.ozlabs.org/patch/2283713/
Changes in v3:
- Added u-boot-tools and python3-dtc patches to fix pylibfdt build
Changes in v2:
- Added babeltrace2 patch to fix SWIG 4.5.0 compatibility
Jaipaul Cheernam (4):
swig: upgrade 4.4.1 -> 4.5.0
babeltrace2: fix build with swig 4.5.0
u-boot: fix pylibfdt build with swig 4.5.0
python3-dtc: fix build with swig 4.5.0
...-removed-SWIG-Python-2-compatibility.patch | 55 +++++++++++++++
meta/recipes-bsp/u-boot/u-boot-common.inc | 4 +-
...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++
.../python/python3-dtc_1.8.1.bb | 1 +
.../swig/swig/determinism.patch | 20 +++---
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 +-
...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++
.../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 +
8 files changed, 199 insertions(+), 13 deletions(-)
create mode 100644 meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
create mode 100644 meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)
create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patchPATCH v5 1/4 swig: upgrade 4.4.1 -> 4.5.0
ChangeLog: https://www.swig.org/Release/CHANGES.current
Release Notes: https://www.swig.org/Release/RELEASENOTES
CompareLog: https://github.com/swig/swig/compare/v4.4.1...v4.5.0
- Refresh determinism.patch
---
.../swig/swig/determinism.patch | 20 +++++++++----------
.../swig/{swig_4.4.1.bb => swig_4.5.0.bb} | 4 ++--
2 files changed, 12 insertions(+), 12 deletions(-)
rename meta/recipes-devtools/swig/{swig_4.4.1.bb => swig_4.5.0.bb} (92%)meta/recipes-devtools/swig/swig/determinism.patch +10 -10
@@ -1,26 +1,26 @@ -From 7df78bedb666e49131c48f1854c6be1597bd133c Mon Sep 17 00:00:00 2001 +From 218e2a20ff978cb28fefdf7b35af8a27768df4db Mon Sep 17 00:00:00 2001 From: Richard Purdie <[email protected]> -Date: Mon, 1 Mar 2021 00:11:10 +0000 +Date: Mon, 10 Aug 2026 11:13:20 +0000 Subject: [PATCH] swig: Fix reproducibility issue Remove the compiler commandline/platform from the compiled binary as this breaks reproducibilty. -Upstream-Status: Inappropriate [OE reproducibiity fix upstream unlikely to take] +Upstream-Status: Inappropriate [OE reproducibility fix upstream unlikely to take] RP 2021/3/1 --- Source/Modules/main.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx -index f68b609..0c2aba3 100644 +index 83ab22a..79a513a 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx -@@ -633,7 +633,6 @@ static void getoptions(int argc, char *argv[]) { - } +@@ -642,7 +642,6 @@ static void getoptions(int argc, char *argv[]) { + } } else if (strcmp(argv[i], "-version") == 0 || strcmp(argv[1], "--version") == 0) { - fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); -- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); - fprintf(stdout, "\nConfigured options: %cpcre\n", + fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version()); +- fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM); + fprintf(stdout, + "\nConfigured options: %cpcre\n", #ifdef HAVE_PCRE - '+'
meta/recipes-devtools/swig/swig_4.5.0.bb renamed from meta/recipes-devtools/swig/swig_4.4.1.bb +2 -2
@@ -13,9 +13,9 @@ SECTION = "devel" DEPENDS = "libpcre2 bison-native" SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \ - file://determinism.patch \ + file://determinism.patch \ " -SRC_URI[sha256sum] = "40162a706c56f7592d08fd52ef5511cb7ac191f3593cf07306a0a554c6281fcf" +SRC_URI[sha256sum] = "22ae0e887f8cca8031a325c67d005207653200b40e71edb3f88780e28e47d0ff" UPSTREAM_CHECK_URI = "https://sourceforge.net/projects/swig/files/swig/" UPSTREAM_CHECK_REGEX = "swig-(?P<pver>\d+(\.\d+)+)"
PATCH v5 2/4 babeltrace2: fix build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2/3 compatibility macros PyString_FromString and SWIG_Python_str_FromChar. Backport upstream fix that replaces both with PyUnicode_FromString.
--- ...Python-2-C-API-macros-for-SWIG-4.5.0.patch | 70 +++++++++++++++++++ .../recipes-kernel/lttng/babeltrace2_2.1.2.bb | 1 + 2 files changed, 71 insertions(+) create mode 100644 meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch
meta/recipes-kernel/lttng/babeltrace2/0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch new file +70 -0
@@ -0,0 +1,70 @@ +From 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3 Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Mon, 28 Jul 2026 13:29:18 +0000 +Subject: [PATCH] bt2: replace removed Python 2 C API macros for SWIG 4.5.0 + compatibility + +SWIG 4.5.0 has removed some Python 2/3 compatibility macros. The two +that affect us are `PyString_FromString` and +`SWIG_Python_str_FromChar`, which are both replaced with +`PyUnicode_FromString`. + +Change-Id: I3c74d8ea7257d9cdc0fa4b533ae7b3a5ef9521d1 +Signed-off-by: Simon Marchi <[email protected]> +Signed-off-by: Jitka Plesnikova <[email protected]> +Reviewed-on: https://review.lttng.org/c/babeltrace/+/18423 +Tested-by: jenkins <[email protected]> +(cherry picked from commit 1c59884d4d3c74d8ea7257d9cdc0fa4b533ae7b3) + +Upstream-Status: Backport [https://github.com/efficios/babeltrace/commit/1c59884d4d] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + src/bindings/python/bt2/bt2/native_bt.i | 4 ++-- + src/bindings/python/bt2/bt2/native_bt_error.i.hpp | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i +index 7f8d9f699..1807d8ff6 100644 +--- a/src/bindings/python/bt2/bt2/native_bt.i ++++ b/src/bindings/python/bt2/bt2/native_bt.i +@@ -56,7 +56,7 @@ typedef uint64_t bt_listener_id; + * + * We initialize the output parameter `temp_value` to an invalid but non-zero + * pointer value. This is to make sure we don't rely on its initial value in +- * the epilogue (where we call SWIG_Python_str_FromChar). When they fail, ++ * the epilogue (where we call PyUnicode_FromString). When they fail, + * functions on which we apply this typemap don't guarantee that the value of + * `temp_value` will be unchanged or valid. + */ +@@ -67,7 +67,7 @@ typedef uint64_t bt_listener_id; + %typemap(argout) (const char **) { + if (*$1) { + /* SWIG_AppendOutput() steals the created object */ +- $result = SWIG_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); ++ $result = SWIG_AppendOutput($result, PyUnicode_FromString(*$1)); + } else { + /* SWIG_AppendOutput() steals Py_None */ + Py_INCREF(Py_None); +diff --git a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +index ba8cef097..2be1e347c 100644 +--- a/src/bindings/python/bt2/bt2/native_bt_error.i.hpp ++++ b/src/bindings/python/bt2/bt2/native_bt_error.i.hpp +@@ -19,7 +19,7 @@ static PyObject *bt_bt2_format_bt_error_cause(const bt_error_cause *error_cause) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_cause_str); + +- py_error_cause_str = PyString_FromString(error_cause_str); ++ py_error_cause_str = PyUnicode_FromString(error_cause_str); + + g_free(error_cause_str); + +@@ -35,7 +35,7 @@ static PyObject *bt_bt2_format_bt_error(const bt_error *error) + BT_COMMON_COLOR_WHEN_NEVER); + BT_ASSERT(error_str); + +- py_error_str = PyString_FromString(error_str); ++ py_error_str = PyUnicode_FromString(error_str); + + g_free(error_str); +
meta/recipes-kernel/lttng/babeltrace2_2.1.2.bb +1 -0
@@ -15,6 +15,7 @@ SRC_URI = "git://git.efficios.com/babeltrace.git;branch=stable-2.1;protocol=http file://0001-Make-bt_field_blob_get_length-return-size_t-instead-.patch \ file://external-python-tests.patch \ file://0001-src-explicitly-only-build-shared-plugins.patch \ + file://0001-bt2-replace-removed-Python-2-C-API-macros-for-SWIG-4.5.0.patch \ " SRCREV = "d0e946a71faf5f0c2d7f1fb5b92a369983e9cf10" UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>2(\.\d+)+)$"
PATCH v5 3/4 u-boot: fix pylibfdt build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the dtc upstream fix to u-boot's bundled pylibfdt/libfdt.i_shipped to replace them with Python 3 equivalents.
--- ...-removed-SWIG-Python-2-compatibility.patch | 55 +++++++++++++++++++ meta/recipes-bsp/u-boot/u-boot-common.inc | 4 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +55 -0
@@ -0,0 +1,55 @@ +From 886616d03b6afcc5ce8b34e7af91f7ccfbb0a5c Mon Sep 17 00:00:00 2001 +From: Jaipaul Cheernam <[email protected]> +Date: Tue, 11 Aug 2026 13:21:01 +0000 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong + +The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +This is a backport of dtc commit 5008d1d6a356 ("pylibfdt: Replace +removed SWIG Python 2 compatibility macros"). + +Upstream-Status: Submitted [https://patchwork.ozlabs.org/patch/2283713/] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + scripts/dtc/pylibfdt/libfdt.i_shipped | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped +index e4659489..326a15c7 100644 +--- a/scripts/dtc/pylibfdt/libfdt.i_shipped ++++ b/scripts/dtc/pylibfdt/libfdt.i_shipped +@@ -1033,7 +1033,7 @@ typedef uint32_t fdt32_t; + PyObject *buff; + + if ($1) { +- resultobj = PyString_FromString( ++ resultobj = PyUnicode_FromString( + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +@@ -1064,13 +1064,13 @@ typedef uint32_t fdt32_t; + } + $1 = PyBytes_AsString($input); + %#else +- $1 = PyString_AsString($input); /* char *str */ ++ $1 = PyBytes_AsString($input); /* char *str */ + %#endif + } + + /* typemaps used for fdt_next_node() */ + %typemap(in, numinputs=1) int *depth (int depth) { +- depth = (int) PyInt_AsLong($input); ++ depth = (int) PyLong_AsLong($input); + $1 = &depth; + } +
meta/recipes-bsp/u-boot/u-boot-common.inc +3 -1
@@ -14,7 +14,9 @@ PE = "1" # repo during parse SRCREV = "ece349ade2973e220f524ce59e59711cc919263f" -SRC_URI = "git://git.u-boot-project.org/u-boot/u-boot.git;protocol=https;branch=main;tag=v${PV}" +SRC_URI = "git://git.u-boot-project.org/u-boot/u-boot.git;protocol=https;branch=main;tag=v${PV} \ + file://0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch \ + " B = "${WORKDIR}/build"
PATCH v5 4/4 python3-dtc: fix build with swig 4.5.0
In reply to Jaipaul CheernamSWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) from its runtime. Backport the upstream fix to replace them with Python 3 equivalents.
--- ...-removed-SWIG-Python-2-compatibility.patch | 57 +++++++++++++++++++ .../python/python3-dtc_1.8.1.bb | 1 + 2 files changed, 58 insertions(+) create mode 100644 meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
meta/recipes-devtools/python/python3-dtc/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch new file +57 -0
@@ -0,0 +1,57 @@ +From 32378d7b4383a79d13da9005035600d8f0c8c29d Mon Sep 17 00:00:00 2001 +From: Jitka Plesnikova <[email protected]> +Date: Tue, 29 Jul 2026 05:55:56 +0000 +Subject: [PATCH] pylibfdt: Replace removed SWIG Python 2 compatibility macros + +SWIG 4.5.0 removed Python 2 compatibility macros (PyInt_*, PyString_*) +from its runtime header pyhead.swg (see commit 79f7a2b7cb7d). Replace +them with their Python 3 C API equivalents: + +- PyString_FromString -> PyUnicode_FromString +- PyString_AsString -> PyBytes_AsString +- PyInt_AsLong -> PyLong_AsLong + +The replacements are safe since the macros were already aliased to +these exact functions in SWIG's Python 3 code path. + +Signed-off-by: Jitka Plesnikova <[email protected]> +Signed-off-by: Peter Robinson <[email protected]> +Signed-off-by: David Gibson <[email protected]> +(cherry picked from commit 5008d1d6a356b8d0a78060da2e1021507d529cff) + +Upstream-Status: Backport [https://github.com/dgibson/dtc/commit/5008d1d6a356b8d0a78060da2e1021507d529cff] + +Signed-off-by: Jaipaul Cheernam <[email protected]> +--- + pylibfdt/libfdt.i | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i +index 1f9c0471..b1cb9873 100644 +--- a/pylibfdt/libfdt.i ++++ b/pylibfdt/libfdt.i +@@ -1136,7 +1136,7 @@ typedef uint32_t fdt32_t; + PyObject *buff; + + if ($1) { +- resultobj = PyString_FromString( ++ resultobj = PyUnicode_FromString( + fdt_string(fdt1, fdt32_to_cpu($1->nameoff))); + buff = PyByteArray_FromStringAndSize( + (const char *)($1 + 1), fdt32_to_cpu($1->len)); +@@ -1169,13 +1169,13 @@ typedef uint32_t fdt32_t; + } + $1 = PyBytes_AsString($input); + %#else +- $1 = PyString_AsString($input); /* char *str */ ++ $1 = PyBytes_AsString($input); /* char *str */ + %#endif + } + + /* typemaps used for fdt_next_node() */ + %typemap(in, numinputs=1) int *depth (int depth) { +- depth = (int) PyInt_AsLong($input); ++ depth = (int) PyLong_AsLong($input); + $1 = &depth; + } +
meta/recipes-devtools/python/python3-dtc_1.8.1.bb +1 -0
@@ -7,6 +7,7 @@ LICENSE = "BSD-2-Clause OR GPL-2.0-only" DEPENDS = "flex-native bison-native swig-native python3-setuptools-scm-native libyaml dtc" SRC_URI = "git://git.kernel.org/pub/scm/utils/dtc/dtc.git;branch=main;protocol=https;tag=v${PV} \ + file://0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch \ " UPSTREAM_CHECK_GITTAGREGEX = "v(?P<pver>\d+(\.\d+)+)"