Skip to content

Commit 61786e5

Browse files
committed
Allow static, non-framework iOS builds
An iOS app can only load a signed framework, so a shared Python has to be built as one. A static libpython is linked into the app binary and loads nothing at runtime, so the requirement does not apply to it, but configure refused that configuration outright. Refuse it only where it cannot work: a shared build with no framework. The LINKFORSHARED and MODULE_DEPS_SHARED framework references are gated on enable_framework, as the Darwin arm above already does, since a build without a framework has nothing to link against. Passing no framework option at all still errors, so a non-framework build stays an explicit opt-in.
1 parent e8158d1 commit 61786e5

2 files changed

Lines changed: 30 additions & 10 deletions

File tree

configure

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ AC_ARG_ENABLE([framework],
579579
case $enableval in
580580
no)
581581
case $ac_sys_system in
582-
iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;
583582
*)
584583
PYTHONFRAMEWORK=
585584
PYTHONFRAMEWORKDIR=no-framework
@@ -689,7 +688,7 @@ AC_ARG_ENABLE([framework],
689688
esac
690689
],[
691690
case $ac_sys_system in
692-
iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;;
691+
iOS) AC_MSG_ERROR([iOS builds must use --enable-framework, or --disable-framework with --disable-shared to build a static libpython]) ;;
693692
*)
694693
PYTHONFRAMEWORK=
695694
PYTHONFRAMEWORKDIR=no-framework
@@ -1689,6 +1688,12 @@ else # shared is disabled
16891688
fi
16901689
AC_MSG_RESULT([$LDLIBRARY])
16911690

1691+
# A shared Python on iOS has to be a framework: an app can only load a signed
1692+
# framework, never a bare dylib. A static libpython has nothing to load.
1693+
if test "$ac_sys_system" = "iOS" && test "$PY_ENABLE_SHARED" = 1 && test -z "$PYTHONFRAMEWORK"; then
1694+
AC_MSG_ERROR([iOS builds must use --enable-framework, or --disable-framework with --disable-shared to build a static libpython])
1695+
fi
1696+
16921697
# HOSTRUNNER - Program to run CPython for the host platform
16931698
AC_MSG_CHECKING([HOSTRUNNER])
16941699
if test -z "$HOSTRUNNER"
@@ -3830,7 +3835,11 @@ then
38303835
fi
38313836
LINKFORSHARED="$LINKFORSHARED"
38323837
elif test $ac_sys_system = "iOS"; then
3833-
LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)'
3838+
LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED"
3839+
3840+
if test "$enable_framework"; then
3841+
LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)'
3842+
fi
38343843
fi
38353844
;;
38363845
OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
@@ -6755,8 +6764,9 @@ if test "$PY_ENABLE_SHARED" = "1" && ( test -n "$ANDROID_API_LEVEL" || test "$MA
67556764
LIBPYTHON="-lpython${VERSION}${ABIFLAGS}"
67566765
fi
67576766

6758-
# On iOS the shared libraries must be linked with the Python framework
6759-
if test "$ac_sys_system" = "iOS"; then
6767+
# On iOS the shared libraries must be linked with the Python framework, when one
6768+
# is being built
6769+
if test "$ac_sys_system" = "iOS" && test "$enable_framework"; then
67606770
MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)"
67616771
fi
67626772

0 commit comments

Comments
 (0)