In the project I'm working on a simple change, like adding echo call to a procedure, in single Nim file leads to about 80 .cpp files being recreated. It has terrible impact on productivity and even though Nim compiler is quite fast, I have to wait a lot after making a change before I can test it, because C++ compiler has to recompile 80 files.
After looking into diffs of .cpp files before and after making changes, I think the problem is in how names are generated for variables with TMP prefix. They seem to use a global counter for suffix and so whenever you change a place where the counter is around 2000, every file where it was higher than 2000 gets changed.
Not sure if it's a viable solution, but if those variables had file-local counters, that would resolve the issue.
This seems to be caused by the usage of idgen.gBackendId in ccgexprs.nim when generating names for string literals and others.
C code generation now deterministic; fixes #4364
@Araq Thanks for the fix! Incremental compilation works much better now.
Sometimes you still have to recompile almost the whole project, but that's due to name mangling scheme. That usually happens when a change to a type is applied (e.g. adding a field to an object type or a new value to enum type). Changes to procedures seem to affect only the file you change and few other dependent/related files.