Demo: -bundle_loader without the need for -undefined #103356
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a illustrative PR - it removes the need for
-undefined dynamic_lookup
by creating a stub bundle loader (that defines each of the expected Python ABI symbols) and then linking each core module using-bundle_loader python3.12.pyabi -flat_namespace
. This causes modules to both be checked for all symbols (yay) as well as a flat namespace (unfortunate but perhaps required as symbols may be defined inpython
orlibpython3.12.dylib
depending on compile type). If it were possible, a potential improvement on this design would be to be able to define those symbols coming from python (python3.12.symbols
is a list) as being flat namespace, but not requiring it wholesale. Another possible fix is if the lines in libpython that do thedlopen
can specify the self module as the effective bundle loader, then without flat namespace, the loader could specify that the required symbols are coming from the current module (which is either the bin or the shared library).dlopen
seems to only assume the bundle loader is the main executable.Basically, at this point its just hacking around
dlopen
on macOS to specify the true bundle loader image as the shared library if need be and the removal of-flat_namespace
to make this 100% legithttps://opensource.apple.com/source/dyld/dyld-519.2.2/dyld3/APIs_macOS.cpp.auto.html