-
Notifications
You must be signed in to change notification settings - Fork 538
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
CLR hosting #9572
base: main
Are you sure you want to change the base?
CLR hosting #9572
Conversation
c085352
to
13bbd93
Compare
82cfb8a
to
77aa40a
Compare
Configuration.props
Outdated
@@ -216,5 +218,6 @@ | |||
<ItemGroup> | |||
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="Mono" /> | |||
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="NativeAOT" /> | |||
<AndroidAbiAndRuntimeFlavor Include="@(AndroidSupportedTargetJitAbi)" AndroidRuntime="CoreCLR" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't figure out if we should case it CoreClr
or CoreCLR
:
- https://grep.app/search?q=CoreCLR&case=true&filter[repo][0]=dotnet/runtime
- https://grep.app/search?q=CoreClr&case=true&filter[repo][0]=dotnet/runtime
I found both, so we can probably decide which we prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like CoreCLR better, since CLR is an acronym
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'Mono' Or '$(AndroidRuntime)' == '' " Include="libnet-android.debug" /> | ||
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'Mono' Or '$(AndroidRuntime)' == '' " Include="libnet-android.release" /> | ||
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'CoreCLR' " Include="libmono-android.debug" /> | ||
<_ExcludedNativeLibraries Condition=" '$(AndroidRuntime)' == 'CoreCLR' " Include="libmono-android.release" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, $(AndroidRuntime)
isn't defined for customer's project builds. I think it would always be blank?
Right now, we only have these:
$(UseMonoRuntime)=true
$(_AndroidNativeAot)=true
Maybe we need to figure out what property xamarin/xamarin-macios uses to identify CoreCLR? You can use it for macOS, to choose between Mono & CoreCLR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would always be blank now and I think we should always expect a value in there. The macios way looks fine.
<_AndroidUseCLR Condition=" '$(AndroidRuntime)' == 'CoreCLR' ">True</_AndroidUseCLR> | ||
<_AndroidUseCLR Condition=" '$(AndroidRuntime)' != 'CoreCLR' ">False</_AndroidUseCLR> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(AndroidRuntime)
is probably always blank in customer's Android projects, but is this the property to select a runtime? Should the property be in DefaultProperties.targets
?
Maybe we should align with xamarin/xamarin-macios?
Ok, here is what we should do for MSBuild properties for now:
We could remove |
I like |
Context: #9572 (comment) Context: https://github.com/xamarin/xamarin-macios/blob/2009c571aa8a975ab0e0b1785e5484dbd64d6f9b/dotnet/targets/Xamarin.Shared.Sdk.targets#L1004-L1006 To align with xamarin/xamarin-macios, the following public MSBuild properties can be used to select a runtime for iOS, macOS, etc.: * `$(UseMonoRuntime)=true`: MonoVM * `$(UseMonoRuntime)=false`: CoreCLR * `$(PublishAot)=true`: NativeAOT * Defaults if blank, select MonoVM Introduce a private `$(_AndroidRuntime)` property we can use throughout our build to know which runtime is being targetted. This way, if a new property is designed in the future, we can keep using `$(_AndroidRuntime)` and simply update the defaults.
…#9686) Context: #9572 (comment) Context: https://github.com/xamarin/xamarin-macios/blob/2009c571aa8a975ab0e0b1785e5484dbd64d6f9b/dotnet/targets/Xamarin.Shared.Sdk.targets#L1004-L1006 To align with xamarin/xamarin-macios, the following public MSBuild properties can be used to select a runtime for iOS, macOS, etc.: * `$(UseMonoRuntime)=true`: MonoVM * `$(UseMonoRuntime)=false`: CoreCLR * `$(PublishAot)=true`: NativeAOT * Defaults if blank, select MonoVM Introduce a private `$(_AndroidRuntime)` property we can use throughout our build to know which runtime is being targeted. This way, if a new property is designed in the future, we can keep using `$(_AndroidRuntime)` and simply update the defaults.
...d.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets
Outdated
Show resolved
Hide resolved
Context: #9572 #9572 is prototyping CoreCLR support, and as part of that it renamed e.g. `src/native/monodroid` to `src/native/mono/monodroid` -- "inserting" a "runtime" value underneath `src/native` -- so that CoreCLR code won't be intermingled with MonoVM code. Separate out these file moves into a separate PR, to reduce the size and review complexity of #9572.
Context: #9572 Add support for Unicode strings to the LLVM IR generator, together with de-duplication and support for outputting the same string encoded both as UTF-8 and Unicode (UTF16LE). Additionally, since all the files are generated from separate tasks, we don't have a global LLVM IR state which can keep track of strings and ensure that there are no duplicate symbol names. To prevent potential clashes, each generator now sets the default string group name which is unique for each module. ; From marshal_methods.arm64-v8a.ll @.mm.0 = dso_local constant [102 x i8] c"Android.App.Activity, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065\00", align 1 ; from environment.arm64-v8a.ll @.env.0 = dso_local constant [7 x i8] c"normal\00", align 1 ; from typemaps.arm64-v8a.ll @.tmr.0 = dso_local constant [22 x i8] c"android/os/BaseBundle\00", align 1 `mm`, `env`, and `tmr` are the default string groups for each module. In the future, we should try to manage strings globally (which would also result in more de-duplication).
Context: #9572 Add a new `src/native/common` for files which can be shared between MonoVM and CoreCLR, and move common infrastructural source there, such as `jni-wrappers.hh` and `strings.hh`. Copy the parts of `src/native/mono` that will be used by #9572 but require modification to be used with CoreCLR into `src/native/clr`. `src/native/clr` is not yet compiled; this merely serves the purpose of making #9572 smaller and easier to review, copying code from the existing MonoVM implementation to the CoreCLR one, mostly without functional changes. There are very few functional changes, most code is copied verbatim with the only changes being formatting, function declaration syntax and, sometimes, the class in which the code lives. Only the code that's actually used in #9572 is copied. This allows us to refresh our runtime code while cleaning it up at the same time, with the goal of having an implementation that is tailored strictly towards CoreCLR (which doesn't have e.g. Mono's embedding APIs)
...d.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets
Outdated
Show resolved
Hide resolved
This is needed until #9572 is merged, since the != 'NativeAOT' would enable the guarded code to run also for `CoreCLR`, which is not fully functional in this PR.
af8bb41
to
c853ea1
Compare
Context: #9572 PR #9572 is quite large. Extract out a set of changes for easier review. Co-authored-by: Jonathan Pryor <[email protected]> Co-authored-by: Jonathan Peppers <[email protected]>
b9bd06b
to
ee0c8a5
Compare
Caveats: * Trimming must be turned off * Typemaps don't work (everything is resolved dynamically) * Marshal methods must be turned off (they use MonoVM embedding API)
By convention (and often enforced requirement), `$(OutputPath)` ends with `\`, which means that quoting it for use with `<Exec/>`: <Exec Command="whatever "$(OutputPath)"" /> will often result in an *invalid* command, because the `\` escapes the quote! whatever "C:\path\to\output\" # ruh roh! The fix is to instead use `$(OutputPath.OutputPath.TrimEnd('\')`, which ensures that the path does *not* end in `\`, preventing the unintentional escape usage: whatever "C:\path\to\output" # yay!
620f785
to
8583a0e
Compare
Required CoreCLR runtime changes: dotnet/runtime#112705