Hello Pythonistas.
For years, the CFLAGS embedded in Python sysconfig contained -O2 in Fedora.
This was how Python was built and by default, all flags used to build Python
were embedded.
Later, the flag was removed in Fedora 39 via this change:
https://fedoraproject.org/wiki/Changes/Python_Extension_Flags_Reduction
We wanted to remove as many flags as possible, with this motivation:
"""
Python developers will get more upstream-like experience when building Python
extension modules and also closer to building vanilla C programs.
"""
Note that removing -O2 specifically was not the primary motivation, but the
removal was intentional at that time.
--------
Now we build Python 3.13 with -O3 via this change:
https://fedoraproject.org/wiki/Changes/Python_built_with_gcc_O3
The change proposal said:
"""
Other Python extension modules will remain bulidng as before, e.g. in RPM
packages, they will still be built with -O2...
"""
However, I made a mistake and the -O3 flag leaked into sysconfig CFLAGS.
The good news is this does not seem to affect RPM packages, they are still
being built with -O2, like this:
<flags embedded in sysconfig> <$CFLAGS from automatic %set_build_flags>
E.g. ... -fcf-protection -fexceptions -O3 -O2 -flto=auto ...
The latter flag wins.
----
OTOH users building their own extension modules will get -O3.
This is not what was intended. However, "Python developers will get more
upstream-like experience" is more true now, because upstream Python builds use -O3:
$ podman run --rm -ti python:3.12 /usr/bin/bash
# python
>>> import sysconfig
>>> sysconfig.get_config_var('CFLAGS')
'-fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall'
So the question is:
Do we keep -O3 for user-built extension modules for speed and upstream-like
experience? (I would update the -O3 change proposal.)
Or do we loose the flag, as currently documented?
Alternatively, do something else entirely (e.g. embed -O2, or other flag...)?
--
Miro Hrončok
--
Phone: +420777974800
Fedora Matrix: mhroncok
--
_______________________________________________
python-devel mailing list -- python-devel@lists.fedoraproject.org
To unsubscribe send an email to python-devel-le...@lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org
Do not reply to spam, report it:
https://pagure.io/fedora-infrastructure/new_issue