TMP variable name generation should be more stable #4364

endragor opened this Issue Jun 18, 2016 · 2 comments


None yet

2 participants


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.

Araq commented Jun 18, 2016

This seems to be caused by the usage of idgen.gBackendId in ccgexprs.nim when generating names for string literals and others.

@Araq Araq added the Showstopper label Jun 18, 2016
@Araq Araq closed this in 4b0ba5e Jun 22, 2016

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment