Build of python loader broken with Python 3.12
Python 3.12 contains a change that introduces a redundant-decls warning, which causes the loader to fail to build due to -Werror=redundant-decls: https://github.com/python/cpython/issues/106560
[103/159] gcc -Iloaders/python/libpythonloader.so.p -Iloaders/python -I../loaders/python -I. -I.. -Ilibpeas -I../libpeas -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/python3.12 -I/usr/include/pygobject-3.0 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_74 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_74 -DLIBPEAS_COMPILATION -Wcast-align -Wdeclaration-after-statement -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=misleading-indentation -Werror=missing-braces -Werror=missing-include-dirs -Werror=nonnull -Werror=overflow -Werror=pointer-arith -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=shadow -Werror=trigraphs -Werror=undef -Werror=write-strings -Wformat-nonliteral -Werror=format-security -Werror=format=2 -Wignored-qualifiers -Wimplicit-function-declaration -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wno-cast-function-type -Wno-dangling-pointer -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -fno-strict-aliasing -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fPIC -pthread '-DPEAS_LOCALEDIR="/usr/share/locale"' -DPYGOBJECT_MAJOR_VERSION=3 -DPYGOBJECT_MINOR_VERSION=44 -DPYGOBJECT_MICRO_VERSION=1 -MD -MQ loaders/python/libpythonloader.so.p/peas-python-internal.c.o -MF loaders/python/libpythonloader.so.p/peas-python-internal.c.o.d -o loaders/python/libpythonloader.so.p/peas-python-internal.c.o -c ../loaders/python/peas-python-internal.c
FAILED: loaders/python/libpythonloader.so.p/peas-python-internal.c.o
gcc -Iloaders/python/libpythonloader.so.p -Iloaders/python -I../loaders/python -I. -I.. -Ilibpeas -I../libpeas -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/python3.12 -I/usr/include/pygobject-3.0 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_74 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_74 -DLIBPEAS_COMPILATION -Wcast-align -Wdeclaration-after-statement -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=misleading-indentation -Werror=missing-braces -Werror=missing-include-dirs -Werror=nonnull -Werror=overflow -Werror=pointer-arith -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=shadow -Werror=trigraphs -Werror=undef -Werror=write-strings -Wformat-nonliteral -Werror=format-security -Werror=format=2 -Wignored-qualifiers -Wimplicit-function-declaration -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wno-cast-function-type -Wno-dangling-pointer -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -fno-strict-aliasing -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fPIC -pthread '-DPEAS_LOCALEDIR="/usr/share/locale"' -DPYGOBJECT_MAJOR_VERSION=3 -DPYGOBJECT_MINOR_VERSION=44 -DPYGOBJECT_MICRO_VERSION=1 -MD -MQ loaders/python/libpythonloader.so.p/peas-python-internal.c.o -MF loaders/python/libpythonloader.so.p/peas-python-internal.c.o.d -o loaders/python/libpythonloader.so.p/peas-python-internal.c.o -c ../loaders/python/peas-python-internal.c
In file included from /usr/include/python3.12/Python.h:44,
from ../loaders/python/peas-python-internal.h:32,
from ../loaders/python/peas-python-internal.c:26:
/usr/include/python3.12/object.h: In function ‘Py_SIZE’:
/usr/include/python3.12/object.h:217:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
217 | PyVarObject *var_ob = _PyVarObject_CAST(ob);
| ^~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:52:
/usr/include/python3.12/longobject.h: At top level:
/usr/include/python3.12/longobject.h:10:26: error: redundant redeclaration of ‘PyLong_Type’ [-Werror=redundant-decls]
10 | PyAPI_DATA(PyTypeObject) PyLong_Type;
| ^~~~~~~~~~~
/usr/include/python3.12/object.h:210:26: note: previous declaration of ‘PyLong_Type’ with type ‘PyTypeObject’ {aka ‘struct _typeobject’}
210 | PyAPI_DATA(PyTypeObject) PyLong_Type;
| ^~~~~~~~~~~
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: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
121 | Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
| ^~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:54:
/usr/include/python3.12/boolobject.h: At top level:
/usr/include/python3.12/boolobject.h:10:26: error: redundant redeclaration of ‘PyBool_Type’ [-Werror=redundant-decls]
10 | PyAPI_DATA(PyTypeObject) PyBool_Type;
| ^~~~~~~~~~~
/usr/include/python3.12/object.h:211:26: note: previous declaration of ‘PyBool_Type’ with type ‘PyTypeObject’ {aka ‘struct _typeobject’}
211 | PyAPI_DATA(PyTypeObject) PyBool_Type;
| ^~~~~~~~~~~
cc1: some warnings being treated as errors
[104/159] gcc -Iloaders/python/libpythonloader.so.p -Iloaders/python -I../loaders/python -I. -I.. -Ilibpeas -I../libpeas -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/python3.12 -I/usr/include/pygobject-3.0 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_74 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_74 -DLIBPEAS_COMPILATION -Wcast-align -Wdeclaration-after-statement -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=misleading-indentation -Werror=missing-braces -Werror=missing-include-dirs -Werror=nonnull -Werror=overflow -Werror=pointer-arith -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=shadow -Werror=trigraphs -Werror=undef -Werror=write-strings -Wformat-nonliteral -Werror=format-security -Werror=format=2 -Wignored-qualifiers -Wimplicit-function-declaration -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wno-cast-function-type -Wno-dangling-pointer -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -fno-strict-aliasing -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fPIC -pthread '-DPEAS_LOCALEDIR="/usr/share/locale"' -DPYGOBJECT_MAJOR_VERSION=3 -DPYGOBJECT_MINOR_VERSION=44 -DPYGOBJECT_MICRO_VERSION=1 -MD -MQ loaders/python/libpythonloader.so.p/peas-plugin-loader-python.c.o -MF loaders/python/libpythonloader.so.p/peas-plugin-loader-python.c.o.d -o loaders/python/libpythonloader.so.p/peas-plugin-loader-python.c.o -c ../loaders/python/peas-plugin-loader-python.c
FAILED: loaders/python/libpythonloader.so.p/peas-plugin-loader-python.c.o
gcc -Iloaders/python/libpythonloader.so.p -Iloaders/python -I../loaders/python -I. -I.. -Ilibpeas -I../libpeas -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/python3.12 -I/usr/include/pygobject-3.0 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_74 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_74 -DLIBPEAS_COMPILATION -Wcast-align -Wdeclaration-after-statement -Werror=address -Werror=array-bounds -Werror=empty-body -Werror=implicit -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=misleading-indentation -Werror=missing-braces -Werror=missing-include-dirs -Werror=nonnull -Werror=overflow -Werror=pointer-arith -Werror=pointer-to-int-cast -Werror=redundant-decls -Werror=return-type -Werror=sequence-point -Werror=shadow -Werror=trigraphs -Werror=undef -Werror=write-strings -Wformat-nonliteral -Werror=format-security -Werror=format=2 -Wignored-qualifiers -Wimplicit-function-declaration -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wno-cast-function-type -Wno-dangling-pointer -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wunused -fno-strict-aliasing -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fPIC -pthread '-DPEAS_LOCALEDIR="/usr/share/locale"' -DPYGOBJECT_MAJOR_VERSION=3 -DPYGOBJECT_MINOR_VERSION=44 -DPYGOBJECT_MICRO_VERSION=1 -MD -MQ loaders/python/libpythonloader.so.p/peas-plugin-loader-python.c.o -MF loaders/python/libpythonloader.so.p/peas-plugin-loader-python.c.o.d -o loaders/python/libpythonloader.so.p/peas-plugin-loader-python.c.o -c ../loaders/python/peas-plugin-loader-python.c
In file included from /usr/include/python3.12/Python.h:44,
from ../loaders/python/peas-python-internal.h:32,
from ../loaders/python/peas-plugin-loader-python.c:28:
/usr/include/python3.12/object.h: In function ‘Py_SIZE’:
/usr/include/python3.12/object.h:217:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
217 | PyVarObject *var_ob = _PyVarObject_CAST(ob);
| ^~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:52:
/usr/include/python3.12/longobject.h: At top level:
/usr/include/python3.12/longobject.h:10:26: error: redundant redeclaration of ‘PyLong_Type’ [-Werror=redundant-decls]
10 | PyAPI_DATA(PyTypeObject) PyLong_Type;
| ^~~~~~~~~~~
/usr/include/python3.12/object.h:210:26: note: previous declaration of ‘PyLong_Type’ with type ‘PyTypeObject’ {aka ‘struct _typeobject’}
210 | PyAPI_DATA(PyTypeObject) PyLong_Type;
| ^~~~~~~~~~~
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: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
121 | Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
| ^~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:54:
/usr/include/python3.12/boolobject.h: At top level:
/usr/include/python3.12/boolobject.h:10:26: error: redundant redeclaration of ‘PyBool_Type’ [-Werror=redundant-decls]
10 | PyAPI_DATA(PyTypeObject) PyBool_Type;
| ^~~~~~~~~~~
/usr/include/python3.12/object.h:211:26: note: previous declaration of ‘PyBool_Type’ with type ‘PyTypeObject’ {aka ‘struct _typeobject’}
211 | PyAPI_DATA(PyTypeObject) PyBool_Type;
| ^~~~~~~~~~~
cc1: some warnings being treated as errors
I worked around it when packaging libpeas2 for Fedora by dropping the -Werror (as the warning is already enabled further down meson.build). Not sure if it is best to wait until this is fixed in Python, keep the dropping of -Werror in the packaging, or something else.
Edited by David King