I’m writing a plugin to generate `@CName` function...
# compiler
n
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
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
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 🙂