metaopt / optree

OpTree: Optimized PyTree Utilities
https://optree.readthedocs.io
Apache License 2.0
146 stars 7 forks source link

[BUG] Build failure on 32-bit architecture (at least i386) #140

Closed sunpoet closed 5 months ago

sunpoet commented 5 months ago

Required prerequisites

What version of OpTree are you using?

0.11.0

System information

The library was built from ports via

Problem description

It fails to build on i386 due to same size of different types. It causes error of redefinition of functions. Therefore, the build fails.

The full build log is here.

Reproducible example code

The build failure is as follows:

-- Build files have been written to: /wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/build/temp.freebsd-13.2-RELEASE-p11-i386-cpython-39
/usr/local/bin/cmake --build . --config Release --target _C --
[ 12%] Building CXX object src/CMakeFiles/_C.dir/optree.cpp.o
In file included from /wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/src/optree.cpp:25:
In file included from /wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/registry.h:29:
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:229:19: error: redefinition of 'GET_ITEM_HANDLE<pybind11::tuple, int>'
inline py::handle GET_ITEM_HANDLE<py::tuple>(const py::handle& container, const int& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:221:19: note: previous definition is here
inline py::handle GET_ITEM_HANDLE<py::tuple>(const py::handle& container, const py::ssize_t& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:241:19: error: redefinition of 'GET_ITEM_HANDLE<pybind11::list, int>'
inline py::handle GET_ITEM_HANDLE<py::list>(const py::handle& container, const int& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:233:19: note: previous definition is here
inline py::handle GET_ITEM_HANDLE<py::list>(const py::handle& container, const py::ssize_t& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:259:19: error: redefinition of 'GET_ITEM_BORROW<pybind11::tuple, int>'
inline py::object GET_ITEM_BORROW<py::tuple>(const py::handle& container, const int& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:250:19: note: previous definition is here
inline py::object GET_ITEM_BORROW<py::tuple>(const py::handle& container, const py::ssize_t& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:273:19: error: redefinition of 'GET_ITEM_BORROW<pybind11::list, int>'
inline py::object GET_ITEM_BORROW<py::list>(const py::handle& container, const int& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:264:19: note: previous definition is here
inline py::object GET_ITEM_BORROW<py::list>(const py::handle& container, const py::ssize_t& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:292:19: error: redefinition of 'GET_ITEM_STEAL<pybind11::tuple, int>'
inline py::object GET_ITEM_STEAL<py::tuple>(const py::handle& container, const int& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:283:19: note: previous definition is here
inline py::object GET_ITEM_STEAL<py::tuple>(const py::handle& container, const py::ssize_t& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:306:19: error: redefinition of 'GET_ITEM_STEAL<pybind11::list, int>'
inline py::object GET_ITEM_STEAL<py::list>(const py::handle& container, const int& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:297:19: note: previous definition is here
inline py::object GET_ITEM_STEAL<py::list>(const py::handle& container, const py::ssize_t& item) {
                  ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:328:13: error: redefinition of 'SET_ITEM<pybind11::tuple, int>'
inline void SET_ITEM<py::tuple>(const py::handle& container,
            ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:316:13: note: previous definition is here
inline void SET_ITEM<py::tuple>(const py::handle& container,
            ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:346:13: error: redefinition of 'SET_ITEM<pybind11::list, int>'
inline void SET_ITEM<py::list>(const py::handle& container,
            ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:334:13: note: previous definition is here
inline void SET_ITEM<py::list>(const py::handle& container,
            ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:578:9: error: no matching function for call to 'SET_ITEM'
        SET_ITEM<py::tuple>(fields, i, py::str(members[i].name));
        ^~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:312:13: note: candidate template ignored: substitution failure [with Container = pybind11::tuple, Item = int]
inline void SET_ITEM(const py::handle& container, const Item& item, const py::handle& value) {
            ^
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:672:26: error: no matching function for call to 'GET_ITEM_BORROW'
        py::object key = GET_ITEM_BORROW<py::list>(keys, i);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/devel/py-optree/work-py39/optree-0.11.0/include/utils.h:246:19: note: candidate template ignored: substitution failure [with Container = pybind11::list, Item = int]
inline py::object GET_ITEM_BORROW(const py::handle& container, const Item& item) {
                  ^
10 errors generated.
*** Error code 1

Traceback

No response

Expected behavior

No response

Additional context

No response

sunpoet commented 5 months ago

Thanks!