mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-03 05:41:10 +00:00
Fix bundled Python crashing on macOS 26 and older when built with Xcode 27 (#16035)
# Description With Xcode 27, building deps on macOS 26 fails at the Python install step with a segfault, and a libpython built with Xcode 27 crashes on macOS 12–26 the first time anything calls `os.pipe()`, which every plugin `subprocess` call does. The macOS 27 SDK declares `pipe2()` and `dup3()` as macOS 27-only, and CPython 3.12 calls them without a runtime check once configure finds them, so on older systems they resolve to NULL. This keeps CPython on the `pipe()`/`dup2()` fallbacks it already uses with older SDKs; upstream fixed it in 3.13+ ([python/cpython#153711](https://github.com/python/cpython/issues/153711)) but not in 3.12. No change for builds with Xcode 26 or older, or on Linux and Windows. # Screenshots/Recordings/Graphs <!-- > Please attach relevant screenshots to showcase the UI changes. > Please attach images that can help explain the changes. --> ## Tests Rebuilt deps with Xcode 27 on macOS 26.6: the Python install step now completes, the installed libpython no longer imports `pipe2`/`dup3`, and CPython's `test_os`, `test_subprocess` and `test_posix` pass, apart from one test that needs `_testcapi`, which `--disable-test-modules` leaves out. Running CPython's configure against the macOS 26.5 and 27.0 SDKs gives a byte-identical `pyconfig.h` for 26.5 with and without this change, and for 27.0 with it. The x86_64 cross-build path was configured on arm64 to confirm both of its configure runs pick up the change. <!-- > A guide for users on how to download the artifacts from this PR. --> [How to Download Pull Requests Artifacts for Testing](https://www.orcaslicer.com/wiki/how_to_download_pr_artifacts)
This commit is contained in:
Vendored
+11
-1
@@ -151,6 +151,12 @@ elseif(APPLE)
|
||||
# the post-install -add_rpath below.
|
||||
set(_python_ldflags "${_python_arch_flags} -Wl,-headerpad_max_install_names")
|
||||
|
||||
# The macOS 27 SDK declares pipe2() and dup3() as available from macOS 27, so
|
||||
# configure finds them and CPython 3.12 calls them without a runtime check.
|
||||
# Below a macOS 27 deployment target they are weak-linked and resolve to NULL
|
||||
# on older systems, where os.pipe() then segfaults -- in `make install`
|
||||
# (compileall, ensurepip) and in the shipped app alike. Every configure below
|
||||
# keeps the pipe()/dup2() fallbacks (python/cpython#153711).
|
||||
if(IS_CROSS_COMPILE)
|
||||
set(_python_build_tgt --build=${_python_build_arch}-apple-darwin --host=${_python_host_arch}-apple-darwin)
|
||||
set(_python_build_arch_flags "-arch ${_python_build_arch_flag} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
@@ -174,7 +180,8 @@ elseif(APPLE)
|
||||
--enable-shared \
|
||||
--without-static-libpython \
|
||||
--disable-test-modules \
|
||||
--build=${_python_build_arch}-apple-darwin && \
|
||||
--build=${_python_build_arch}-apple-darwin \
|
||||
ac_cv_func_pipe2=no ac_cv_func_dup3=no && \
|
||||
make -j${NPROC} python && \
|
||||
cd '<SOURCE_DIR>' && \
|
||||
env \
|
||||
@@ -191,6 +198,7 @@ elseif(APPLE)
|
||||
--without-static-libpython \
|
||||
--with-openssl='${DESTDIR}' \
|
||||
--disable-test-modules \
|
||||
ac_cv_func_pipe2=no ac_cv_func_dup3=no \
|
||||
${_python_build_tgt} \
|
||||
--with-build-python='${_python_build_python}' \
|
||||
py_cv_module__tkinter=n/a"
|
||||
@@ -213,6 +221,8 @@ elseif(APPLE)
|
||||
--with-openssl=${DESTDIR}
|
||||
--disable-test-modules
|
||||
${_python_build_tgt}
|
||||
ac_cv_func_pipe2=no
|
||||
ac_cv_func_dup3=no
|
||||
# Tcl/Tk 9.0 (e.g. from Homebrew) is incompatible with CPython 3.12's
|
||||
# _tkinter; OrcaSlicer's embedded Python does not need tkinter anyway.
|
||||
py_cv_module__tkinter=n/a
|
||||
|
||||
Reference in New Issue
Block a user