Bug 2217084
| Summary: | -Wdeclaration-after-statement error in Python.h while building xen | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Michael Young <m.a.young> |
| Component: | python3.12 | Assignee: | Python Maintainers <python-maint> |
| Status: | CLOSED NOTABUG | QA Contact: | |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | rawhide | CC: | cstratak, mhroncok, pviktori, python-maint, python-packagers-sig, thrnciar, torsava, vstinner |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2023-08-02 12:30:18 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Possibly a followup for https://github.com/python/cpython/pull/92783/files https://peps.python.org/pep-0007/ """Python 3.11 and newer versions use C11 without optional features. The public C API should be compatible with C++.""" While in the past, contributions that removed mixed declarations and code were merged, there is no promise by Python that it would follow C90. I don't think it's possible to use -Werror=declaration-after-statement when building Python extension modules, sorry. Why does xen need -Werror=declaration-after-statement? I think upstream could be persuaded if there is a good reason. It is a combination of -Wno-declaration-after-statement from xen (common to most of the code) and -Werror from Fedora. As I suspect this doesn't qua;ify as a good reason I am going to apply a targeted workaround (dropping back down to -Wno-declaration-after-statement where needed) to get xen built with python 3.12. > ...and -Werror from Fedora.
Note that Fedora does not set -Werror globally.
This is not an issue we can address downstream. If you'd like to change this in Python, please start a discussion upstream. |
Description of problem: Building xen with python3.12 fails with the error self.initialize_options() In file included from /usr/include/python3.12/Python.h:44, from xen/lowlevel/xc/xc.c:8: /usr/include/python3.12/object.h: In function ‘Py_SIZE’: /usr/include/python3.12/object.h:217:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 217 | PyVarObject *var_ob = _PyVarObject_CAST(ob); | ^~~~~~~~~~~ In file included from /usr/include/python3.12/Python.h:53: /usr/include/python3.12/cpython/longintrepr.h: In function ‘_PyLong_CompactValue’: /usr/include/python3.12/cpython/longintrepr.h:121:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 121 | Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK); | ^~~~~~~~~~ cc1: all warnings being treated as errors This is still the case with python-devel-3.12.0~b3-2.fc39 . I think the compiler actually wants something like PyVarObject *var_ob; ... *var_ob = _PyVarObject_CAST(ob);