I may not know modern C++ well enough, but I would think that, if you go through a translation unit, discarding everything ”not constexpr”, the result should compile to an object file without any code.
Repeat compilation (conceptually, the implementation might be more efficient), replacing anything ”constexpr” by what you got earlier, and you’re done.
Or am I overlooking something?