CMakeLists.txt currently states: https://github.com/bitcoin/bitcoin/blob/9cb9651d92ddb5d92724f6a52440601c7a0bbcf8/CMakeLists.txt#L487-L491
However that isn’t always true. If, for example, depends is built with DEBUG=1
, and CMake is configured with -DCMAKE_BUILD_TYPE=Debug
, -O1
will actually be used. This is confusing, not just because the documentation is incorrect, but when making a change to switch the build type to Debug
in oss-fuzz, it’s caused unexpected results: https://github.com/google/oss-fuzz/pull/12443#issuecomment-2326564546.
Rather than assuming that builds with the Debug
build type don’t use optimisations, the check should be fixed to actually check what optimisation level is being used.
i.e:
0make -C depends/ NO_QT=1 NO_WALLET=1 NO_ZMQ=1 NO_UPNP=1 -j17 DEBUG=1
1cmake -B build --toolchain=/root/ci_scratch/depends/x86_64-pc-linux-gnu/toolchain.cmake -DCMAKE_BUILD_TYPE=Debug
2<snip>
3C++ compiler flags .................... -pipe -std=c++20 -O0 -ftrapv -O1 -g3
(-O1
is last, so is what will be used).