gulrak/filesystem

Test suite does not build on centos7

bbannier opened this issue · 5 comments

The test suite does not seem to build under centos7 with devtoolset-9. This seems to be due to a used TestAllocator not implementing rebind (deprecated in C++17, removed in C++20), e.g.,

/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h: In instantiation of ‘class std::basic_string<char, std::char_traits<char>, TestAllocator<char> >’:
/tmp/cirrus-ci-build/test/filesystem_test.cpp:588:116:   required from here
/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h:3142:63: error: no class template named ‘rebind’ in ‘class TestAllocator<char>’
 3142 |       typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
      |                                                               ^~~~~~~~~~~~~~~~~
/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h:3160:68: error: no class template named ‘rebind’ in ‘class TestAllocator<char>’
 3160 |       typedef __gnu_cxx::__normal_iterator<pointer, basic_string>  iterator;
      |                                                                    ^~~~~~~~
/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h:3162:61: error: no class template named ‘rebind’ in ‘class TestAllocator<char>’
 3162 |                                                             const_iterator;
      |                                                             ^~~~~~~~~~~~~~
/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h:3163:53: error: no class template named ‘rebind’ in ‘class TestAllocator<char>’
 3163 |       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
      |                                                     ^~~~~~~~~~~~~~~~~~~~~~
/opt/rh/devtoolset-9/root/usr/include/c++/9/bits/basic_string.h:3164:52: error: no class template named ‘rebind’ in ‘class TestAllocator<char>’
 3164 |       typedef std::reverse_iterator<iterator>      reverse_iterator;

I was exploring whether this library would be a good replacement for devtoolset on centos7 since the base system libstdc++ is fairly old there, and some the std filesystem library often requires compiled components (the devtoolset workflow is easiest to deploy if the produced artifacts have not runtime dependencies on devtoolset libraries).

I have tested this by extending the Cirrus CI setup with centos7 and centos8 platforms here. The build and test steps pass for centos8, but centos7 fails with above error.

Ideally it should be possible to use this library to statically compile in a libstdc++-neutral std::filesystem-like functionality (either by using header-only components or by a static link).

I understand that there is no official support for centos platforms, so please close this if it is out of scope.

I'll see what I can do. Will need to fix that on the way to C++20 support anyway, I guess. Thanks for reporting it.

I used your referenced centos7/8 .cirrus.yml changes to test this, if it is okay with you, I'll merge them with the fix, than I would call it a supported platform, as that's what is needed for me to keep track that I don't break things for it.

I used your referenced centos7/8 .cirrus.yml changes to test this, if it is okay with you, I'll merge them with the fix, than I would call it a supported platform, as that's what is needed for me to keep track that I don't break things for it.

Yes, please, use the code if it is useful. Since devtoolset should ideally only be used during build, but not runtime, ultimately this line https://github.com/bbannier/filesystem/blob/81908c385b017f39cee013ff73d5c3abb67261be/.cirrus.yml#L25 should probably read instead

- source /opt/rh/devtoolset-9/enable && PATH=$PATH:/usr/local/bin .ci/unix-test.sh
+ PATH=$PATH:/usr/local/bin .ci/unix-test.sh

With that you could ensure that the binary produced with devtoolset can be used without it.

Released with v1.3.6

Awesome, thanks a lot @gulrak.