Skip to content

Commit 146e950

Browse files
committed
[3.9] pythongh-114099: Refactor configure and Makefile to accomodate non-macOS frameworks (python#115120)
Part of the PEP 730 work to add iOS support. This change lays the groundwork for introducing iOS/tvOS/watchOS frameworks; it includes the structural refactoring needed so that iOS branches can be added into in a subsequent PR. Summary of changes: * Updates config.sub to the 2024-01-01 release. This is the "as released" version of config.sub. * Adds a RESSRCDIR variable to allow sharing of macOS and iOS Makefile steps. * Adds an INSTALLTARGETS variable so platforms can customise which targets are actually installed. This will be used to exclude certain targets (e.g., binaries, manfiles) from iOS framework installs. * Adds a PYTHONFRAMEWORKINSTALLNAMEPREFIX variable; this is used as the install name for the library. This is needed to allow for iOS frameworks to specify an @rpath-based install name. * Evaluates MACHDEP earlier in the configure process so that ac_sys_system is available. * Modifies _PYTHON_HOST_PLATFORM evaluation for cross-platform builds so that the CPU architecture is differentiated from the host identifier. This will be used to generate a _PYTHON_HOST_PLATFORM definition that includes ABI information, not just CPU architecture. * Differentiates between SOABI_PLATFORM and PLATFORM_TRIPLET. SOABI_PLATFORM is used in binary module names, and includes the ABI, but not the OS or CPU architecture (e.g., math.cpython-313-iphonesimulator.dylib). PLATFORM_TRIPLET is used as the sys._multiarch value, and on iOS will contains the ABI and architecture (e.g., iphoneos-arm64). This differentiation hasn't historically been needed because while macOS is a multiarch platform, it uses a bare darwin as PLATFORM_TRIPLE. * Removes the use of the deprecated -Wl,-single_module flag when compiling macOS frameworks. * Some whitespace normalisation where there was a mix of spaces and tabs in a single block.
1 parent f593889 commit 146e950

File tree

6 files changed

+638
-305
lines changed

6 files changed

+638
-305
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Tools/unicode/data/
114114
/config.status.lineno
115115
# hendrikmuhs/ccache-action@v1
116116
/.ccache
117+
/cross-build/
117118
/platform
118119
/profile-clean-stamp
119120
/profile-run-stamp
@@ -143,4 +144,4 @@ Tools/ssl/win32
143144
/Modules/Setup.bootstrap
144145
/Modules/Setup.stdlib
145146
/Python/deepfreeze/
146-
/Python/frozen_modules/
147+
/Python/frozen_modules/

Makefile.pre.in

+12-5
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ PYTHONFRAMEWORK= @PYTHONFRAMEWORK@
174174
PYTHONFRAMEWORKDIR= @PYTHONFRAMEWORKDIR@
175175
PYTHONFRAMEWORKPREFIX= @PYTHONFRAMEWORKPREFIX@
176176
PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@
177+
PYTHONFRAMEWORKINSTALLNAMEPREFIX= @PYTHONFRAMEWORKINSTALLNAMEPREFIX@
178+
RESSRCDIR= @RESSRCDIR@
177179
# Deployment target selected during configure, to be checked
178180
# by distutils. The export statement is needed to ensure that the
179181
# deployment target is active during build.
@@ -301,6 +303,8 @@ IO_OBJS= \
301303
##########################################################################
302304

303305
LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
306+
LIBFFI_LIBDIR= @LIBFFI_LIBDIR@
307+
LIBFFI_LIB= @LIBFFI_LIB@
304308

305309
##########################################################################
306310
# Parser
@@ -654,7 +658,7 @@ libpython3.so: libpython$(LDVERSION).so
654658
$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
655659

656660
libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
657-
$(CC) -dynamiclib -Wl,-single_module $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
661+
$(CC) -dynamiclib $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
658662

659663

660664
libpython$(VERSION).sl: $(LIBRARY_OBJS)
@@ -678,14 +682,13 @@ $(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
678682
# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
679683
# minimal framework (not including the Lib directory and such) in the current
680684
# directory.
681-
RESSRCDIR=Mac/Resources/framework
682685
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
683686
$(LIBRARY) \
684687
$(RESSRCDIR)/Info.plist
685688
$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
686689
$(CC) -o $(LDLIBRARY) $(PY_CORE_LDFLAGS) -dynamiclib \
687-
-all_load $(LIBRARY) -Wl,-single_module \
688-
-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
690+
-all_load $(LIBRARY) \
691+
-install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLNAMEPREFIX)/$(PYTHONFRAMEWORK) \
689692
-compatibility_version $(VERSION) \
690693
-current_version $(VERSION) \
691694
-framework CoreFoundation $(LIBS);
@@ -1249,7 +1252,11 @@ multisslcompile: build_all
12491252
multissltest: build_all
12501253
$(RUNSHARED) ./$(BUILDPYTHON) Tools/ssl/multissltests.py
12511254

1252-
install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@
1255+
# All install targets use the "all" target as synchronization point to
1256+
# prevent race conditions with PGO builds. PGO builds use recursive make,
1257+
# which can lead to two parallel `./python setup.py build` processes that
1258+
# step on each others toes.
1259+
install: @FRAMEWORKINSTALLFIRST@ @INSTALLTARGETS@ @FRAMEWORKINSTALLLAST@
12531260
if test "x$(ENSUREPIP)" != "xno" ; then \
12541261
case $(ENSUREPIP) in \
12551262
upgrade) ensurepip="--upgrade" ;; \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
configure and Makefile were refactored to accomodate framework builds on
2+
Apple platforms other than macOS.

0 commit comments

Comments
 (0)