STINNER Victor <vstin...@python.org> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42307>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to