Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundled Catch library fails to compile with recent C++ #160

Closed
arrowd opened this issue Mar 15, 2024 · 3 comments
Closed

Bundled Catch library fails to compile with recent C++ #160

arrowd opened this issue Mar 15, 2024 · 3 comments

Comments

@arrowd
Copy link

arrowd commented Mar 15, 2024

When building on FreeBSD 14 which uses Clang 16.0.6, I get the following error:

FAILED: tests/unit-tests/CMakeFiles/unit_tests.dir/test_runner.cc.o 
/usr/bin/c++  -I/wrkdirs/usr/ports/devel/libcuckoo/work/libcuckoo-0.3.1/tests/Catch/single_include -I/wrkdirs/usr/ports/devel/libcuckoo/work/libcuckoo-0.3.1 -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing   -DNDEBUG -pthread -MD -MT tests/unit-tests/CMakeFiles/unit_tests.dir/test_runner.cc.o -MF tests/unit-tests/CMakeFiles/unit_tests.dir/test_runner.cc.o.d -o tests/unit-tests/CMakeFiles/unit_tests.dir/test_runner.cc.o -c /wrkdirs/usr/ports/devel/libcuckoo/work/libcuckoo-0.3.1/tests/unit-tests/test_runner.cc
In file included from /wrkdirs/usr/ports/devel/libcuckoo/work/libcuckoo-0.3.1/tests/unit-tests/test_runner.cc:3:
In file included from /wrkdirs/usr/ports/devel/libcuckoo/work/libcuckoo-0.3.1/tests/Catch/single_include/catch.hpp:74:
In file included from /usr/include/c++/v1/sstream:191:
In file included from /usr/include/c++/v1/istream:165:
In file included from /usr/include/c++/v1/ostream:170:
In file included from /usr/include/c++/v1/bitset:131:
In file included from /usr/include/c++/v1/string:576:
In file included from /usr/include/c++/v1/string_view:1025:
In file included from /usr/include/c++/v1/algorithm:1848:
In file included from /usr/include/c++/v1/__algorithm/ranges_sample.h:13:
In file included from /usr/include/c++/v1/__algorithm/sample.h:18:
/usr/include/c++/v1/__random/uniform_int_distribution.h:234:5: error: static assertion failed due to requirement '__libcpp_random_is_valid_urng<Catch::RandomNumberGenerator, void>::value': 
    static_assert(__libcpp_random_is_valid_urng<_URNG>::value, "");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/__algorithm/shuffle.h:155:35: note: in instantiation of function template specialization 'std::uniform_int_distribution<long>::operator()<Catch::RandomNumberGenerator>' requested here
            difference_type __i = __uid(__g, _Pp(0, __d));
                                  ^
/usr/include/c++/v1/__algorithm/shuffle.h:167:14: note: in instantiation of function template specialization 'std::__shuffle<std::_ClassicAlgPolicy, std::__wrap_iter<Catch::TestCase *>, std::__wrap_iter<Catch::TestCase *>, Catch::RandomNumberGenerator &>' requested here
  (void)std::__shuffle<_ClassicAlgPolicy>(
             ^
/wrkdirs/usr/ports/devel/libcuckoo/work/libcuckoo-0.3.1/tests/Catch/single_include/catch.hpp:6481:18: note: in instantiation of function template specialization 'std::shuffle<std::__wrap_iter<Catch::TestCase *>, Catch::RandomNumberGenerator &>' requested here
            std::shuffle( vector.begin(), vector.end(), rng );
                 ^
/wrkdirs/usr/ports/devel/libcuckoo/work/libcuckoo-0.3.1/tests/Catch/single_include/catch.hpp:6499:44: note: in instantiation of function template specialization 'Catch::RandomNumberGenerator::shuffle<std::vector<Catch::TestCase>>' requested here
                    RandomNumberGenerator::shuffle( sorted );
                                           ^
1 error generated.
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Mar 15, 2024
Reported upstream: efficient/libcuckoo#160

Reported by:	Andrea Venturoli <ml@netfence.it>
manugoyal added a commit that referenced this issue Mar 16, 2024
Motivated by #160.

It seems like Catch is moving in the direction of a more fully-featured,
separately-compiled test framework. And we basically just need the bare
minimum here. The acutest library seems to provide this.
@manugoyal
Copy link
Contributor

Thanks for reporting @arrowd!

I wasn't able to reproduce your issue on clang 16.0.6 on my ubuntu machine, but nevertheless there is room to slim down our dependencies here. I looked into upgrading Catch, but they are actually moving towards a more fully-featured test framework, and we basically just need the bare minimum.

So I tried replacing the test framework in this branch: https://github.com/efficient/libcuckoo/tree/replace-catch-with-acutest

If you have a chance, would appreciate if you could check that this compiles and runs on FreeBSD.

@arrowd
Copy link
Author

arrowd commented Mar 17, 2024

I wasn't able to reproduce your issue on clang 16.0.6 on my ubuntu machine

I think the problem is with the standard library then. FreeBSD uses libc++ matching Clang's version, while on Ubuntu Clang still uses libstdc++, I believe.

So I tried replacing the test framework in this branch: https://github.com/efficient/libcuckoo/tree/replace-catch-with-acutest

Tried it out and it build fine. Tests also pass, thanks for working on this!

@manugoyal
Copy link
Contributor

Awesome, great to hear! Just merged into the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants