Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1896382

Summary: boost fails to build with Python 3.10: Py_TYPE= needs to be replaced with Py_SET_TYPE
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: boostAssignee: Jonathan Wakely <jwakely>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: dakingun, denis.arnaud_fedora, jwakely, mhroncok, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: boost-1.73.0-10.fc34 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-14 17:46:12 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:
Bug Depends On:    
Bug Blocks: 1890881, 1897494, 1897583    

Description Tomáš Hrnčiar 2020-11-10 12:34:26 UTC
boost fails to build with Python 3.10.0a2.

In file included from /usr/include/python3.10/pytime.h:6,
                 from /usr/include/python3.10/Python.h:85,
                 from ./boost/python/detail/wrap_python.hpp:178,
                 from ./boost/python/detail/prefix.hpp:13,
                 from ./boost/python/object_core.hpp:10,
                 from ./boost/python/object/enum_base.hpp:8,
                 from libs/python/src/object/enum.cpp:6:
libs/python/src/object/enum.cpp: In function 'boost::python::api::object boost::python::objects::{anonymous}::new_enum_type(const char*, const char*)':
/usr/include/python3.10/object.h:140:29: error: lvalue required as left operand of assignment
  140 | #define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
libs/python/src/object/enum.cpp:156:11: note: in expansion of macro 'Py_TYPE'
  156 |           Py_TYPE(&enum_type_object) = incref(&PyType_Type);
      |           ^~~~~~~
gcc.compile.c++ serial/boost/bin.v2/libs/python/build/gcc-10/release/debug-symbols-on/pch-off/python-3.10/threading-multi/visibility-hidden/object/class.o

    "g++"  -fvisibility-inlines-hidden -fPIC -m64 -pthread -g -fvisibility=hidden -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 -fno-strict-aliasing -Wno-unused-local-typedefs -Wno-deprecated-declarations  -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE -DNDEBUG  -I"." -I"/usr/include/python3.10" -c -o "serial/boost/bin.v2/libs/python/build/gcc-10/release/debug-symbols-on/pch-off/python-3.10/threading-multi/visibility-hidden/object/class.o" "libs/python/src/object/class.cpp"

In file included from /usr/include/python3.10/pytime.h:6,
                 from /usr/include/python3.10/Python.h:85,
                 from ./boost/python/detail/wrap_python.hpp:178,
                 from ./boost/python/detail/prefix.hpp:13,
                 from libs/python/src/object/class.cpp:6:
libs/python/src/object/class.cpp: In function 'PyObject* boost::python::objects::static_data()':
/usr/include/python3.10/object.h:140:29: error: lvalue required as left operand of assignment
  140 | #define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
libs/python/src/object/class.cpp:211:11: note: in expansion of macro 'Py_TYPE'
  211 |           Py_TYPE(&static_data_object) = &PyType_Type;
      |           ^~~~~~~
libs/python/src/object/class.cpp: In function 'boost::python::type_handle boost::python::objects::class_metatype()':
/usr/include/python3.10/object.h:140:29: error: lvalue required as left operand of assignment
  140 | #define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
libs/python/src/object/class.cpp:319:11: note: in expansion of macro 'Py_TYPE'
  319 |           Py_TYPE(&class_metatype_object) = &PyType_Type;
      |           ^~~~~~~
libs/python/src/object/class.cpp: In function 'PyObject* boost::python::objects::instance_new(PyTypeObject*, PyObject*, PyObject*)':
/usr/include/python3.10/object.h:134:29: error: lvalue required as left operand of assignment
  134 | #define Py_SIZE(ob) _Py_SIZE(_PyVarObject_CAST_CONST(ob))
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libs/python/src/object/class.cpp:378:15: note: in expansion of macro 'Py_SIZE'
  378 |               Py_SIZE(result) =
      |               ^~~~~~~
libs/python/src/object/class.cpp: In function 'boost::python::type_handle boost::python::objects::class_type()':
/usr/include/python3.10/object.h:140:29: error: lvalue required as left operand of assignment
  140 | #define Py_TYPE(ob) _Py_TYPE(_PyObject_CAST_CONST(ob))
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
libs/python/src/object/class.cpp:473:11: note: in expansion of macro 'Py_TYPE'
  473 |           Py_TYPE(&class_type_object) = incref(class_metatype().get());
      |           ^~~~~~~
libs/python/src/object/class.cpp: In static member function 'static void* boost::python::instance_holder::allocate(PyObject*, std::size_t, std::size_t)':
/usr/include/python3.10/object.h:134:29: error: lvalue required as left operand of assignment
  134 | #define Py_SIZE(ob) _Py_SIZE(_PyVarObject_CAST_CONST(ob))
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libs/python/src/object/class.cpp:742:9: note: in expansion of macro 'Py_SIZE'
  742 |         Py_SIZE(self) = holder_offset;
      |         ^~~~~~~
...failed updating 2 targets...
error: Bad exit status from /var/tmp/rpm-tmp.oihGUt (%build)

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

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

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

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-11-10 12:39:26 UTC
I'm boosting (hehe) the severity of this one, since boost is quite needed by other packages.

Comment 2 Kevin Kofler 2020-11-12 11:46:32 UTC
*** Bug 1897076 has been marked as a duplicate of this bug. ***

Comment 3 Jonathan Wakely 2020-11-14 00:05:01 UTC
There's a scratch build at https://koji.fedoraproject.org/koji/taskinfo?taskID=55558055 with the patch to use Py_SET_TYPE, which builds OK with Python 3.9

I'm also trying the same SRPM in copr with Python 3.10

Comment 4 Jonathan Wakely 2020-11-14 01:11:09 UTC
That version built OK in rawhide, but not in copr using python 3.10

I've pushed a fixed version to rawhide dist-git now, but I haven't started a koji build. Can you pull from rawhide to test it with Python 3.10, or do I need to build it for rawhide too?

Comment 5 Miro Hrončok 2020-11-14 07:28:58 UTC
Thanks!

The package should build automatically in https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/boost/

However, there was come copr outage/error. I'll trigger it manually.

Comment 6 Miro Hrončok 2020-11-14 17:52:58 UTC
*** Bug 1897494 has been marked as a duplicate of this bug. ***

Comment 7 Miro Hrončok 2020-11-14 17:53:00 UTC
*** Bug 1897583 has been marked as a duplicate of this bug. ***

Comment 8 Miro Hrončok 2020-11-16 10:44:16 UTC
*** Bug 1896383 has been marked as a duplicate of this bug. ***

Comment 9 Jonathan Wakely 2020-11-16 17:18:35 UTC
OK, I think I should build it for rawhide now then.

Comment 11 Miro Hrončok 2020-11-18 17:59:17 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

Comment 12 Miro Hrončok 2020-11-18 18:12:51 UTC
*** Bug 1896398 has been marked as a duplicate of this bug. ***