Tobias Bergkvist <tob...@bergkv.ist> added the comment:

This makes a lot of sense now.

Thank you so much for the thorough explanation Ned - and for highlighting where 
my assumptions were wrong!

I didn’t realise I needed to specify MACOSX_DEPLOYMENT_TARGET to enable 
backwards compatibility. Is there a reason for not setting this to as old a 
version as possible by default when running ./configure? (Bigger binaries? Or 
something else?)

If I understand correctly, the following two statements are now equivalent (in 
Python >= 3.9, but not in Python == 3.8), after the added Python-support for 
weak linking you mention:

```
if (__builtin_available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)) { // 
...
If (HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH_RUNTIME) { // ...
```
From: 
https://github.com/python/cpython/blob/3d315c311676888201f4a3576e4ee3698684a3a2/Modules/_ctypes/callproc.c#L1452


And in order to support the deprecated case of building on an older 
MacOS-version, I would want to do something like the following:

```
#ifdef __APPLE__
#ifdef HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH
// leave current implementation as is
#else
// dynamic loading implementation
#endif
#endif
```

That way, dynamic loading will only be used when building on old MacOS, and we 
keep the current code path using weak linking when possible.

This means we will still get useful compiler errors if for example Apple 
decides to suddenly remove the _dyld_shared_cache_contains_path symbol again in 
the future, or change its signature - rather than having to wait for the test 
suite to fail. It makes sense to prioritise good error reporting for the latest 
version of MacOS, since this will reduce the debugging time for CPython 
developers whenever Apple introduces new breaking changes to MacOS.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44689>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to