Sujet : Building CPython from source, stripping executable
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.pythonDate : 12. Feb 2025, 00:25:27
Autres entêtes
Organisation : None to speak of
Message-ID : <87frkknjx4.fsf@nosuchdomain.example.com>
User-Agent : Gnus/5.13 (Gnus v5.13)
I'm building CPython 3.14.0a5 from source on Ubuntu 22.04.5.
Is there some way to specify that the python3.14 executable should
be stripped? (Stripping reduces the size of the executable from
33M to 5.8M.)
Of course I can run "strip" manually after installing, but I'm
looking for a way to do it as part of the build.
For a lot of software packages, invoking "make install-strip"
rather than "make install" does this, but CPython's generated
Makefile doesn't include this target.
Diving into the Makefile, I see this:
# Option to install to strip binaries
STRIPFLAG=-s
but STRIPFLAG is used only if PYTHONFRAMEWORKDIR is set, which
seems to be Mac-specific.
The Makefile also has:
INSTALL= /usr/bin/install -c
(The "-c" option is ignored by the GNU Coreutils install command.)
I tried setting INSTALL to "install -s", and the installation
failed because it tried to strip Python scripts as well as the
python3.14 executable:
install -s -m 644 ./Tools/gdb/libpython.py python-gdb.py
strip: python-gdb.py: file format not recognized
install: strip process terminated abnormally
make: *** [Makefile:1117: python-gdb.py] Error 1
Is there a straightforward way to strip executables during installation?
If not, I'll run "strip" manually for now and submit an issue on
<
https://github.com/python/cpython/issues> suggesting adding an
"install-strip" target to the Makefile.
I don't think this is a new issue in 3.14.0a5; that's just where
I happened to run into it.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */