Bug 1893194 - gobject-introspection fails to build with Python 3.10: Py_TYPE= needs to be replaced with Py_SET_TYPE
Summary: gobject-introspection fails to build with Python 3.10: Py_TYPE= needs to be r...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gobject-introspection
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Colin Walters
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2020-10-30 14:03 UTC by Tomáš Hrnčiar
Modified: 2020-11-18 17:59 UTC (History)
8 users (show)

Fixed In Version: gobject-introspection-1.66.1-2.fc34
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 08:36:34 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNOME Gitlab GNOME/gobject-introspection - merge_requests 243 0 None None None 2020-11-03 15:15:20 UTC

Description Tomáš Hrnčiar 2020-10-30 14:03:17 UTC
gobject-introspection fails to build with Python 3.10.0a1.

../giscanner/giscannermodule.c: In function ‘PyInit__giscanner’:
../giscanner/giscannermodule.c:56:20: error: lvalue required as left operand of assignment
   56 |     Py_TYPE(&type) = &PyType_Type;             \
      |                    ^
../giscanner/giscannermodule.c:629:5: note: in expansion of macro ‘REGISTER_TYPE’
  629 |     REGISTER_TYPE (d, "SourceScanner", PyGISourceScanner_Type);
      |     ^~~~~~~~~~~~~
../giscanner/giscannermodule.c:56:20: error: lvalue required as left operand of assignment
   56 |     Py_TYPE(&type) = &PyType_Type;             \
      |                    ^
../giscanner/giscannermodule.c:632:5: note: in expansion of macro ‘REGISTER_TYPE’
  632 |     REGISTER_TYPE (d, "SourceSymbol", PyGISourceSymbol_Type);
      |     ^~~~~~~~~~~~~
../giscanner/giscannermodule.c:56:20: error: lvalue required as left operand of assignment
   56 |     Py_TYPE(&type) = &PyType_Type;             \
      |                    ^
../giscanner/giscannermodule.c:635:5: note: in expansion of macro ‘REGISTER_TYPE’
  635 |     REGISTER_TYPE (d, "SourceType", PyGISourceType_Type);
      |     ^~~~~~~~~~~~~
[73/168] gcc  -o tools/g-ir-compiler tools/g-ir-compiler.p/compiler.c.o -Wl,--as-needed -Wl,--no-undefined -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -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 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--start-group girepository/libgirepository-internals.a girepository/libgirepository-gthash.a girepository/cmph/libcmph.a girepository/libgirepository-1.0.so.1.0.0 /usr/lib64/libffi.so /usr/lib64/libglib-2.0.so /usr/lib64/libgobject-2.0.so /usr/lib64/libgio-2.0.so -Wl,--export-dynamic /usr/lib64/libgmodule-2.0.so -pthread -lm -Wl,--end-group '-Wl,-rpath,$ORIGIN/../girepository' -Wl,-rpath-link,/builddir/build/BUILD/gobject-introspection-1.66.1/x86_64-redhat-linux-gnu/girepository
ninja: build stopped: subcommand failed.
Found runner: ['/usr/bin/ninja']
error: Bad exit status from /var/tmp/rpm-tmp.WLS2Av (%build)
    Bad exit status from /var/tmp/rpm-tmp.WLS2Av (%build)

This is seems like an error with Py_Type(). For more info see: https://docs.python.org/3.10/whatsnew/3.10.html#id2

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01728360-gobject-introspection/

For all our attempts to build gobject-introspection with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/gobject-introspection/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2020-10-30 20:46:37 UTC
https://docs.python.org/3.10/whatsnew/3.10.html#id2

Since Py_TYPE() is changed to the inline static function, Py_TYPE(obj) = new_type must be replaced with Py_SET_TYPE(obj, new_type): see Py_SET_TYPE() (available since Python 3.9). For backward compatibility, this macro can be used:

#if PY_VERSION_HEX < 0x030900A4
#  define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
#endif

https://bugs.python.org/issue39573

Comment 2 Miro Hrončok 2020-11-03 10:25:12 UTC
CCing Kalev, who is the de-facto maintainer here AFAIK.

Comment 3 Tomáš Hrnčiar 2020-11-03 15:15:20 UTC
Fix is already proposed in upstream. See: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/243

Comment 4 Kalev Lember 2020-11-04 08:36:34 UTC
Thanks for finding the MR! I went ahead and backported this to rawhide: https://src.fedoraproject.org/rpms/gobject-introspection/c/408248fb59bdd890041b892b828177790203c62d?branch=master

Comment 5 Miro Hrončok 2020-11-18 17:59:14 UTC
JFYI The change was reverted in Python 3.10, because it caused too much trouble (the amount of affected Fedora packages was too big).

This comment is mass posted in all relevant bugzillas. If you already worked upstream to fix the problem, you might want to let them know about the revert, but the new way of doing things also works.

Sorry for the trouble and thanks again for the fix.

https://github.com/python/cpython/commit/0e2ac21dd


Note You need to log in before you can comment on or make changes to this bug.