diff options
author | Victor Stinner <vstinner@python.org> | 2022-01-13 18:24:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-13 18:24:28 (GMT) |
commit | 6be848922bc0f4c632c255c39de82a45b6480286 (patch) | |
tree | c20a5ac0989b76b96cb5e391bd445d21e68eca30 /configure.ac | |
parent | 0885999a8e5ffad3fae0302675ad0030e33a15af (diff) | |
download | cpython-6be848922bc0f4c632c255c39de82a45b6480286.zip cpython-6be848922bc0f4c632c255c39de82a45b6480286.tar.gz cpython-6be848922bc0f4c632c255c39de82a45b6480286.tar.bz2 |
bpo-44133: Link Python executable with object files (GH-30556)
When Python is built without --enable-shared, the "python" program is
now linked to object files, rather than being linked to the Python
library (libpython.a), to make sure that all symbols are exported.
Previously, the linker omitted some symbols like the Py_FrozenMain()
function.
When Python is configured with --without-static-libpython, the Python
static library (libpython.a) is no longer built.
* Check --without-static-libpython earlier in configure.ac
* Add LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variables to Makefile.
* test_capi now ensures that the "Py_FrozenMain" symbol is exported.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/configure.ac b/configure.ac index e5ebf7b..89041b2 100644 --- a/configure.ac +++ b/configure.ac @@ -1231,6 +1231,23 @@ then fi AC_MSG_RESULT($enable_shared) +# --with-static-libpython +STATIC_LIBPYTHON=1 +AC_MSG_CHECKING(for --with-static-libpython) +AC_ARG_WITH(static-libpython, + AS_HELP_STRING([--without-static-libpython], + [do not build libpythonMAJOR.MINOR.a and do not install python.o (default is yes)]), +[ +if test "$withval" = no +then + AC_MSG_RESULT(no); + STATIC_LIBPYTHON=0 +else + AC_MSG_RESULT(yes); +fi], +[AC_MSG_RESULT(yes)]) +AC_SUBST(STATIC_LIBPYTHON) + AC_MSG_CHECKING(for --enable-profiling) AC_ARG_ENABLE(profiling, AS_HELP_STRING([--enable-profiling], [enable C-level code profiling with gprof (default is no)])) @@ -1336,6 +1353,31 @@ fi AC_MSG_RESULT($LDLIBRARY) +# LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable +LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)' +LINK_PYTHON_DEPS='$(LIBRARY_DEPS)' +if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then + LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS" + if test "$STATIC_LIBPYTHON" = 1; then + LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS" + fi + # Link Python program to the shared library + LINK_PYTHON_OBJS='$(BLDLIBRARY)' +else + if test "$STATIC_LIBPYTHON" = 0; then + # Build Python needs object files but don't need to build + # Python static library + LINK_PYTHON_DEPS="$LIBRARY_DEPS \$(LIBRARY_OBJS)" + fi + LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS" + # Link Python program to object files + LINK_PYTHON_OBJS='$(LIBRARY_OBJS)' +fi +AC_SUBST(LIBRARY_DEPS) +AC_SUBST(LINK_PYTHON_DEPS) +AC_SUBST(LINK_PYTHON_OBJS) + +# ar program AC_SUBST(AR) AC_CHECK_TOOLS(AR, ar aal, ar) @@ -6273,39 +6315,6 @@ else fi], [AC_MSG_RESULT(no)]) -# --with-static-libpython -STATIC_LIBPYTHON=1 -AC_MSG_CHECKING(for --with-static-libpython) -AC_ARG_WITH(static-libpython, - AS_HELP_STRING([--without-static-libpython], - [do not build libpythonMAJOR.MINOR.a and do not install python.o (default is yes)]), -[ -if test "$withval" = no -then - AC_MSG_RESULT(no); - STATIC_LIBPYTHON=0 -else - AC_MSG_RESULT(yes); -fi], -[AC_MSG_RESULT(yes)]) -LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)' -if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then - LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS" - if test "$STATIC_LIBPYTHON" = 1; then - LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS" - fi -else - LIBRARY_DEPS="\$(LIBRARY) $LIBRARY_DEPS" -fi - -dnl browser needs a WASM assets stdlib bundle -AS_CASE([$ac_sys_system/$ac_sys_emscripten_target], - [Emscripten/browser], [LIBRARY_DEPS="$LIBRARY_DEPS \$(WASM_STDLIB)"], -) - -AC_SUBST(STATIC_LIBPYTHON) -AC_SUBST(LIBRARY_DEPS) - # Check whether to disable test modules. Once set, setup.py will not build # test extension modules and "make install" will not install test suites. AC_MSG_CHECKING(for --disable-test-modules) |