]> git.99rst.org Git - openwrt-packages.git/commitdiff
python-cffi: fix cross-compilation on macOS hosts
authorJosef Schlehofer <redacted>
Fri, 7 Aug 2026 11:19:31 +0000 (13:19 +0200)
committerAlexandru Ardelean <redacted>
Sun, 9 Aug 2026 08:42:40 +0000 (11:42 +0300)
setup.py picks the macOS-only -iwithsysroot/usr/include/ffi flag from
sys.platform, which describes the interpreter running the build rather than
the target, so cross-compiling from a macOS host hands an Apple clang flag to
the GNU cross compiler and the build fails. Use sysconfig.get_platform(),
which honours the _PYTHON_HOST_PLATFORM that python3-package.mk exports.

Signed-off-by: Josef Schlehofer <redacted>
lang/python/python-cffi/Makefile
lang/python/python-cffi/patches/001-fix-cross-compilation-on-macos-hosts.patch [new file with mode: 0644]

index cc07b449b665ad5e73be49b889f86551f47ad79c..b6d26b5d9889b4e56c42dec82c1ec4e04e134f72 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=python-cffi
 PKG_VERSION:=2.0.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PYPI_NAME:=cffi
 PKG_HASH:=44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529
diff --git a/lang/python/python-cffi/patches/001-fix-cross-compilation-on-macos-hosts.patch b/lang/python/python-cffi/patches/001-fix-cross-compilation-on-macos-hosts.patch
new file mode 100644 (file)
index 0000000..32fb448
--- /dev/null
@@ -0,0 +1,31 @@
+From 7a3b39e2fbbaa0511789a3231964f61f77fb28a9 Mon Sep 17 00:00:00 2001
+From: Josef Schlehofer <pepe.schlehofer@gmail.com>
+Date: Tue, 9 Jun 2026 04:33:35 +0000
+Subject: [PATCH] setup.py: fix cross-compilation on macOS hosts
+
+When cross-compiling for a non-macOS target (such as Linux) on a macOS host,
+setup.py incorrectly detects the host platform as 'darwin' using sys.platform.
+This adds the macOS-specific flag -iwithsysroot/usr/include/ffi to the compiler
+arguments, which causes the cross-compiler to fail with:
+
+  powerpc-openwrt-linux-musl-gcc: error: unrecognized command-line option
+  '-iwithsysroot/usr/include/ffi'
+
+By using sysconfig.get_platform().startswith('macosx') instead of 'darwin' in
+sys.platform, we correctly check the target platform rather than the build host.
+sysconfig.get_platform() honours _PYTHON_HOST_PLATFORM, which
+python3-package.mk already exports.
+
+Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
+---
+--- a/setup.py
++++ b/setup.py
+@@ -154,7 +154,7 @@ else:
+     ask_supports_thread()
+     ask_supports_sync_synchronize()
+-if 'darwin' in sys.platform:
++if sysconfig.get_platform().startswith('macosx'):
+     # priority is given to `pkg_config`, but always fall back on SDK's libffi.
+     extra_compile_args += ['-iwithsysroot/usr/include/ffi']
git clone https://git.99rst.org/PROJECT