-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add support for host startup hooks to Mono #47462
Comments
Tagging subscribers to this area: @vitek-karas, @agocke Issue DetailsThe dotnet core host supports host startup hooks to inject assemblies to run before the runtime. We should implement support for this in Mono. In addition to the ALC use-cases described in the design document, above, it may also be used for #44806 to configure and set up hot reload
|
For reference, CoreCLR calls the startup hooks from runtime/src/coreclr/vm/assembly.cpp Line 1646 in 69e114c
And the class |
Tagging subscribers to this area: @CoffeeFlux Issue DetailsThe dotnet core host supports host startup hooks to inject assemblies to run before the runtime. We should implement support for this in Mono. In addition to the ALC use-cases described in the design document, above, it may also be used for #44806 to configure and set up hot reload
|
Because of embedders, (who must call Also I'm assuming that the startup hooks are primarily about setting up the managed environment. If they need to do Android or iOS API calls, running them near the end of |
In CoreCLR startup hooks only run when |
cc @lambdageek - is this something we can get to for 7.0 ? |
@SamMonoRT We can probably add the runtime support, but:
It might make sense to add the support for desktop only so that, for example, s390x can use startup hooks to more closedly match coreclr behavior on their platform. |
Moving to 8.0.0 |
We may want this early in net8 to support Ctrl-F5 hot reload on mobile |
Looks like the "how to get code on the device" problem is understood by @mcumming and @jonathanpeppers, so the runtime should just do our bits (look for the var, call the StartupHookProvider class) |
…#80391) Fixes #47462 **CoreCLR** This also makes some changes to CoreCLR to decouple EventPipe and startup hooks. Presently if startup hooks are disabled, `RuntimeEventSource.Initialize` is never called. The PR makes the two features independent by moving runtime event source initialization out of the startup hook feature check. * Implement startup hooks support in Mono * Keep StartupHookProvider.ProcessStartupHooks under feature flag * Don't catch/cleanup the exceptions from startup hooks. * Add an ios simulator startup hook functional test * Implement Android functional test * Add WASM functional test * Make a single managed startup method for CoreCLR A common configuration for coreclr is event source enabled, startup hooks disabled, so at least one managed call is inevitable. Since we have to call into managed no matter what, let the trimmer determine what happens once we get there. This is different from mono where published trimmed apps may have both startup hooks and event source disabled. In that case we would rather avoid a managed call to an empty method early in startup. * fix build and line damage
…dotnet#80391) Fixes dotnet#47462 **CoreCLR** This also makes some changes to CoreCLR to decouple EventPipe and startup hooks. Presently if startup hooks are disabled, `RuntimeEventSource.Initialize` is never called. The PR makes the two features independent by moving runtime event source initialization out of the startup hook feature check. * Implement startup hooks support in Mono * Keep StartupHookProvider.ProcessStartupHooks under feature flag * Don't catch/cleanup the exceptions from startup hooks. * Add an ios simulator startup hook functional test * Implement Android functional test * Add WASM functional test * Make a single managed startup method for CoreCLR A common configuration for coreclr is event source enabled, startup hooks disabled, so at least one managed call is inevitable. Since we have to call into managed no matter what, let the trimmer determine what happens once we get there. This is different from mono where published trimmed apps may have both startup hooks and event source disabled. In that case we would rather avoid a managed call to an empty method early in startup. * fix build and line damage
The dotnet core host supports host startup hooks to inject assemblies to run before the main method.
We should implement support for this in Mono.
However for some use cases, such as mobile workloads, it is not enough to add runtime support - we will also need workload integration to bundle the startup hook assemblies into the mobile apps. At that point it may make sense to use a more static approach - instead of inspecting an environment variable and doing method lookup using reflection, just execute the hooks directly from the mobile embedders before the runtime starts (or pass a less dynamic structure to the runtime to execute the methods on the embedders' behalf).
Also need to investigate if in general we need to give the embedders a way to identify the right time to run the startup hooks (for example after some managed code executes to set up the Android or ios environment).
Additionally if the startup hooks need any special permissions beyond what the app needs, the workloads need to be involved.
In scenarios where MonoVM may be substituted for CoreCLR (ie console apps) we should implement the startup hook support as spec'd.
The text was updated successfully, but these errors were encountered: