Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-43103: Add configure --without-static-libpython #24418

Merged
merged 1 commit into from
Feb 17, 2021
Merged

bpo-43103: Add configure --without-static-libpython #24418

merged 1 commit into from
Feb 17, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Feb 2, 2021

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

Fix smelly.py and stable_abi.py tools when libpython3.10.a is
missing.

https://bugs.python.org/issue43103

@vstinner
Copy link
Member Author

vstinner commented Feb 2, 2021

I tested 4 cases. CFLAGS="-O0" is just to build Python faster.

(1) disable shared without static

git clean -fdx
./configure CFLAGS="-O0" --without-static-python --prefix $PWD/target
make && make install

Output:

$ /bin/ls -1 target/lib/python3.10/config-3.10-x86_64-linux-gnu/
config.c
config.c.in
install-sh
Makefile
makesetup
__pycache__
python-config.py
Setup
Setup.local

$ find target/ -name "libpython*"
target/lib/libpython3.10.a

=> target/lib/libpython3.10.a is still installed. Should it be not installed?

(2) disable shared with static

git clean -fdx
./configure CFLAGS="-O0" --with-static-python --prefix $PWD/target
make && make install

Output:

$ /bin/ls -1 target/lib/python3.10/config-3.10-x86_64-linux-gnu/
config.c
config.c.in
install-sh
libpython3.10.a
Makefile
makesetup
__pycache__
python-config.py
python.o
Setup
Setup.local

$ find target/ -name "libpython*"
target/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.a
target/lib/libpython3.10.a

(3) enable shared with static

git clean -fdx
./configure --with-static-python --enable-shared --prefix $PWD/target CFLAGS="-O0"
make && make install

Output:

$ ls -1 target/lib/python3.10/config-3.10-x86_64-linux-gnu/
config.c
config.c.in
install-sh
libpython3.10.a
Makefile
makesetup
__pycache__/
python-config.py
python.o
Setup
Setup.local

$ find target/ -name "libpython*"
target/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.a
target/lib/libpython3.10.so.1.0
target/lib/libpython3.10.so
target/lib/libpython3.so

(4) enable shared without static

git clean -fdx
./configure --without-static-python --enable-shared --prefix $PWD/target CFLAGS="-O0"
make && make install

Output:

$ ls -1 target/lib/python3.10/config-3.10-x86_64-linux-gnu/
config.c
config.c.in
install-sh
Makefile
makesetup
__pycache__/
python-config.py
Setup
Setup.local

$ find target/ -name "libpython*"
target/lib/libpython3.10.so.1.0
target/lib/libpython3.10.so
target/lib/libpython3.so

=> target/lib/libpython3.10.a is not installed, as expected.

@vstinner
Copy link
Member Author

vstinner commented Feb 2, 2021

(1) disable shared without static
target/lib/libpython3.10.a is still installed. Should it be not installed?

Update: I fixed the Makefile to not install libpython3.10.a in this case.

@vstinner
Copy link
Member Author

vstinner commented Feb 3, 2021

Tests / Windows (x86) (pull_request) Failing after 18m — Windows (x86)

This failure is unrelated to my PR: "1 test failed: test_asyncio". (The Windows build is not affected by my PR.)

By default, Python no longer builds ``libpythonMAJOR.MINOR.a`` static library
and no longer installs it and ``python.o``. These files are only useful to
build a static Python executable which is an uncommon use case. Add configure
``--without-static-python`` option to build and install these files.
Copy link
Contributor

@lazka lazka Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this read --with-static-python ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the NEWS entry was outdated. I wrote the PR and the NEWS entry. Is it better now?

Copy link
Contributor

@lazka lazka Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if static install is enabled by default now, then yes. thanks!

edit: I was slightly confused by the default change.. ignore my other comments.

@vstinner vstinner changed the title bpo-43103: Don't install libpythonX.Y.a by default bpo-43103: Add configure --without-static-libpython Feb 3, 2021
@vstinner
Copy link
Member Author

vstinner commented Feb 3, 2021

cc @pablogsal @hroncok

@@ -797,6 +797,12 @@ Build Changes

(Contributed by Victor Stinner in :issue:`42856`.)

* Add configure ``--without-static-libpython`` option to not build
``libpythonMAJOR.MINOR.a`` static library and not install ``python.o`` object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``libpythonMAJOR.MINOR.a`` static library and not install ``python.o`` object
``libpythonMAJOR.MINOR.a`` static library and not install the ``python.o`` object

Doc/whatsnew/3.10.rst Outdated Show resolved Hide resolved
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.
@vstinner
Copy link
Member Author

@pablogsal: Thanks, I took all your remarks in account. Would you mind to review the updated PR?

@pablogsal
Copy link
Member

@pablogsal: Thanks, I took all your remarks in account. Would you mind to review the updated PR?

Yup, will re-review today

@pablogsal pablogsal added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 16, 2021
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @pablogsal for commit e1268bd 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 16, 2021
@vstinner
Copy link
Member Author

buildbot/AMD64 FreeBSD Shared PR: Failure

This issue is known and unrelated to my PR: https://bugs.python.org/issue43233

@vstinner
Copy link
Member Author

buildbot/AMD64 Windows10 PR: Failure

Oh, this failure is really strange.

 argv: ['Tools\\buildbot\\test.bat', '-p', 'x64', '-j4', '--junit-xml', 'test-results.xml', '--timeout', '900']
(...)
Windows fatal exception: stack overflow

Current thread 0x00002474 (most recent call first):
  File "D:\buildarea\pull_request.bolen-windows10\build\lib\_pyio.py", line 1619 in __repr__
  File "D:\buildarea\pull_request.bolen-windows10\build\lib\_pyio.py", line 1627 in __repr__
  File "D:\buildarea\pull_request.bolen-windows10\build\lib\_pyio.py", line 1627 in __repr__
(...)
0:03:22 load avg: 15.71 [ 59/426/3] test_exceptions crashed (Exit code 3221225725) -- running: test_zipfile (1 min 4 sec), test_tokenize (3 min 15 sec)
Windows fatal exception: stack overflow

Current thread 0x000023f4 (most recent call first):
  File "D:\buildarea\pull_request.bolen-windows10\build\lib\test\test_exceptions.py", line 585 in f
  File "D:\buildarea\pull_request.bolen-windows10\build\lib\test\test_exceptions.py", line 585 in f
  File "D:\buildarea\pull_request.bolen-windows10\build\lib\test\test_exceptions.py", line 585 in f
(...)
0:04:27 load avg: 14.79 [114/426/6] test_runpy crashed (Exit code 3221225725) -- running: test_socket (31.4 sec), test_asyncio (45.8 sec)
Windows fatal exception: stack overflow

Current thread 0x00002704 (most recent call first):
  File "<frozen zipimport>", line 343 in _get_module_path
  File "<frozen zipimport>", line 725 in _get_module_code
  File "<frozen zipimport>", line 223 in get_filename
(...)
17 tests failed:
    test_exceptions test_fileio test_io test_isinstance test_json
    test_lib2to3 test_logging test_pickle test_pickletools
    test_plistlib test_richcmp test_runpy test_sys test_threading
    test_traceback test_typing test_xml_etree
(...)

buildbot/aarch64 RHEL7 PR: Failure

The classic test_asyncio bug:

1 test altered the execution environment:
    test_asyncio

@vstinner vstinner merged commit 801bb0b into python:master Feb 17, 2021
@vstinner vstinner deleted the static_opt branch February 17, 2021 10:14
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
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.
@edmorley
Copy link

edmorley commented Apr 7, 2022

Hi! I don't suppose this would be eligible for a backport to Python 3.9? If so, would someone mind adding the needs backport to 3.9 label mentioned here?

@vstinner
Copy link
Member Author

vstinner commented Apr 7, 2022

This is a new feature. We don't backport new features to stable branches sadly. https://devguide.python.org/#status-of-python-branches

@edmorley
Copy link

edmorley commented Apr 7, 2022

Ah ok thank you. Since this was build related, I thought there might be some wiggle room.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants