C library system-call wrappers, or the lack thereof
C library system-call wrappers, or the lack thereof
Posted Nov 16, 2018 22:08 UTC (Fri) by mathstuf (subscriber, #69389)In reply to: C library system-call wrappers, or the lack thereof by mathstuf
Parent article: C library system-call wrappers, or the lack thereof
Posted Nov 18, 2018 21:12 UTC (Sun)
by lgerbarg (guest, #57988)
[Link] (1 responses)
Now that I understand what you are trying to do a bit more clearly (sorry about the confusion) -bundle_loader is not appropriate unless you can re-export the symbols from the main executable. I think that would be the best option from a technical perspective, but it is probably unreasonable since it would require changes and back ports to all of the python interpreters.
Assuming that you need to get this to work without making changes to python itself. I think you should pass ld "-undefined dynamic_lookup." It is kind of gross, but it should work for your use case. If there is ever a desire to improve this behavior for future pythons there changes to the interpreter that would make modules work better:
1) Reexporting the symbols from libpython out of the python interpreter itself and using -bundle_loader
Posted Nov 20, 2018 15:16 UTC (Tue)
by mathstuf (subscriber, #69389)
[Link]
> I think you should pass ld "-undefined dynamic_lookup." It is kind of gross
That works for today. And projects which don't only target macOS are almost never going to do what seems like a bad legacy behavior. The "gross" part of this solution is what led to the patch to ld64.
> Renaming or symlinking the library exporting the API to have an unversioned name (like "libpython.dylib") and then having python set an LC_RPATH to the directory containing the dylib/symlink. Then modules could link to them via "@rpath/libpython.dylib" .
The name of the file doesn't matter. The binary must be edited using `install_name_tool -id` to change what gets embedded in the linking binary. And RPATH on macOS is awful. It only applies if explicitly requested and if something says "use me via rpath", no tools (I know of) add the paths automatically and they must be manually added.
C library system-call wrappers, or the lack thereof
or
2) Renaming or symlinking the library exporting the API to have an unversioned name (like "libpython.dylib") and then having python set an LC_RPATH to the directory containing the dylib/symlink. Then modules could link to them via "@rpath/libpython.dylib" .
C library system-call wrappers, or the lack thereof