Skip to content

Commit 7a3b39e

Browse files
authored
setup.py: fix cross-compilation on macOS hosts (#247)
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: aarch64-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. This allows successful cross-compilation on macOS hosts.
1 parent fe99742 commit 7a3b39e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def use_homebrew_for_libffi():
154154
ask_supports_thread()
155155
ask_supports_sync_synchronize()
156156

157-
if 'darwin' in sys.platform:
157+
if sysconfig.get_platform().startswith('macosx'):
158158
# priority is given to `pkg_config`, but always fall back on SDK's libffi.
159159
extra_compile_args += ['-iwithsysroot/usr/include/ffi']
160160

0 commit comments

Comments
 (0)