boschmitt / tweedledum

C++17 Library for analysis, compilation/synthesis, and optimization of quantum circuits
MIT License
98 stars 36 forks source link

Build failure of tests (catch2) with gcc 10.3.0, glibc 2.34 #172

Closed drewrisinger closed 2 years ago

drewrisinger commented 2 years ago

Describe the bug

Error on certain build systems when building tests (catch2.hpp): MINSIGSTKSZ is not constexpr.

Error Log

[55/102] Building CXX object tests/CMakeFiles/run_tests.dir/run_tests.cpp.o
FAILED: tests/CMakeFiles/run_tests.dir/run_tests.cpp.o 
/nix/store/4ybkncn05qbhgbdxg9sxdgpm1jpdx76w-gcc-wrapper-10.3.0/bin/g++ -DABC_NAMESPACE=pabc -DABC_NO_USE_READLINE -DDISABLE_NAUTY -DFMT_HEADER_ONLY=1 -DLIN64 -DTEST_QASM_DIR=\"/build/source/tests/qasm\" -I/build/source/tests/catch2 -I/build/source/include -I/build/source/external/abcsat -I/build/source/external/abcesop -I/build/source/external/abcresub -isystem /build/source/external/eigen -isystem /build/source/external/fmt/include -isystem /build/source/external/mockturtle -isystem /build/source/external/kitty -isystem /build/source/external/lorina -isystem /build/source/external/rang -isystem /build/source/external/parallel_hashmap -isystem /build/source/external/percy -isystem /build/source/external/bill -O3 -DNDEBUG -std=gnu++17 -MD -MT tests/CMakeFiles/run_tests.dir/run_tests.cpp.o -MF tests/CMakeFiles/run_tests.dir/run_tests.cpp.o.d -o tests/CMakeFiles/run_tests.dir/run_tests.cpp.o -c /build/source/tests/run_tests.cpp
In file included from /nix/store/l1cds4dpaad47f1n6jwzva2sn1dzdn6a-glibc-2.34-115-dev/include/signal.h:328,
                 from /build/source/tests/catch2/catch.hpp:8034,
                 from /build/source/tests/run_tests.cpp:8:
/build/source/tests/catch2/catch.hpp:10822:58: error: call to non-'constexpr' function 'long int sysconf(int)'
10822 |     static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
      |                                                          ^~~~~~~~~~~
In file included from /nix/store/l1cds4dpaad47f1n6jwzva2sn1dzdn6a-glibc-2.34-115-dev/include/bits/sigstksz.h:24,
                 from /nix/store/l1cds4dpaad47f1n6jwzva2sn1dzdn6a-glibc-2.34-115-dev/include/signal.h:328,
                 from /build/source/tests/catch2/catch.hpp:8034,
                 from /build/source/tests/run_tests.cpp:8:
/nix/store/l1cds4dpaad47f1n6jwzva2sn1dzdn6a-glibc-2.34-115-dev/include/unistd.h:640:17: note: 'long int sysconf(int)' declared here
  640 | extern long int sysconf (int __name) __THROW;
      |                 ^~~~~~~
In file included from /build/source/tests/run_tests.cpp:8:
/build/source/tests/catch2/catch.hpp:10881:45: error: size of array 'altStackMem' is not an integral constant-expression
10881 |     char FatalConditionHandler::altStackMem[sigStackSize] = {};
      |                                             ^~~~~~~~~~~~

Expected behavior

Build should pass.

Information

Debugging

Traced bug to https://github.com/boschmitt/tweedledum/blob/e73beb23a3feeba02a851e3f8131e3c85a29de2b/tests/catch2/catch.hpp#L10822. When comparing against upstream catch2, this line was removed in May 2021, see https://github.com/catchorg/Catch2/commit/c0d0a50bdb2ae2f749443c0386c2b25379bdbf76 Bugfix should basically just be applying the patch from https://github.com/catchorg/Catch2/commit/c0d0a50bdb2ae2f749443c0386c2b25379bdbf76

drewrisinger commented 2 years ago

Thanks @boschmitt