From 09e30f3ee6a86bd9de6b82266ada3b1a263d2c02 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 14 May 2021 18:57:51 +0200 Subject: [PATCH] bpo-44133: Export Py_FrozenMain() symbol 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. --- Doc/whatsnew/3.11.rst | 5 +++++ Makefile.pre.in | 2 +- .../next/Build/2021-05-14-19-02-04.bpo-44133.XnroKM.rst | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2021-05-14-19-02-04.bpo-44133.XnroKM.rst 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.