I'm not sure if this is the right place to discuss...
# compiler
w
I'm not sure if this is the right place to discuss compiler plugins, but please allow me to ask a question. Are there any best practices for implementing plugins that perform backend IR operations based on function calls? In particular, I'm struggling with the problem of incremental compilation skipping processing for some function calls, especially when I want to aggregate the results of generation into a specific object. I found a way to always compile only calls to specific functions (when there are arbitrary changes) using an inline function hack, but I don't think this is a recommended method. I also considered creating a custom caching mechanism, but it seems difficult to implement and impossible to handle cases where the number of callers decreases. I think that inline generation should be the way to go in such cases, but I would appreciate any information you might have.
y
Absolutely the right place to discuss plugins! IIRC, incremental compilation doesn't have incredible support for plugins. I know some plugins tell users to turn it off. Maybe Metro could be a source of inspiration? You can also try and store information in annotations, and then look it up to see what calls were already processed and thus are skipped here
w
Thank you for your reply.
I know some plugins tell users to turn it off.
I see, I didn't know there was a plugin to turn off incremental compilation. It was very helpful in considering the trade-offs.
Maybe Metro could be a source of inspiration?
Thank you for the recommendation, I'll take a look.
o
TestBalloon collects top-level properties, which required it to disable incremental compilation before Kotlin 2.3.20. Now it can register such references with the compiler in a way that works with incremental compilation. Maybe that helps.
w
TestBalloon
Thank you. I understand that
pluginContext.recordLookup
is probably an important mechanism; I will look into it.