bpo-43103: Add configure --without-static-libpython (GH-24418)

Add a new configure --without-static-libpython option to not build
the libpythonMAJOR.MINOR.a static library and not install the
python.o object file.

Fix smelly.py and stable_abi.py tools when libpython3.10.a is
missing.
This commit is contained in:
Victor Stinner 2021-02-17 11:14:42 +01:00 committed by GitHub
parent 6a4177516b
commit 801bb0b503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 25 deletions

View File

@ -820,6 +820,12 @@ Build Changes
(Contributed by Victor Stinner in :issue:`42856`.)
* Add a new configure ``--without-static-libpython`` option to not build the
``libpythonMAJOR.MINOR.a`` static library and not install the ``python.o``
object file.
(Contributed by Victor Stinner in :issue:`43103`.)
C API Changes
=============

View File

@ -236,6 +236,9 @@ PY3LIBRARY= @PY3LIBRARY@
DLLLIBRARY= @DLLLIBRARY@
LDLIBRARYDIR= @LDLIBRARYDIR@
INSTSONAME= @INSTSONAME@
LIBRARY_DEPS= @LIBRARY_DEPS@
PY_ENABLE_SHARED= @PY_ENABLE_SHARED@
STATIC_LIBPYTHON= @STATIC_LIBPYTHON@
LIBS= @LIBS@
@ -578,7 +581,7 @@ clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
# Build the interpreter
$(BUILDPYTHON): Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS)
$(BUILDPYTHON): Programs/python.o $(LIBRARY_DEPS)
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
platform: $(BUILDPYTHON) pybuilddir.txt
@ -713,7 +716,7 @@ Makefile Modules/config.c: Makefile.pre \
@echo "The Makefile was updated, you may need to re-run make."
Programs/_testembed: Programs/_testembed.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) $(EXPORTSYMS)
Programs/_testembed: Programs/_testembed.o $(LIBRARY_DEPS)
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/_testembed.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS)
############################################################################
@ -1305,19 +1308,21 @@ altbininstall: $(BUILDPYTHON) @FRAMEWORKPYTHONW@
fi; \
(cd $(DESTDIR)$(BINDIR); $(LN) python$(LDVERSION)$(EXE) python$(VERSION)$(EXE)); \
fi
if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
if test -n "$(DLLLIBRARY)" ; then \
$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
else \
$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
if test $(LDLIBRARY) != $(INSTSONAME); then \
(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
fi \
@if test "$(PY_ENABLE_SHARED)" = 1 -o "$(STATIC_LIBPYTHON)" = 1; then \
if test -f $(LDLIBRARY) && test "$(PYTHONFRAMEWORKDIR)" = "no-framework" ; then \
if test -n "$(DLLLIBRARY)" ; then \
$(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
else \
$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
if test $(LDLIBRARY) != $(INSTSONAME); then \
(cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
fi \
fi; \
if test -n "$(PY3LIBRARY)"; then \
$(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
fi; \
else true; \
fi; \
if test -n "$(PY3LIBRARY)"; then \
$(INSTALL_SHARED) $(PY3LIBRARY) $(DESTDIR)$(LIBDIR)/$(PY3LIBRARY); \
fi; \
else true; \
fi
if test "x$(LIPO_32BIT_FLAGS)" != "x" ; then \
rm -f $(DESTDIR)$(BINDIR)python$(VERSION)-32$(EXE); \
@ -1661,19 +1666,21 @@ libainstall: @DEF_MAKE_RULE@ python-config
else true; \
fi; \
done
@if test -d $(LIBRARY); then :; else \
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
if test "$(SHLIB_SUFFIX)" = .dll; then \
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
@if test "$(STATIC_LIBPYTHON)" = 1; then \
if test -d $(LIBRARY); then :; else \
if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
if test "$(SHLIB_SUFFIX)" = .dll; then \
$(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
else \
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
fi; \
else \
$(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
echo Skip install of $(LIBRARY) - use make frameworkinstall; \
fi; \
else \
echo Skip install of $(LIBRARY) - use make frameworkinstall; \
fi; \
$(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o; \
fi
$(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
$(INSTALL_DATA) Programs/python.o $(DESTDIR)$(LIBPL)/python.o
$(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
$(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
$(INSTALL_DATA) $(srcdir)/Modules/Setup $(DESTDIR)$(LIBPL)/Setup

View File

@ -0,0 +1,3 @@
Add a new configure ``--without-static-libpython`` option to not build the
``libpythonMAJOR.MINOR.a`` static library and not install the ``python.o``
object file.

View File

@ -136,11 +136,14 @@ def check_extensions():
def main():
nsymbol = 0
# static library
LIBRARY = sysconfig.get_config_var('LIBRARY')
if not LIBRARY:
raise Exception("failed to get LIBRARY variable from sysconfig")
nsymbol = check_library(LIBRARY)
if os.path.exists(LIBRARY):
nsymbol += check_library(LIBRARY)
# dynamic library
LDLIBRARY = sysconfig.get_config_var('LDLIBRARY')

View File

@ -2,8 +2,9 @@
import argparse
import glob
import re
import os.path
import pathlib
import re
import subprocess
import sys
import sysconfig
@ -213,7 +214,8 @@ def check_symbols(parser_args):
LIBRARY = sysconfig.get_config_var("LIBRARY")
if not LIBRARY:
raise Exception("failed to get LIBRARY variable from sysconfig")
check_library(parser_args.stable_abi_file, LIBRARY, abi_funcs)
if os.path.exists(LIBRARY):
check_library(parser_args.stable_abi_file, LIBRARY, abi_funcs)
# dynamic library
LDLIBRARY = sysconfig.get_config_var("LDLIBRARY")

40
configure vendored
View File

@ -624,6 +624,8 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
TEST_MODULES
LIBRARY_DEPS
STATIC_LIBPYTHON
OPENSSL_LDFLAGS
OPENSSL_LIBS
OPENSSL_INCLUDES
@ -856,6 +858,7 @@ with_openssl
with_ssl_default_suites
with_builtin_hashlib_hashes
with_experimental_isolated_subinterpreters
with_static_libpython
enable_test_modules
'
ac_precious_vars='build_alias
@ -1602,6 +1605,9 @@ 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:
MACHDEP name for machine-dependent library files
@ -17776,6 +17782,40 @@ $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; 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
# 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

View File

@ -5882,6 +5882,33 @@ 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; 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
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)