https://kotlinlang.org logo
r

raulraja

05/31/2021, 1:55 PM
Hello everyone!, I was looking at
org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
and looking into how to integrate with plugins that depend on
org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
and
org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
. I see
AllOpen
and others are connected to the new FIR frontend and I was hoping to run some compiler plugin tests and work on the FIR support for arrow meta. I have a couple of questions that came up while I was working on this. Here it goes in case anyone can help. 1. The
FirExtensionRegistrar
unlike the
ComponentRegistrar
is not an interface but an abstract class and it requires a separate lifecycle. Once instantiated for regular CLI plugins and another for the FIR style of subscription. Did I miss-understood this or is there a way to integrate this with existing compiler plugins based on the
ComponentRegistrar
? 2. Even when declaring both of those extensions and enabling FIR with
configuration.put(CommonConfigurationKeys.USE_FIR, true)
the override for the FIR plugin`override fun ExtensionRegistrarContext.configurePlugin(): Unit` never gets called, Is there something else needed to enable FIR beside that flag? If anyone has had success testing the FIR extension points or could provide any guidance or example as to how to enable them I’d very much appreciate it. Thanks!
d

dmitriy.novozhilov

05/31/2021, 2:55 PM
Hi Raul
FirExtensionRegistrar
and corresponding infrastructure is a PoC prototype which we implemented a year ago. Currently there is no API for FIR compiler plugins. All FirExtensions you may find in project didn't work at all and will be changed in future, so it's meaningless to try to implement something with them
Currently the main focus for FIR team is to release FIR in alpha stage by this fall, so all our resources are concentrated on implementing missing diagnostics and fixing existing bugs. Work on plugins postponed until this point, so some early API will be accessible for compiler plugin developers only by end of 2021 (I hope), not earlier
We will definitely announce when it will be available (in blogbost or in this channel)
If you really want to play with FIR I recommend you to just fork kotlin project and change compiler directly. I can write some guidelines about FIR pipeline if it will be needed
r

raulraja

05/31/2021, 3:05 PM
Thanks so much @dmitriy.novozhilov and this clarifies it. I was thinking while I wait for the compiler extensions for FIR to make it that maybe I could bootstrap the FIR process in
AnalysisExtension.doAnalysis
method to send all the KtFiles to Fir. If you have any pointers to code anywhere to launch FIR from analysis or other part that would make sense that may help. Thanks!
d

dmitriy.novozhilov

05/31/2021, 3:09 PM
Do you interested in FIR research running compiler on small tests or on some real projects? Or maybe both?
r

raulraja

05/31/2021, 3:14 PM
yes to all 🙂
d

dmitriy.novozhilov

05/31/2021, 3:16 PM
Ok, I will write some doc today or tomorrow
r

raulraja

05/31/2021, 3:16 PM
thank you so much, appreciate your time and help 🙏
38 Views