Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
919efcc
Add support for ARM64 to the pythonw tool
ronaldoussoren Jul 20, 2020
69c39f3
Add support for "universal2" as a fat binary target on macOS
ronaldoussoren Jul 20, 2020
3940c86
Tweak ctypes.macholib.dyld to work with the shared library cache.
ronaldoussoren Jul 20, 2020
deda5f0
Silence compile time warning
ronaldoussoren Jul 20, 2020
ea3c200
macOS/arm64 support, based on GH-21249
ronaldoussoren Jul 20, 2020
552bca8
Fix test for macOS before 10.10
ronaldoussoren Jul 20, 2020
e0c23a1
ARM64 is a valid platform for macOS
ronaldoussoren Jul 20, 2020
e637a77
Unconditionally use uint32_t here.
ronaldoussoren Jul 20, 2020
02fb660
First stab at deploying to an earlier version of macOS than the build…
ronaldoussoren Jul 21, 2020
ba2f5a3
Update build-installer.py for universal2 builds
ronaldoussoren Jul 26, 2020
8e3b454
Merge ctypes changes from Apple (PR 21241)
ronaldoussoren Jul 26, 2020
87c942b
The archive-deps.py script isn't really useful
ronaldoussoren Jul 26, 2020
515fbe6
Merge branch 'macos-deploy-to-earlier' into macos11-deploy-earlier-br…
ronaldoussoren Oct 20, 2020
eee5437
Cleanup the code to check at runtime for a couple of APIs.
ronaldoussoren Oct 20, 2020
3a1d4f2
Dynamicly fill posix._have_functions as well
ronaldoussoren Oct 20, 2020
2f019f4
Changes after testing with Xcode 6.2 on macOS 10.9
ronaldoussoren Oct 21, 2020
cec3da7
Code formatting
ronaldoussoren Oct 21, 2020
86b5cf3
Fix a number of errors in weaklinking support
ronaldoussoren Oct 21, 2020
d604cef
Merge branch 'macos11-deploy-earlier-branch' of github.com:ronaldouss…
ronaldoussoren Oct 21, 2020
dde0ba4
Implement tests for weak linked symbols.
ronaldoussoren Oct 21, 2020
7ac26c4
Finish the test for os.link behaviour
ronaldoussoren Oct 21, 2020
191a2d7
posixmodule.c uses multi-phase initialization
ronaldoussoren Oct 21, 2020
e6d195b
Make sure some form of prep_cif is called, even if the variadic versi…
ronaldoussoren Oct 21, 2020
cfb02ba
Move the removal of unavailable functions to the module exec
ronaldoussoren Oct 21, 2020
003dae8
Improved error handling
ronaldoussoren Oct 21, 2020
004ba4e
Remove '-arch arm64' from the compiler arguments when necessary
ronaldoussoren Oct 21, 2020
6019346
check that weak linking works for the time module
ronaldoussoren Oct 22, 2020
54576ab
Drop the DEPS_ONLY changes
ronaldoussoren Oct 22, 2020
6af77ab
Undo change to default PATH
ronaldoussoren Oct 22, 2020
b653df9
Use configure to detect the presence of _dyld_shared_cache_contains_path
ronaldoussoren Oct 22, 2020
98af7b3
Revert unnecessary change
ronaldoussoren Oct 22, 2020
817d9bf
Updates to timemodule.c
ronaldoussoren Oct 22, 2020
8684d9d
Stricter checking of __builtin_available
ronaldoussoren Oct 22, 2020
0b44610
Clean up setup.py
ronaldoussoren Oct 22, 2020
36deb92
Fix build failures on Linux
ronaldoussoren Oct 22, 2020
33d5710
Fix typo
ronaldoussoren Oct 22, 2020
c3113eb
Remove reference to non-existing probe function
ronaldoussoren Oct 22, 2020
587e53e
One more attempt at building on Linux...
ronaldoussoren Oct 22, 2020
24ef276
A bit of clean up of the setup.py logic.
ronaldoussoren Oct 22, 2020
e0614bc
Fix patchcheck issues
ronaldoussoren Oct 22, 2020
e6478fa
add prefix to f-strings
ronaldoussoren Oct 22, 2020
3f72949
Add missing preprocessor guards
ronaldoussoren Oct 22, 2020
5daff99
Use the correct cut-off for the availability of clock_gettime and
ronaldoussoren Oct 22, 2020
6681261
Fix error in preprocessor logic for os.chmod implementation
ronaldoussoren Oct 22, 2020
b17a3d5
Merge branch 'master' into macos11-deploy-earlier-branch
ronaldoussoren Oct 22, 2020
7e64e95
the sid attribute for posix_spawn is only available on recent version…
ronaldoussoren Oct 31, 2020
fef2e93
Changes due to review by Victor Stinner
ronaldoussoren Oct 31, 2020
24eb0d0
Merge branch 'macos11-deploy-earlier-branch' of github.com:ronaldouss…
ronaldoussoren Oct 31, 2020
296666b
inor changes
ronaldoussoren Nov 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changes due to review by Victor Stinner
  • Loading branch information
ronaldoussoren committed Oct 31, 2020
commit fef2e93a846b12cf01d625c5c32d07e33b03e907
11 changes: 3 additions & 8 deletions Lib/test/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,9 @@ def test_posix_spawnp(self):
class TestPosixWeaklinking(unittest.TestCase):
# These test cases verify that weak linking support on macOS works
# as expected. These cases only test new behaviour introduced by weak linking,
# regular behaviour is tested by the normal test cases.
# regular behaviour is tested by the normal test cases.
#
# See the section on Weak Linking in Mac/README.txt for more information.
def setUp(self):
import sysconfig
import platform
Expand Down Expand Up @@ -2027,9 +2029,6 @@ def test_link(self):
finally:
support.rmtree(base_path)
Comment thread
ronaldoussoren marked this conversation as resolved.
Outdated

Comment thread
ronaldoussoren marked this conversation as resolved.
Outdated



def test_listdir_scandir(self):
self._verify_available("HAVE_FDOPENDIR")
if self.mac_ver >= (10, 10):
Expand Down Expand Up @@ -2139,10 +2138,6 @@ def test_utime(self):
with self.assertRaisesRegex(NotImplementedError, "follow_symlinks unavailable"):
os.utime("path", follow_symlinks=False)

# XXX: Check if this test is correct, the implementation of os.utime
# is fairly complicated



def test_main():
try:
Expand Down
19 changes: 10 additions & 9 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,24 +1046,25 @@ class TestTimeWeaklinking(unittest.TestCase):
# These test cases verify that weak linking support on macOS works
Comment thread
ronaldoussoren marked this conversation as resolved.
# as expected. These cases only test new behaviour introduced by weak linking,
# regular behaviour is tested by the normal test cases.
def setUp(self):
#
# See the section on Weak Linking in Mac/README.txt for more information.
def test_clock_functions(self):
import sysconfig
import platform

config_vars = sysconfig.get_config_vars()
self.available = { nm for nm in config_vars if nm.startswith("HAVE_") and config_vars[nm] }
self.mac_ver = tuple(int(part) for part in platform.mac_ver()[0].split("."))
var_name = "HAVE_CLOCK_GETTIME"
if var_name not in config_vars or not config_vars[var_name]:
raise unittest.SkipTest(f"{var_name} is not available")

def _verify_available(self, name):
if name not in self.available:
raise unittest.SkipTest(f"{name} not weak-linked")
mac_ver = tuple(int(x) for x in platform.mac_ver()[0].split("."))

def test_clock_functions(self):
self._verify_available("HAVE_CLOCK_GETTIME")
clock_names = [
"CLOCK_MONOTONIC", "clock_gettime", "clock_gettime_ns", "clock_settime",
"clock_settime_ns", "clock_getres"]
if self.mac_ver >= (10, 12):

Comment thread
ronaldoussoren marked this conversation as resolved.
Outdated

if mac_ver >= (10, 12):
for name in clock_names:
self.assertTrue(hasattr(time, name), f"time.{name} is not available")

Expand Down
37 changes: 37 additions & 0 deletions Mac/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ support ppc (Xcode 4 on 10.6 and later systems). The flavor can be specified
using the configure option ``--with-universal-archs=VALUE``. The following
values are available:

* ``universal2``: ``arm64``, ``x86_64``
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not all also contain arm64?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to change the meaning of existing sets. It is also not possible to build fat binaries with arm64 and ppc or i386 with a single compiler, the current compiler in Xcode only supports arm64 and x86_64.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 3.10 we can reconsider the sets of architectures to support, possibly defaulting to "universal2" and only keeping that and "intel" (for folks still needing 32-bit support). But that's for another issue.


* ``intel``: ``i386``, ``x86_64``

* ``intel-32``: ``i386``
Expand Down Expand Up @@ -155,6 +157,8 @@ following combinations of SDKs and universal-archs flavors are available:

* 10.15 and later SDKs support ``intel-64`` only

* 11.0 and later SDKs support ``universal2``

The makefile for a framework build will also install ``python3.x-32``
binaries when the universal architecture includes at least one 32-bit
architecture (that is, for all flavors but ``64-bit`` and ``intel-64``).
Expand Down Expand Up @@ -352,6 +356,39 @@ A framework install also installs some applications in ``/Applications/Python X.
And lastly a framework installation installs files in ``/usr/local/bin``, all of
them symbolic links to files in ``/Library/Frameworks/Python.framework/Versions/X.Y/bin``.

Weak linking support
====================

The CPython sources support building with the latest SDK while targetting deployment
to macOS 10.9. This is done through weak linking of symbols introduced in macOS
10.10 or later and checking for their availability at runtime.

This requires the use of Apple's compiler toolchain on macOS 10.13 or later.

The basic implementation pattern is:

* ``HAVE_<FUNCTION>`` is a macro defined (or not) by the configure script

* ``HAVE_<FUNCTION>_RUNTIME`` is a macro defined in the relevant source
files. This expands to a call to ``__builtin_available`` when using
a new enough Apple compiler, and to a true value otherwise.

* Use ``HAVE_<FUNCTION>_RUNTIME`` before calling ``<function>``. This macro
*must* be used a the sole expression in an if statement::

if (HAVE_<FUNCTION>_RUNTIME) {
/* <function> is available */
}

Or:

if (HAVE_<FUNCTION>_RUNTIME) {} else {
/* <function> is not available */
}

Using other patterns (such as ``!HAVE_<FUNCTION>_RUNTIME``) is not supported
by Apple's compilers.


Resources
=========
Expand Down