Skip to content

Commit 8035bd6

Browse files
committed
Make better use of makesetup directives in module configuration.
1 parent 4b832f6 commit 8035bd6

File tree

10 files changed

+230
-78
lines changed

10 files changed

+230
-78
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ downloads/libffi-$(LIBFFI_VERSION).tgz:
232232
clean-Python:
233233
@echo ">>> Clean Python build products"
234234
rm -rf \
235+
dist/Python-$(PYTHON_VER)-* \
235236
build/*/Python-$(PYTHON_VERSION)-* \
236237
build/*/python \
237238
build/*/python-*.log \
@@ -469,11 +470,11 @@ $$(PYTHON_DIR-$(target))/Makefile: \
469470
> $$(PYTHON_DIR-$(target))/Modules/Setup.local
470471
# Configure target Python
471472
cd $$(PYTHON_DIR-$(target)) && \
472-
PATH=$(PROJECT_DIR)/$(PYTHON_DIR-macOS)/_install/bin:$(PATH) \
473473
./configure \
474474
CC="$$(CC-$(target))" LD="$$(CC-$(target))" \
475475
--host=$$(MACHINE_DETAILED-$(target))-apple-$(shell echo $(os) | tr '[:upper:]' '[:lower:]') \
476476
--build=$(HOST_ARCH)-apple-darwin \
477+
--with-build-python=$(PROJECT_DIR)/$(PYTHON_DIR-macOS)/_install/bin/python$(PYTHON_VER) \
477478
--prefix="$(PROJECT_DIR)/$$(PYTHON_DIR-$(target))/_install" \
478479
--without-doc-strings --enable-ipv6 --without-ensurepip \
479480
--with-openssl=../openssl/$$(SDK-$(target)) \
@@ -484,14 +485,12 @@ $$(PYTHON_DIR-$(target))/Makefile: \
484485
$$(PYTHON_DIR-$(target))/python.exe: $$(PYTHON_DIR-$(target))/Makefile
485486
@echo ">>> Build Python for $(target)"
486487
cd $$(PYTHON_DIR-$(target)) && \
487-
PATH="$(PROJECT_DIR)/$(PYTHON_DIR-macOS)/_install/bin:$(PATH)" \
488488
make all \
489489
2>&1 | tee -a ../python-$(target).build.log
490490

491491
$$(PYTHON_LIB-$(target)): $$(PYTHON_DIR-$(target))/python.exe
492492
@echo ">>> Install Python for $(target)"
493493
cd $$(PYTHON_DIR-$(target)) && \
494-
PATH="$(PROJECT_DIR)/$(PYTHON_DIR-macOS)/_install/bin:$(PATH)" \
495494
make install \
496495
2>&1 | tee -a ../python-$(target).install.log
497496

patch/Python/Python.patch

Lines changed: 127 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,10 +1500,31 @@ index 44974d433b..ae4e18802b 100755
15001500
#
15011501
# Platform support for Windows
15021502
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
1503-
index 9132f13e81..c6901a31d5 100644
1503+
index 9132f13e81..36e00f7bfd 100644
15041504
--- a/Modules/_posixsubprocess.c
15051505
+++ b/Modules/_posixsubprocess.c
1506-
@@ -660,11 +660,15 @@
1506+
@@ -31,10 +31,20 @@
1507+
1508+
#include "posixmodule.h"
1509+
1510+
+#if defined(__APPLE__)
1511+
+#include "TargetConditionals.h"
1512+
+#endif
1513+
+
1514+
#ifdef _Py_MEMORY_SANITIZER
1515+
# include <sanitizer/msan_interface.h>
1516+
#endif
1517+
1518+
+// iOS/tvOS/watchOS *define* a number of POSIX functions, but you can't use them
1519+
+// because they aren't conventional multiprocess environments.
1520+
+#if TARGET_OS_IPHONE
1521+
+# undef HAVE_FORK
1522+
+#endif
1523+
+
1524+
#if defined(__ANDROID__) && __ANDROID_API__ < 21 && !defined(SYS_getdents64)
1525+
# include <sys/linux-syscalls.h>
1526+
# define SYS_getdents64 __NR_getdents64
1527+
@@ -660,11 +670,15 @@
15071528
saved_errno = 0;
15081529
for (i = 0; exec_array[i] != NULL; ++i) {
15091530
const char *executable = exec_array[i];
@@ -1519,18 +1540,93 @@ index 9132f13e81..c6901a31d5 100644
15191540
if (errno != ENOENT && errno != ENOTDIR && saved_errno == 0) {
15201541
saved_errno = errno;
15211542
}
1522-
@@ -751,7 +755,11 @@
1543+
@@ -730,7 +744,9 @@
1544+
PyObject *preexec_fn,
1545+
PyObject *preexec_fn_args_tuple)
1546+
{
1547+
-
1548+
+/* iOS/tvOS/watchOS define the existence of fork, but it cannot be invoked;
1549+
+ * so fail fast if any attempt is made to invoke fork_exec */
1550+
+#ifdef HAVE_FORK
1551+
pid_t pid;
1552+
1553+
#ifdef VFORK_USABLE
1554+
@@ -749,7 +765,7 @@
1555+
pid = fork();
1556+
}
15231557
} else
1524-
#endif
1558+
-#endif
1559+
+#endif /* VFORK_USABLE */
15251560
{
1526-
+#if defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
1527-
+ pid = -1;
1528-
+#else
15291561
pid = fork();
1530-
+#endif
15311562
}
1532-
1563+
@@ -757,7 +773,6 @@
15331564
if (pid != 0) {
1565+
return pid;
1566+
}
1567+
-
1568+
/* Child process.
1569+
* See the comment above child_exec() for restrictions imposed on
1570+
* the code below.
1571+
@@ -780,6 +795,9 @@
1572+
py_fds_to_keep, preexec_fn, preexec_fn_args_tuple);
1573+
_exit(255);
1574+
return 0; /* Dead code to avoid a potential compiler warning. */
1575+
+#else /* HAVE_FORK */
1576+
+ return -1;
1577+
+#endif /* HAVE_FORK */
1578+
}
1579+
1580+
1581+
@@ -810,7 +828,9 @@
1582+
int need_after_fork = 0;
1583+
int saved_errno = 0;
1584+
int allow_vfork;
1585+
-
1586+
+/* iOS/tvOS/watchOS define the existence of fork, but it cannot be invoked;
1587+
+ * so fail fast if any attempt is made to invoke fork_exec */
1588+
+#ifdef HAVE_FORK
1589+
if (!PyArg_ParseTuple(
1590+
args, "OOpO!OOiiiiiiiiii" _Py_PARSE_PID "OOOiOp:fork_exec",
1591+
&process_args, &executable_list,
1592+
@@ -982,7 +1002,6 @@
1593+
goto cleanup;
1594+
#endif /* HAVE_SETREUID */
1595+
}
1596+
-
1597+
/* This must be the last thing done before fork() because we do not
1598+
* want to call PyOS_BeforeFork() if there is any chance of another
1599+
* error leading to the cleanup: code without calling fork(). */
1600+
@@ -1017,7 +1036,7 @@
1601+
}
1602+
old_sigmask = &old_sigs;
1603+
}
1604+
-#endif
1605+
+#endif /* VFORK_USABLE */
1606+
1607+
pid = do_fork_exec(exec_array, argv, envp, cwd,
1608+
p2cread, p2cwrite, c2pread, c2pwrite,
1609+
@@ -1049,7 +1068,7 @@
1610+
* the thread signal mask. */
1611+
(void) pthread_sigmask(SIG_SETMASK, old_sigmask, NULL);
1612+
}
1613+
-#endif
1614+
+#endif /* VFORK_USABLE */
1615+
1616+
if (need_after_fork)
1617+
PyOS_AfterFork_Parent();
1618+
@@ -1078,8 +1097,10 @@
1619+
PyGC_Enable();
1620+
}
1621+
Py_XDECREF(gc_module);
1622+
-
1623+
return pid == -1 ? NULL : PyLong_FromPid(pid);
1624+
+#else /* HAVE_FORK */
1625+
+ return NULL;
1626+
+#endif
1627+
}
1628+
1629+
15341630
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
15351631
index 08c40834c4..5c110d7211 100644
15361632
--- a/Modules/faulthandler.c
@@ -1556,7 +1652,7 @@ index 08c40834c4..5c110d7211 100644
15561652
and sigaction() SA_ONSTACK */
15571653
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
15581654
diff --git a/Modules/makesetup b/Modules/makesetup
1559-
index 9b20e3c9f6..196ff69984 100755
1655+
index 9b20e3c9f6..23be532f6a 100755
15601656
--- a/Modules/makesetup
15611657
+++ b/Modules/makesetup
15621658
@@ -166,7 +166,7 @@
@@ -1576,7 +1672,25 @@ index 9b20e3c9f6..196ff69984 100755
15761672
\$\(*_CFLAGS\)) cpps="$cpps $arg";;
15771673
\$\(*_INCLUDES\)) cpps="$cpps $arg";;
15781674
\$\(*_LIBS\)) libs="$libs $arg";;
1579-
@@ -245,6 +246,7 @@
1675+
@@ -220,7 +221,16 @@
1676+
done
1677+
case $doconfig in
1678+
yes)
1679+
- LIBS="$LIBS $libs"
1680+
+ # sed has a character limit for multiline substitutions on some
1681+
+ # installs. If you have a lot of customized module configurations,
1682+
+ # the LOCALMODLIBS definition can end up exceeding that line length.
1683+
+ # To ensure this doesn't happen, only include $libs if it adds
1684+
+ # something, and put each library definition on it's own line. This
1685+
+ # requires escaping for when this script runs, and escaping for when
1686+
+ # the output is run through sed.
1687+
+ if test "$libs"; then
1688+
+ LIBS="$LIBS \\\\\\\\\\$NL\t$libs"
1689+
+ fi
1690+
MODS="$MODS $mods"
1691+
BUILT="$BUILT $mods"
1692+
;;
1693+
@@ -245,6 +255,7 @@
15801694
*.C) obj=`basename $src .C`.o; cc='$(CXX)';;
15811695
*.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';;
15821696
*.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';;
@@ -1600,7 +1714,7 @@ index aa93e756c6..fcf3784c2f 100644
16001714
sin(pi*x), giving accurate results for all finite x (especially x
16011715
integral or close to an integer). This is here for use in the
16021716
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
1603-
index 4015889441..3cacff0f3f 100644
1717+
index 4015889441..b9d6633213 100644
16041718
--- a/Modules/posixmodule.c
16051719
+++ b/Modules/posixmodule.c
16061720
@@ -69,6 +69,8 @@
@@ -1617,7 +1731,7 @@ index 4015889441..3cacff0f3f 100644
16171731
#endif /* ! __WATCOMC__ || __QNX__ */
16181732

16191733
+// iOS/tvOS/watchOS *define* a number of POSIX functions, but you can't use them
1620-
+// because iOS isn't a conventional multiprocess environment.
1734+
+// because they aren't conventional multiprocess environment.
16211735
+#if TARGET_OS_IPHONE
16221736
+# undef HAVE_EXECV
16231737
+# undef HAVE_FORK

0 commit comments

Comments
 (0)