I am curious what the expected technique for statically linking libexpat, libhacl, and libmpdec is. Python builds them and leaves them in the build tree in the corresponding Modules subdirectories.
But make install doesn’t seem to put them into python-<version>/lib and it also doesn’t seem to create a .pc file so there is no way to inquire what extra libs we need to link. Presumably I’m doing something wrong, does anyone have tips?
These LIBEXPAT_LDFLAGS go into MODULE_PYEXPAT_LDFLAGS which go into LOCALMODLIBS which go into MODLIBS which go into the flags to link the .so file. So it seems that the issue is that we’re using the libpython.a target and then linking an executable directly from that, and we’d have the same problem even if we were linking a linux binary. I wonder if we should be getting the MODLIBS variable out of the Makefile and passing that at link time.
means that you have statically linked expat into python?
I think what it means is that when you link libpython.a into an executable/shared library you should pass -lm cpython/Modules/expat/libexpat.a as link arguments. So the resulting libpython.so will contain statically linked expat but libpython.a does not include the expat objects.
You could checked to see if libpython.a contains the expat symbols?
I checked and it doesn’t contain them. Instead, these symbols are added when libpython.so is linked from libpython.a. I think it would be helpful if libpython.a did include them though – it seems to me that taking libpython.a and linking it into your own executable / shared lib currently requires some guessing to figure out the appropriate link args.
There is a target in the Makefile called libainstall that I am using to install libpython.a into the install directory, but it doesn’t seem to install libexpat, libhacl, libmpdec etc. Perhaps it should?