You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[NativeAOT] Update documentation when building native libraries with a custom native host #82156
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.
The CustomNativeMain property might be more appropriate to document in a public place. It integrates nicely with the existing NativeAOT MSBuild targets.
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.
I understand, I just wanted to avoid having this feature left undocumented.
Especially because it is the integration point for both Xamarin and AppleAppBuilder and would be useful for developers working on the integration to have it documented somewhere.
Regarding the public documentation, I am not sure what should be the right solution.
It is true that we integrated Xamarin builds with NativeAOT, as we knew (or discovered) what flags need to be passed to achieve this, and there is an open issue on simplifying that process: #87187
Nevertheless, I think it would be useful to have (somewhere) a documentation explaining the integration process. Maybe the right place for such documentation is not dotnet/runtime, but rather Xamarin (and/or other app models) I am not sure.
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 CustomNativeMain explanation.
I think it would be useful to have (somewhere) a documentation explaining the integration process. Maybe the right place for such documentation is not dotnet/runtime, but rather Xamarin (and/or other app models) I am not sure.
Having document in Xamarin that explains how all parts are put together (including the static registrar, etc.) sounds reasonable to me.
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.
Activity
AustinWise commentedon Feb 27, 2023
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:
This will generate a symbol for the managed main function. You can call it by writing the following C declaration:
Otherwise follow the instructions for linking the static library.
MichalStrehovsky commentedon Feb 28, 2023
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.
agocke commentedon Feb 28, 2023
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.
AustinWise commentedon Mar 1, 2023
I agree it's a pretty niche feature.
The
CustomNativeMainproperty might be more appropriate to document in a public place. It integrates nicely with the existing NativeAOT MSBuild targets.ivanpovazan commentedon Mar 1, 2023
I understand, I just wanted to avoid having this feature left undocumented.
Especially because it is the integration point for both Xamarin and AppleAppBuilder and would be useful for developers working on the integration to have it documented somewhere.
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?
AustinWise commentedon Jun 25, 2023
I made a sample for the
CustomNativeMainproperty here:https://github.com/AustinWise/SplitInit
I'll see about putting something in the official interop docs.
It looks like Xamarin is using the
CustomNativeMainproperty, so there is probably no need to document the-splitinitflag to ILC.exe.ivanpovazan commentedon Jun 29, 2023
Thank you for the provided sample.
I wonder if the sample and/or the description explaining the
CustomNativeMainproperty could be added to: https://github.com/dotnet/samples/tree/main/core/nativeaot instead.Regarding the public documentation, I am not sure what should be the right solution.
It is true that we integrated Xamarin builds with NativeAOT, as we knew (or discovered) what flags need to be passed to achieve this, and there is an open issue on simplifying that process: #87187
Nevertheless, I think it would be useful to have (somewhere) a documentation explaining the integration process. Maybe the right place for such documentation is not dotnet/runtime, but rather Xamarin (and/or other app models) I am not sure.
@MichalStrehovsky @jkotas what do you think?
jkotas commentedon Jun 29, 2023
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
CustomNativeMainexplanation.Having document in Xamarin that explains how all parts are put together (including the static registrar, etc.) sounds reasonable to me.
ivanpovazan commentedon Jul 25, 2023
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.