-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NativeAOT] Update documentation when building native libraries with a custom native host #82156
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsThe documentation for building native libraries with NativeAOT should be updated with the description of recently added feature: compiling a managed program as a static library linked with a custom native host application: #81873 /cc: @AustinWise @dotnet/ilc-contrib
|
I'll eventually add this to the docs, but this is the short version of how to build a static library that also includes the executable entry point. Add this property to your project: <PropertyGroup>
<IlcArg>-splitinit</IlcArg>
</PropertyGroup> This will generate a symbol for the managed main function. You can call it by writing the following C declaration: #if defined(_WIN32)
extern "C" int __managed__Main(int argc, wchar_t* argv[]);
#else
extern "C" int __managed__Main(int argc, char* argv[]);
#endif Otherwise follow the instructions for linking the static library. |
I wonder if we really need to document/support this outside Xamarin. The static library building experience is subpar and not something we suggest in general (need to worry about versions of C/C++ compiler and libc the runtime was built against and versions the user code is using). Dynamic libraries provide a better experience and most people should go with that. Static libraries with custom main are a niche of a niche and it might be better to not overcomplicate the docs with that. |
This seems like the kind of thing that could go in a runtime-repo doc file, but we wouldn't want to put in public documentation. |
I agree it's a pretty niche feature. The |
I understand, I just wanted to avoid having this feature left undocumented. Would https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/interop.md maybe be a better location or you would like to keep it private (internal) completely? |
I made a sample for the https://github.com/AustinWise/SplitInit I'll see about putting something in the official interop docs. It looks like Xamarin is using the |
Thank you for the provided sample. Regarding the public documentation, I am not sure what should be the right solution. @MichalStrehovsky @jkotas what do you think? |
I agree with what Michal said in #82156 (comment) . I do not think it is worth it to complicate the mainstream documentation or samples with
Having document in Xamarin that explains how all parts are put together (including the static registrar, etc.) sounds reasonable to me. |
I am closing this issue in favour of: dotnet/macios#18585 which should track providing a public documentation regarding Xamarin+NativeAOT support. Please feel free to add more context there, if necessary, and review the changes once we get a PR for it. |
The documentation for building native libraries with NativeAOT should be updated with the description of recently added feature: compiling a managed program as a static library linked with a custom native host application: #81873
/cc: @AustinWise @dotnet/ilc-contrib
The text was updated successfully, but these errors were encountered: