build: Make G_FUZZING constexpr, require -DBUILD_FOR_FUZZING=ON to fuzz
g_fuzzing
is used inside Assume
at runtime, causing significant overhead in hot paths. See https://github.com/bitcoin/bitcoin/issues/31178
One could simply remove the g_fuzzing
check from the Assume
, but this would make fuzzing a bit less useful. Also, it would be unclear if g_fuzzing
adds a runtime overhead in other code paths today or in the future.
Fix all issues by making G_FUZZING
equal to the build option BUILD_FOR_FUZZING
, and for consistency in fuzzing, require it to be set when executing any fuzz target.
Fixes https://github.com/bitcoin/bitcoin/issues/31178
Temporarily this drops fuzzing from two CI tasks, but they can be re-added in a follow-up with something like https://github.com/bitcoin/bitcoin/pull/31073