bpo-41100: ctypes: check _dyld_shared_cache_contains_path in find_library by lawrence-danna-apple · Pull Request #21241 · python/cpython
System libraries in Mac OS 11 may be present only in the shared cache,
with the actual mach-o file not present in the corresponding location
on the filesystem. ctypes.util.find_library should check the
shared cache in order to behave consistently across Mac OS 10.15
and earlier and Mac OS 11.0 and later.
Is it necessary to add _dyld_shared_cache_contains_path, or is safe to assume libraries in /usr/lib and /lib are in the cache?
In PyObjC similar code to find_library assumes that a library is in the shared cache if (a) the library path starts with "/usr/lib" or "/lib" and (b) there is a symbolic link (such as /usr/lib/libSystem.dylib).
I'm not too happy about using a private symbol, that tends to be fragile.
"I'm not too happy about using a private symbol, that tends to be fragile"
I just spoke to dyld engineers, _dyld_shared_cache_contains_path will be made a public API in Mac OS 11 Seed 3
I was thinking we'd add it as a private symbol now, and then update it to including dyld.h when Seed 3 is out.
"Is it necessary to add _dyld_shared_cache_contains_path, or is safe to assume libraries in /usr/lib and /lib are in the cache?"
I think it is necessary, because if we just assumed any name under /lib was in the cache, then it would think literally anything you ask for is in the cache. find_library("FOO") would return /lib/libFOO.dylib, which is not what we want.
System libraries in Mac OS 11 may be present only in the shared cache, with the actual mach-o file not present in the corresponding location on the filesystem. ctypes.util.find_library should check the shared cache in order to behave consistently across Mac OS 10.15 and earlier and Mac OS 11.0 and later.
| #endif | ||
|
|
||
| #ifdef __APPLE__ | ||
| extern bool _dyld_shared_cache_contains_path(const char* path) __attribute__((weak_import)); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced with #include <mach-o/dyld.h> after Seed 3
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please wait for official API here? or at least have another PR to clean this up which we can merge later?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seed 3 is out today 🎉
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it got pushed out to seed 4
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in Xcode 12 beta 4, only enough with the same name but with documentation in a header file.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, updated the pull request to include mach-o/dyld.h instead of declaring a weak import
samschott pushed a commit to samschott/maestral-cocoa that referenced this pull request
Thanks for the PR. It has been included in and superseded by GH-22855,
minrk
mentioned this pull request