I'm doing the python dynamic module loading dance.
As you likely know, this is not the typical shared library scenario described on all the docs, where an executable is linked against an existing shared lib. Instead cythonized python modules need to call back to the interpreter that loaded them for various functions. Thus, when creating the interpreter, some manner of symbol export must happen, which can then later be linked into a module's dynamic lib to resolve interpreter symbols.
With GNU/GCC this is all magic with the -shared
flag (perhaps GNU's weak symbol feature, unsupported on macOS, helps out?). With a MingW GCC variant on Windows -Wl,--output-def python.def
is required, followed by dlltool -d python.def -l python.dll.a
, which creates some object thingy that can be linked into the subsequent module .so files. I played with lipo python -create -output libpython.dylib
on macOS, but saw that no one else uses this and abandoned it.
The python3 on Darwin uses clang -bundle -undefined dynamic_lookup
, but when I roll my own custom interpreter, building a module by hand with the above gives: ld: warning: -undefined dynamic_lookup may not work with chained fixups
... whatever that means.
Link args of -bundle -bundle_loader ../python
result in NO errors or warnings, but my interpreter cannot load these module .so files either, probably due to some error I have not yet unmasked.
I am hoping to find a solution that works for both Xcode and Homebrew, and that will last for a decade or so, but for now would be happy getting something to work today.