diff mbox series

[meta-python] python3-m2crypto: fix do_compile error using clang

Message ID 20260318030446.2041-1-wangmy@fujitsu.com
State Accepted
Headers show
Series [meta-python] python3-m2crypto: fix do_compile error using clang | expand

Commit Message

Wang Mingyu March 18, 2026, 3:04 a.m. UTC
From: Wang Mingyu <wangmy@fujitsu.com>

erre message:
| INFO:mkpath:creating build/temp.linux-aarch64-cpython-314/src/SWIG
| INFO:spawn:aarch64-yoe-linux-clang -mcpu=cortex-a57+crc --dyld-prefix=/usr -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/srv/build/yoe/build/tmp/work/cortexa57-yoe-linux/python3-m2crypto/0.47.0/recipe-sysroot -O2 -g -ffile-prefix-map=/srv/build/yoe/build/tmp/work/cortexa57-yoe-linux/python3-m2crypto/0.47.0/sources/m2crypto-0.47.0=/usr/src/debug/python3-m2crypto/0.47.0 -ffile-prefix-map=/srv/build/yoe/build/tmp/work/cortexa57-yoe-linux/python3-m2crypto/0.47.0/sources/m2crypto-0.47.0=/usr/src/debug/python3-m2crypto/0.47.0 -ffile-prefix-map=/srv/build/yoe/build/tmp/work/cortexa57-yoe-linux/python3-m2crypto/0.47.0/recipe-sysroot= -ffile-prefix-map=/srv/build/yoe/build/tmp/work/cortexa57-yoe-linux/python3-m2crypto/0.47.0/recipe-sysroot-native= -pipe -fPIC -I/srv/build/yoe/build/tmp/work/cortexa57-yoe-linux/python3-m2crypto/0.47.0/recipe-sysroot/usr/include/python3.14 -I/srv/build/yoe/build/tmp/work/cortexa57-yoe-linux/python3-m2crypto/0.47.0/sources/m2crypto-0.47.0/src/SWIG -c src/SWIG/_m2crypto_wrap.c -o build/temp.linux-aarch64-cpython-314/src/SWIG/_m2crypto_wrap.o -DTHREADING -Wno-deprecated-declarations
| src/SWIG/_m2crypto_wrap.c:4455:1: error: unknown type name 'PRAGMA_IGNORE_UNUSED_LABEL'
|  4455 | PRAGMA_IGNORE_UNUSED_LABEL
|       | ^
| src/SWIG/_m2crypto_wrap.c:4456:30: error: expected ';' after top level declarator
|  4456 | PRAGMA_WARN_STRICT_PROTOTYPES
|       |                              ^
|       |                              ;
| 2 errors generated.

Add patch 0001-fix-swig-avoid-clang-GNUC-pragma-block-before-_lib.h.patch to avoid clang GNUC pragma block before _lib.h

Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
---
 ...lang-GNUC-pragma-block-before-_lib.h.patch | 49 +++++++++++++++++++
 .../python/python3-m2crypto_0.47.0.bb         |  3 +-
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-m2crypto/0001-fix-swig-avoid-clang-GNUC-pragma-block-before-_lib.h.patch
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-m2crypto/0001-fix-swig-avoid-clang-GNUC-pragma-block-before-_lib.h.patch b/meta-python/recipes-devtools/python/python3-m2crypto/0001-fix-swig-avoid-clang-GNUC-pragma-block-before-_lib.h.patch
new file mode 100644
index 0000000000..7aa768f44d
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-m2crypto/0001-fix-swig-avoid-clang-GNUC-pragma-block-before-_lib.h.patch
@@ -0,0 +1,49 @@ 
+From df210da932c2cab9d3a80ee88c70611d77824a15 Mon Sep 17 00:00:00 2001
+From: Wang Mingyu <wangmy@fujitsu.com>
+Date: Wed, 18 Mar 2026 02:26:56 +0000
+Subject: [PATCH] fix(swig): avoid clang GNUC pragma block before _lib.h
+
+Clang defines __GNUC__, so the old guard emitted PRAGMA_* tokens before
+they were defined, breaking builds on macOS/clang; move the block after
+<_lib.h> and exclude clang while keeping the GCC<5 workaround.
+
+Fixes: https://todo.sr.ht/~mcepl/m2crypto/392
+
+Upstream-Status: Backport [git.sr.ht/~mcepl/m2crypto/commit/504ca8f438afb0f5041d2b5163e5f666a9a1b742.patch]
+
+Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
+---
+ src/SWIG/_m2crypto.i | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/src/SWIG/_m2crypto.i b/src/SWIG/_m2crypto.i
+index d89d355..5426446 100644
+--- a/src/SWIG/_m2crypto.i
++++ b/src/SWIG/_m2crypto.i
+@@ -43,15 +43,18 @@ typedef unsigned __int64 uint64_t;
+ %}
+ 
+ %{
+-#if defined __GNUC__ && __GNUC__ < 5
+-PRAGMA_IGNORE_UNUSED_LABEL
+-PRAGMA_WARN_STRICT_PROTOTYPES
+-#endif
+-
+ #include <openssl/err.h>
+ #include <openssl/rand.h>
+ #include <_lib.h>
+ 
++/* _lib.h defines PRAGMA_* helpers; only needed for old GCC (clang defines
++ * __GNUC__ too, but doesn't need this workaround).
++ */
++#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 5)
++PRAGMA_IGNORE_UNUSED_LABEL
++PRAGMA_WARN_STRICT_PROTOTYPES
++#endif
++
+ #include "compile.h"
+ 
+ static PyObject *ssl_verify_cb_func;
+-- 
+2.43.0
+
diff --git a/meta-python/recipes-devtools/python/python3-m2crypto_0.47.0.bb b/meta-python/recipes-devtools/python/python3-m2crypto_0.47.0.bb
index ba7bd9b8e3..0ebe30f81c 100644
--- a/meta-python/recipes-devtools/python/python3-m2crypto_0.47.0.bb
+++ b/meta-python/recipes-devtools/python/python3-m2crypto_0.47.0.bb
@@ -6,7 +6,8 @@  LIC_FILES_CHKSUM = "file://LICENSES/BSD-2-Clause.txt;md5=8099b0e569f862ece05740a
 
 SRC_URI[sha256sum] = "9256300be1e0412be802aa1f827e0ce7f94deb1099b8ccdcfd9867a7f0f975bf"
 
-SRC_URI += "file://0001-setup.py-Make-the-cmd-available.patch"
+SRC_URI += "file://0001-setup.py-Make-the-cmd-available.patch \
+            file://0001-fix-swig-avoid-clang-GNUC-pragma-block-before-_lib.h.patch"
 
 CVE_STATUS[CVE-2009-0127] = "disputed: upstream claims there is no bug"
 CVE_STATUS[CVE-2020-25657] = "fixed-version: the used version (0.46.2) contains the fix already"