zodb / relstorage

A backend for ZODB that stores pickles in a relational database.
Other
53 stars 46 forks source link

Unable to install: fails to build relstorage.cache.cache extension #499

Closed larsks closed 7 months ago

larsks commented 1 year ago

I'm trying to install RelStorage on python 3.11, with gcc version 13.1.1. pip install RelStorage[sqlite3] fails with:

      gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isrc/relstorage/cache -Isrc/relstorage -Iinclude -I/home/lars/tmp/python/.venv/include -I/usr/include/python3.11 -c src/relstorage/cache/c_cache.cpp -o build/temp.linux-x86_64-cpython-311/src/relstorage/cache/c_cache.o
      In file included from /usr/include/c++/13/ext/alloc_traits.h:34,
                       from /usr/include/c++/13/bits/stl_uninitialized.h:64,
                       from /usr/include/c++/13/memory:69,
                       from src/relstorage/cache/c_cache.cpp:15:
      /usr/include/c++/13/bits/alloc_traits.h: In instantiation of ‘struct std::__allocator_traits_base::__rebind<relstorage::PythonAllocator<relstorage::cache::ProposedCacheEntry>, relstorage::cache::ProposedCacheEntry, void>’:
      /usr/include/c++/13/bits/alloc_traits.h:94:11:   required by substitution of ‘template<class _Alloc, class _Up> using std::__alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = relstorage::PythonAllocator<relstorage::cache::ProposedCacheEntry>; _Up = relstorage::cache::ProposedCacheEntry]’
      /usr/include/c++/13/bits/alloc_traits.h:228:8:   required by substitution of ‘template<class _Alloc> template<class _Tp> using std::allocator_traits< <template-parameter-1-1> >::rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = relstorage::cache::ProposedCacheEntry; _Alloc = relstorage::PythonAllocator<relstorage::cache::ProposedCacheEntry>]’
      /usr/include/c++/13/ext/alloc_traits.h:126:65:   required from ‘struct __gnu_cxx::__alloc_traits<relstorage::PythonAllocator<relstorage::cache::ProposedCacheEntry>, relstorage::cache::ProposedCacheEntry>::rebind<relstorage::cache::ProposedCacheEntry>’
      /usr/include/c++/13/bits/stl_vector.h:88:21:   required from ‘struct std::_Vector_base<relstorage::cache::ProposedCacheEntry, relstorage::PythonAllocator<relstorage::cache::ProposedCacheEntry> >’
      /usr/include/c++/13/bits/stl_vector.h:425:11:   required from ‘class std::vector<relstorage::cache::ProposedCacheEntry, relstorage::PythonAllocator<relstorage::cache::ProposedCacheEntry> >’
      src/relstorage/cache/c_cache.h:523:26:   required from here
      /usr/include/c++/13/bits/alloc_traits.h:70:31: error: static assertion failed: allocator_traits<A>::rebind_alloc<A::value_type> must be A
         70 |                         _Tp>::value,
            |                               ^~~~~
      /usr/include/c++/13/bits/alloc_traits.h:70:31: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
      error: command '/usr/bin/gcc' failed with exit code 1

I'm not intimately familiar with C++ so I'm not sure if this represents a real error, some sort of version skew in the compiler, or something else.

margaridasp commented 9 months ago

I have the same problem on Fedora 38, gcc version 13.2.1 I found a project where they seem to have had this issue and fixed it, apparently by specifying some "rebind" type: https://github.com/nlohmann/json/pull/3895

jamadden commented 8 months ago

Please try with Relstorage 4.

margaridasp commented 8 months ago

Please try with Relstorage 4.

Thank you @jamadden I was able to install it now, with version 4! :)

MJuddBooth commented 8 months ago

Unfortunately, @jamadden, I am still getting that same build error with the head of the master branch. python3.11.6, gcc 13.2.0 .

MJuddBooth commented 8 months ago

And I have no idea whether this does the right thing but adding the following (as suggested by gcc 13 porting): template <class U> struct rebind { using other = PythonAllocator<U>; }; to src/relstorage/_rs_types.h allows it to build.

jamadden commented 7 months ago

I thought the necessary change had made it into the last pre-release version of RelStorage 4, but (obviously) it hadn't.

I've made and tested the necessary change, and officially released RelStorage 4. (Binary wheels are still building, trickling in as they finish.)