This sounds like you are doing something that is not intended to work.
Global counters at comptime if they work somehow, are a bug that you are exploiting. Using such bugs, are counter to the efforts of getting Zig to a state where it can incrementally compile things and compile more things in parallel.
Instead of doing that sort of thing, write code that explicitly registers and collects types in an array and use the index of the type in the array.
I think if you can’t do that, then comptime might not be the right level to implement your features, that is why it isn’t the only way to do meta programming. Instead of exploiting comptime, rethink it, maybe use the buildsystem.
What you describe sounds brittle and like it tries to make things work magically. Instead just write code that actually does things, instead of gluing everything up within the implementation, to then put a pretty interface on top of it.
Throw away the pretty interface and get the pipes simple and clear, write libraries, not frameworks where nobody wants to look at the plumbing.
This is my personal opinion, but this contorting the language into another pseudo language which then is called a framework, seems to bring all kinds of problems.
My 2 cents: either write an actual language implementation or write libraries, not this strange mix. I think you are trying to squeeze your solution into Zig at the wrong level, use buildsteps, or code generation, not a hacked version of comptime.