https://kotlinlang.org logo
#compiler
Title
# compiler
n

natario1

07/29/2022, 4:40 PM
I’m writing a plugin to generate
@CName
functions and have them exported in the final K/N binary. But looking at the file with
nm
, I can see that the generated symbol is not exported. Is it even possible to achieve this? Maybe the export pipeline runs before
IrGeneration
and so my symbol is useless? Or I’m doing something wrong. I’m generating my function and then calling
irFile.declarations.add(function)
, something I’m a bit unsure of.
s

shikasd

07/30/2022, 12:26 AM
Maybe the export pipeline runs before IrGeneration and so my symbol is useless?
Yes, exactly that. Consider using KSP instead, it generates source code directly and the compiler should pick it up for this case:)
n

natario1

07/30/2022, 10:24 AM
Thanks Andrei! What about SyntheticResolve, any chance to declare an annotated function there and implement it later? I read that SyntheticResolve is not able to generate top level functions (which @CNames should be), but I found a hack to work with CName functions inside objects too.
I tried, looks like it’s possible with SyntheticResolve, but it all looks too hacky. I will think about it 🙂
8 Views