Skip to content

Xamarin iOS should call monovm_initialize for .NET 6 #10504

Closed

Description

@CoffeeFlux

monovm_initialize is a cleaned-up equivalent to coreclr_initialize, which is one of the .NET Core hosting functions in CoreClrHost.h.

Signature: https://github.com/dotnet/runtime/blob/1d9e50cb4735df46d3de0cee5791e97295eaf588/src/mono/mono/mini/mono-private-unstable.h#L30

It needs to be called in net6 embedding projects before the runtime is started. Specifically, what it's doing is:

  • Passing in various runtime properties, a subset of which we support. The important ones are:
    • TRUSTED_PLATFORM_ASSEMBLIES: Hard-coded list of assemblies, intended to be used for the BCL and fast-path'd in the loading algorithm. They also have some ALC loading implications (default context only).
    • APP_PATHS: Essentially the same as MONO_PATH. Prefer TRUSTED_PLATFORM_ASSEMBLIES where possible.
    • NATIVE_DLL_SEARCH_DIRECTORIES: Extra directories to check when loading native libraries for pinvokes.
    • System.Globalization.Invariant: Alternative way to set the DOTNET_SYSTEM_GLOBALIZATION_INVARIANT env var.
    • PINVOKE_OVERRIDE: First-chance native callback to control P/Invoke resolution, see Static linking of native libs runtime#44505
  • Adding netcore-specific loader hooks, some of which use those properties
  • Setting the runtime to use strict assembly name checking, as we still default to the historical behavior otherwise

The runtime properties are also set in files like .runtimeconfig.json, which is parsed in by the default host and passed to coreclr_initialize. Mono embedders not using the default host will have to handle this themselves, probably at build time in the case of Xamarin, if they wish to support those files.

Applications not calling monovm_initialize may result in a runtime error at some undetermined point in the future.



Time estimate: 2 weeks

Activity

  1. self-assigned this
    on Jan 22, 2021
  2. added
    dotnet
    iOS
    macOS
    enhancement
    on Jan 22, 2021
  3. added this to the .NET 6 milestone on Jan 22, 2021
  4. rolfbjarne commented on Jan 22, 2021

    @rolfbjarne
    Member

    OK, I'll have a look at this.

    Is monovm_initialize already available to call, or do I have to wait until it's implemented?

  5. CoffeeFlux commented on Jan 22, 2021

    @CoffeeFlux
    Author

    Already implemented. It's called by the default dotnet host, so if it didn't work we wouldn't function anywhere.

  6. CoffeeFlux commented on Jan 22, 2021

    @CoffeeFlux
    Author

    The main limitations with it right now are:

  7. lambdageek commented on Jan 22, 2021

    @lambdageek
    Member

    Worth adding, monovm_intialize is also responsible for surfacing System.AppContext properties from the embedding host through the runtime up to managed https://gist.github.com/lambdageek/c6f101503b6db9876e281e677980b6df

  8. added
    dotnet-pri0
    feature
    and removed
    enhancement
    on Feb 3, 2021
  9. added
    dotnet-pri1
    and removed
    dotnet-pri0
    on May 10, 2021
  10. rolfbjarne commented on Jul 30, 2021

    @rolfbjarne
    Member

    We're adding all the assemblies in the app bundle to TRUSTED_PLATFORM_ASSEMBLIES, so APP_PATHS shouldn't be needed.

  11. added a commit that references this issue on Jul 30, 2021
    7ebdcc0
  12. added a commit that references this issue on Aug 2, 2021
    440ff7c
  13. ghost locked as resolved and limited conversation to collaborators on Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

dotnetdotnet-pri1estimate-2wfeatureiOSmacOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions