This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients nascheme, ned.deily, pablogsal, vstinner
Date 2020-11-10.14:30:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605018603.84.0.157716936833.issue42307@roundup.psfhosted.org>
In-reply-to
Content
Oh! I managed to build a static Python with the following commands:

cd /opt/pymaster/lib/python3.10/config-3.10-x86_64-linux-gnu
gcc -static -o ~/python-static python.o -L. $(./python-config.py --libs --embed)

I get a static binary:

$ ldd ~/python-static 
	not a dynamic executable

And it works as expected:

$ ~/python-static 
Python 3.10.0a2+ (heads/master:1f73c320e2, Nov 10 2020, 11:47:55) 
[GCC 10.2.1 20201016 (Red Hat 10.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 


But... does any user really build Python manually after Python is installed? The Python build system couldn't handle that as part of the regular build? Maybe using a new configure --enable-static flag?


I'm not a fan of static binaries. For example, the linker emits many warnings about static linking:

/usr/bin/ld: ./libpython3.10.a(dynload_shlib.o): in function `_PyImport_FindSharedFuncptr':
/home/vstinner/python/master/./Python/dynload_shlib.c:100: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: ./libpython3.10.a(posixmodule.o): in function `os_getgrouplist_impl':
/home/vstinner/python/master/./Modules/posixmodule.c:7411: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: ./libpython3.10.a(posixmodule.o): in function `os_initgroups_impl':
/home/vstinner/python/master/./Modules/posixmodule.c:7610: warning: Using 'initgroups' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: ./libpython3.10.a(pwdmodule.o): in function `pwd_getpwall_impl':
/home/vstinner/python/master/./Modules/pwdmodule.c:302: warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /home/vstinner/python/master/./Modules/pwdmodule.c:301: warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /home/vstinner/python/master/./Modules/pwdmodule.c:307: warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: ./libpython3.10.a(pwdmodule.o): in function `pwd_getpwnam_impl':
/home/vstinner/python/master/./Modules/pwdmodule.c:249: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: ./libpython3.10.a(pwdmodule.o): in function `pwd_getpwuid':
/home/vstinner/python/master/./Modules/pwdmodule.c:166: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
History
Date User Action Args
2020-11-10 14:30:03vstinnersetrecipients: + vstinner, nascheme, ned.deily, pablogsal
2020-11-10 14:30:03vstinnersetmessageid: <1605018603.84.0.157716936833.issue42307@roundup.psfhosted.org>
2020-11-10 14:30:03vstinnerlinkissue42307 messages
2020-11-10 14:30:03vstinnercreate