summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-01-13 18:24:28 (GMT)
committerGitHub <noreply@github.com>2022-01-13 18:24:28 (GMT)
commit6be848922bc0f4c632c255c39de82a45b6480286 (patch)
treec20a5ac0989b76b96cb5e391bd445d21e68eca30 /configure
parent0885999a8e5ffad3fae0302675ad0030e33a15af (diff)
downloadcpython-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')
-rwxr-xr-xconfigure105
1 files changed, 57 insertions, 48 deletions
diff --git a/configure b/configure
index 127b350..ccbf4fc 100755
--- a/configure
+++ b/configure
@@ -775,8 +775,6 @@ MODULE__IO_TRUE
MODULES_SETUP_STDLIB
MODULE_BUILDTYPE
TEST_MODULES
-LIBRARY_DEPS
-STATIC_LIBPYTHON
OPENSSL_RPATH
OPENSSL_LDFLAGS
OPENSSL_LIBS
@@ -877,6 +875,10 @@ READELF
ARFLAGS
ac_ct_AR
AR
+LINK_PYTHON_OBJS
+LINK_PYTHON_DEPS
+LIBRARY_DEPS
+STATIC_LIBPYTHON
GNULD
EXPORTSFROM
EXPORTSYMS
@@ -1007,6 +1009,7 @@ with_cxx_main
with_emscripten_target
with_suffix
enable_shared
+with_static_libpython
enable_profiling
with_pydebug
with_trace_refs
@@ -1048,7 +1051,6 @@ with_openssl_rpath
with_ssl_default_suites
with_builtin_hashlib_hashes
with_experimental_isolated_subinterpreters
-with_static_libpython
enable_test_modules
'
ac_precious_vars='build_alias
@@ -1758,6 +1760,9 @@ Optional Packages:
Emscripten platform
--with-suffix=SUFFIX set executable suffix to SUFFIX (default is empty,
yes is mapped to '.exe')
+ --without-static-libpython
+ do not build libpythonMAJOR.MINOR.a and do not
+ install python.o (default is yes)
--with-pydebug build with Py_DEBUG defined (default is no)
--with-trace-refs enable tracing references for debugging purpose
(default is no)
@@ -1840,9 +1845,6 @@ Optional Packages:
--with-experimental-isolated-subinterpreters
better isolate subinterpreters, experimental build
mode (default is no)
- --without-static-libpython
- do not build libpythonMAJOR.MINOR.a and do not
- install python.o (default is yes)
Some influential environment variables:
PKG_CONFIG path to pkg-config utility
@@ -6428,6 +6430,30 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
$as_echo "$enable_shared" >&6; }
+# --with-static-libpython
+STATIC_LIBPYTHON=1
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-static-libpython" >&5
+$as_echo_n "checking for --with-static-libpython... " >&6; }
+
+# Check whether --with-static-libpython was given.
+if test "${with_static_libpython+set}" = set; then :
+ withval=$with_static_libpython;
+if test "$withval" = no
+then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; };
+ STATIC_LIBPYTHON=0
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; };
+fi
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-profiling" >&5
$as_echo_n "checking for --enable-profiling... " >&6; }
# Check whether --enable-profiling was given.
@@ -6550,6 +6576,31 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDLIBRARY" >&5
$as_echo "$LDLIBRARY" >&6; }
+# 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
+
+
+
+
+# ar program
if test -n "$ac_tool_prefix"; then
for ac_prog in ar aal
@@ -21213,48 +21264,6 @@ $as_echo "no" >&6; }
fi
-# --with-static-libpython
-STATIC_LIBPYTHON=1
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-static-libpython" >&5
-$as_echo_n "checking for --with-static-libpython... " >&6; }
-
-# Check whether --with-static-libpython was given.
-if test "${with_static_libpython+set}" = set; then :
- withval=$with_static_libpython;
-if test "$withval" = no
-then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
- STATIC_LIBPYTHON=0
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-fi
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-
-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
-
-case $ac_sys_system/$ac_sys_emscripten_target in #(
- Emscripten/browser) :
- LIBRARY_DEPS="$LIBRARY_DEPS \$(WASM_STDLIB)" ;; #(
- *) :
- ;;
-esac
-
-
-
-
# Check whether to disable test modules. Once set, setup.py will not build
# test extension modules and "make install" will not install test suites.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --disable-test-modules" >&5