dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.98k stars 4.66k forks source link

NativeAOT - prior art for infering custom attributes #108101

Open yowl opened 5 hours ago

yowl commented 5 hours ago

I want to ask if anyone thinks there is prior art for this problem, https://github.com/dotnet/runtimelab/issues/2626

In NativeAOT-LLVM, if a library is referenced that contains JSExport, we need to mark it as UnmanagedCallersOnly in addition so we can root it, export it, and get the right calling convention. Example is the Register method created by the JSExport source generator. Rooting can be solved with theRdXmlRootProvider but the other problems are harder. One way is to change the source generator to always add it, and another way, not necessarily correct, is to view this as: "NativeAOT requires additional attributes that the library author might not be aware of", so I was wondering if there is any prior art?

Thanks!

dotnet-policy-service[bot] commented 5 hours ago

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas See info in area-owners.md if you want to be subscribed.

yowl commented 42 minutes ago

Actually realised that the source generator already creates:

[UnmanagedCallersOnly(EntryPoint = "XpfSimple__GeneratedInitializer__Register_")]
private static void __Register__Export()
{
    __Register_();
}

Which looks like it is for this purpose, I'll close this for now.