All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
To: openembedded-core@lists.openembedded.org
Cc: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
Subject: [PATCH v4 3/4] u-boot-tools: fix pylibfdt build with swig 4.5.0
Date: Tue, 11 Aug 2026 15:51:59 +0200	[thread overview]
Message-ID: <20260811135200.18942-4-jaipaul.cheernam@est.tech> (raw)
In-Reply-To: <20260811135200.18942-1-jaipaul.cheernam@est.tech>

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 <jaipaul.cheernam@est.tech>
---
 ...-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

diff --git a/meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch b/meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
new file mode 100644
index 0000000000..c1d0204e32
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/0001-pylibfdt-Replace-removed-SWIG-Python-2-compatibility.patch
@@ -0,0 +1,55 @@
+From 886616d03b6afcc5ce8b34e7af91f7ccfbb0a5c Mon Sep 17 00:00:00 2001
+From: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
+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 <jaipaul.cheernam@est.tech>
+---
+ 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;
+ }
+ 
diff --git a/meta/recipes-bsp/u-boot/u-boot-tools_2026.07.bb b/meta/recipes-bsp/u-boot/u-boot-tools_2026.07.bb
index 9e7a178310..ea90b726c5 100644
--- a/meta/recipes-bsp/u-boot/u-boot-tools_2026.07.bb
+++ b/meta/recipes-bsp/u-boot/u-boot-tools_2026.07.bb
@@ -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 \
+            "


  parent reply	other threads:[~2026-08-11 13:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 15:45 [PATCH] swig: upgrade 4.4.1 -> 4.5.0 Jaipaul Cheernam
2026-08-10 21:02 ` [OE-core] " Richard Purdie
2026-08-11  6:12 ` [PATCH v2 0/2] " Jaipaul Cheernam
2026-08-11  6:12   ` [PATCH v2 1/2] " Jaipaul Cheernam
2026-08-11 10:25     ` [OE-core] " Richard Purdie
2026-08-11 11:15       ` Jaipaul Cheernam
2026-08-11  6:12   ` [PATCH v2 2/2] babeltrace2: fix build with swig 4.5.0 Jaipaul Cheernam
2026-08-11 11:11 ` [PATCH v3 0/4] swig: upgrade 4.4.1 -> 4.5.0 Jaipaul Cheernam
2026-08-11 11:11   ` [PATCH v3 1/4] " Jaipaul Cheernam
2026-08-11 11:11   ` [PATCH v3 2/4] babeltrace2: fix build with swig 4.5.0 Jaipaul Cheernam
2026-08-11 11:11   ` [PATCH v3 3/4] u-boot-tools: fix pylibfdt " Jaipaul Cheernam
2026-08-11 12:58     ` [OE-core] " Mathieu Dubois-Briand
2026-08-11 13:38     ` Quentin Schulz
2026-08-11 11:11   ` [PATCH v3 4/4] python3-dtc: fix " Jaipaul Cheernam
2026-08-11 13:51 ` [PATCH v4 0/4] swig: upgrade 4.4.1 -> 4.5.0 Jaipaul Cheernam
2026-08-11 13:51   ` [PATCH v4 1/4] " Jaipaul Cheernam
2026-08-11 13:51   ` [PATCH v4 2/4] babeltrace2: fix build with swig 4.5.0 Jaipaul Cheernam
2026-08-11 13:51   ` Jaipaul Cheernam [this message]
2026-08-11 13:52   ` [PATCH v4 4/4] python3-dtc: " Jaipaul Cheernam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260811135200.18942-4-jaipaul.cheernam@est.tech \
    --to=jaipaul.cheernam@est.tech \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.