diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 503688294072a3..22503f4540f058 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -103,6 +103,11 @@ Optimizations Build Changes ============= +* The Python binary now builds the libpython static library using + ``-Wl,--whole-archive`` linker option to export all symbols exported by + object files. Previously, the ``Py_FrozenMain`` symbol was not exported. + (Contributed by Victor Stinner in :issue:`44133`.) + Deprecated ========== diff --git a/Makefile.pre.in b/Makefile.pre.in index 080318bf454f6c..1eb227b3c5d7c9 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -587,7 +587,7 @@ clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c # Build the interpreter $(BUILDPYTHON): Programs/python.o $(LIBRARY_DEPS) - $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) + $(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o -Wl,--whole-archive $(BLDLIBRARY) -Wl,--no-whole-archive $(LIBS) $(MODLIBS) $(SYSLIBS) platform: $(BUILDPYTHON) pybuilddir.txt $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform diff --git a/Misc/NEWS.d/next/Build/2021-05-14-19-02-04.bpo-44133.XnroKM.rst b/Misc/NEWS.d/next/Build/2021-05-14-19-02-04.bpo-44133.XnroKM.rst new file mode 100644 index 00000000000000..c1756cc7ac2d7f --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-05-14-19-02-04.bpo-44133.XnroKM.rst @@ -0,0 +1,4 @@ +The Python binary now builds the libpython static library using +``-Wl,--whole-archive`` linker option to export all symbols exported by +object files. Previously, the ``Py_FrozenMain`` symbol was not exported. +Patch by Victor Stinner.