Author vstinner
Recipients vstinner
Date 2021-05-14.16:58:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621011524.07.0.0957325647121.issue44133@roundup.psfhosted.org>
In-reply-to
Content
When Python is built without --enable-shared, the "Py_FrozenMain" is not exported.

When Python is built with --enable-shared, the "Py_FrozenMain" is exported as expected.

I can reproduce the issue with attached reproduce.tar.gz example:

* build.sh exports "func1" symbol
* build_ar.sh doesn't export the "func1" symbol

The difference is that build.sh links directly two object files (.o) into a binary, whereas build_ar.sh creates a static library (.a) and then link the static library into a binary.

Python is always built with a static library (libpythonVERSION.a) which causes the issue.

A solution is to pass -Wl,--whole-archive option to the linker to export *all* symbols exported by all object files, and not only export symbols of the object files which are used.

I'm not sure why, but "Py_FrozenMain" is the *only* impacted symbol of the whole C API.

This issue was discovered by Petr Viktorin who works on the stable ABI:
https://mail.python.org/archives/list/capi-sig@python.org/thread/5QLI3NUP3OSGLCCIBAQOTX4GEJQBWJ6F/
History
Date User Action Args
2021-05-14 16:58:44vstinnersetrecipients: + vstinner
2021-05-14 16:58:44vstinnersetmessageid: <1621011524.07.0.0957325647121.issue44133@roundup.psfhosted.org>
2021-05-14 16:58:44vstinnerlinkissue44133 messages
2021-05-14 16:58:43vstinnercreate