Skip to content

Commit 367e0f6

Browse files
authored
Fix Python 3.13 builds on macOS (#8)
1 parent 520e9d3 commit 367e0f6

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

cpython-unix/build-cpython.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_10}" ]; then
146146
patch -p1 -i ${ROOT}/patch-makesetup-deduplicate-objs.patch
147147
fi
148148

149+
# testembed links against Tcl/Tk and libpython which already has Tcl/Tk leading
150+
# duplicate symbols and warnings from objc (which causes test failures).
151+
if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_13}" ]; then
152+
patch -p1 -i ${ROOT}/patch-make-testembed-nolink-tcltk.patch
153+
fi
154+
149155
# The default build rule for the macOS dylib doesn't pick up libraries
150156
# from modules / makesetup. So patch it accordingly.
151157
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]; then
@@ -444,6 +450,12 @@ if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
444450
export MACOSX_DEPLOYMENT_TARGET="${APPLE_MIN_DEPLOYMENT_TARGET}"
445451
fi
446452

453+
# ptsrname_r is only available in SDK 13.4+
454+
if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
455+
echo "Disabling ptsname_r due to macOS SDK 13.4+ requirement."
456+
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} ac_cv_func_ptsname_r=no"
457+
fi
458+
447459
# We use ndbm on macOS and BerkeleyDB elsewhere.
448460
if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
449461
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} --with-dbmliborder=ndbm"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
diff --git a/Makefile.pre.in b/Makefile.pre.in
2+
--- a/Makefile.pre.in
3+
+++ b/Makefile.pre.in
4+
@@ -1432,6 +1432,8 @@
5+
$(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/build/generate_re_casefix.py $(srcdir)/Lib/re/_casefix.py
6+
7+
Programs/_testembed: Programs/_testembed.o $(LINK_PYTHON_DEPS)
8+
+ $(eval MODLIBS := $(subst -Xlinker -hidden-ltcl8.6, , $(MODLIBS)))
9+
+ $(eval MODLIBS := $(subst -Xlinker -hidden-ltk8.6, , $(MODLIBS)))
10+
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)

cpython-unix/targets.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ thumb7k-apple-watchos:
546546

547547
# Intel macOS.
548548
#
549-
# We target compatibility with macOS 10.13+ for compatibility with older Apple
549+
# We target compatibility with macOS 10.9+ for compatibility with older Apple
550550
# machines.
551551
x86_64-apple-darwin:
552552
host_platforms:
@@ -566,7 +566,7 @@ x86_64-apple-darwin:
566566
target_cflags:
567567
- '-arch'
568568
- 'x86_64'
569-
- '-mmacosx-version-min=10.13.4'
569+
- '-mmacosx-version-min=10.9'
570570
# Suppress extremely verbose warnings we see with LLVM 10.
571571
- '-Wno-nullability-completeness'
572572
- '-Wno-expansion-to-defined'
@@ -581,7 +581,7 @@ x86_64-apple-darwin:
581581
target_ldflags:
582582
- '-arch'
583583
- 'x86_64'
584-
- '-mmacosx-version-min=10.13.4'
584+
- '-mmacosx-version-min=10.9'
585585
needs:
586586
- autoconf
587587
- bzip2

src/validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static PLATFORM_TAG_BY_TRIPLE: Lazy<HashMap<&'static str, &'static str>> = Lazy:
461461
("mips64el-unknown-linux-gnuabi64", "todo"),
462462
("ppc64le-unknown-linux-gnu", "linux-powerpc64le"),
463463
("s390x-unknown-linux-gnu", "linux-s390x"),
464-
("x86_64-apple-darwin", "macosx-10.13-x86_64"),
464+
("x86_64-apple-darwin", "macosx-10.9-x86_64"),
465465
("x86_64-apple-ios", "iOS-x86_64"),
466466
("x86_64-pc-windows-msvc", "win-amd64"),
467467
("x86_64-unknown-linux-gnu", "linux-x86_64"),
@@ -1100,7 +1100,7 @@ fn validate_macho<Mach: MachHeader<Endian = Endianness>>(
11001100
bytes: &[u8],
11011101
) -> Result<()> {
11021102
let advertised_target_version =
1103-
semver::Version::parse(&format!("{}", advertised_target_version))?;
1103+
semver::Version::parse(&format!("{}.0", advertised_target_version))?;
11041104
let advertised_sdk_version = semver::Version::parse(&format!("{}.0", advertised_sdk_version))?;
11051105

11061106
let endian = header.endian()?;

0 commit comments

Comments
 (0)