Build fails on newer compiler versions
When building with a new compiler verison (gcc 11.2.0 in my case), the build fails with the below error:
In file included from /usr/include/signal.h:328,
from /symforce/third_party/catch2/include/catch.hpp:8152,
from /symforce/third_party/catch2/src/catch_amalgamated.cpp:15:
/symforce/third_party/catch2/src/catch_amalgamated.cpp:3580:54: error: call to non-'constexpr' function 'long int sysconf(int)'
3580 | static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
| ^~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
from /usr/include/signal.h:328,
from /symforce/third_party/catch2/include/catch.hpp:8152,
from /symforce/third_party/catch2/src/catch_amalgamated.cpp:15:
/usr/include/unistd.h:640:17: note: 'long int sysconf(int)' declared here
640 | extern long int sysconf (int __name) __THROW;
| ^~~~~~~
/symforce/third_party/catch2/src/catch_amalgamated.cpp:3633:41: error: size of array 'altStackMem' is not an integral constant-expression
3633 | char FatalConditionHandler::altStackMem[sigStackSize] = {};
| ^~~~~~~~~~~~
This error is apparently already known about and fixed on the developer branch of catch2: https://github.com/catchorg/Catch2/pull/2317
We, however, have a copy of catch2 checked in the third_party directory, so our version doesn't have the fix.
So, updating catch2 will probably fix this error. We'd probably want to download the newer version of catch2 using cmake's FetchContent and delete catch2 from third_party while we're at it.
To Reproduce
Create a docker container with
docker run --rm -it ubuntu:jammy /bin/bash
and run the following commands:
apt-get update
apt-get install build-essential doxygen libgmp-dev pandoc git python3-pip -y
git clone https://github.com/symforce-org/symforce.git
cd symforce
pip3 install -r dev_requirements.txt
mkdir build
cd build
cmake ..
make -j $(nproc)
To see it work with a newer version of gcc, you can just run the above commands, except in ubuntu:focal (which ends up using gcc 9.4.0) by instead creating your docker container with
docker run --rm -it ubuntu:focal /bin/bash