One problem we are regularly running into is that most LLVM builds ship without asserts enabled, and that at least a few times each release we were seeing asserts triggering on code in wild. We previously tried to run with asserts enabled for our custom clang deployment here at Epic Games, and had to turn it off because we kept running into broken things upstream (like this one we reported).
It’s painful for us to maintain an assert-built-clang and a non-assert-built-clang in our build systems, so what I want to investigate is moving the asserts in LLVM to be controllable via an LLVM option.
Here’s my rough strawperson idea for this:
- We’d add a new mode to the CMake assertion-enabled variable for
RUNTIME
. - We’d add a new
llvm_assert
that would default to C’s assert with assertsON
like before, a no-op withOFF
and map to a new assert backed by acl::opt
-enablement whenRUNTIME
is specified. - We’d have to check all the cases where
NDEBUG
is used to add data structures for asserting too. - Ideally we’d want to be sure we could enable this option via the C API (I floated this idea to a bunch of gamedev friends and someone with a custom language that uses the C API really really really wanted to be able to use this too).
Assuming the above would acceptable - we could then look at potentially switching the default assert mode to be always-on (behind an option), once we could investigate the runtime and executable size costs. I want that step to be out-of-scope from the initial proposal, as there be dragons that don’t need to be fought quite yet!