Skip to content

Add R2R knob to force value of TargetAllowsRuntimeCodeGeneration - #132889

Open
BrzVlad wants to merge 1 commit into
dotnet:mainfrom
BrzVlad:fix-r2r-dyn-code-compiled
Open

Add R2R knob to force value of TargetAllowsRuntimeCodeGeneration#132889
BrzVlad wants to merge 1 commit into
dotnet:mainfrom
BrzVlad:fix-r2r-dyn-code-compiled

Conversation

@BrzVlad

@BrzVlad BrzVlad commented Aug 28, 2026

Copy link
Copy Markdown
Member

iOS like configuration can be obtained by passing --target-allows-runtime-code-generation:false.

When runtime is built with dynamiccodecompiled false, this also makes sure that corelib is build in this configuration, just to make sure that corerun and testhost respect it. We don't yet test this configuration on CI, so no additional changes are done yet on the testing infra.

dotnet/performance job expected crossgen2 built from runtime with dynamiccodecompiled to have TargetAllowsRuntimeCodeGeneration automatically disabled. This regressed following the removal of the FEATURE_DYNAMIC_CODE_COMPILED hack in https://github.com/dotnet/runtime/pull/130622/changes.

iOS like configuration can be obtained by passing `--target-allows-runtime-code-generation:false`
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an explicit crossgen2 command-line knob to override the inferred TargetAllowsRuntimeCodeGeneration value, and wires it into the CoreCLR corelib crossgen invocation so that builds with FeatureDynamicCodeCompiled=false produce matching ReadyToRun behavior.

Changes:

  • Add --target-allows-runtime-code-generation option to crossgen2 (nullable bool override).
  • Use the override (when provided) instead of the target OS/arch heuristic in crossgen2 compilation setup.
  • Pass the knob from crossgen-corelib.proj based on $(FeatureDynamicCodeCompiled) so corelib R2R generation matches the runtime configuration.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/coreclr/tools/aot/crossgen2/Properties/Resources.resx Adds the help/description string for the new CLI option.
src/coreclr/tools/aot/crossgen2/Program.cs Applies the option override and feeds it into ReadyToRun compilation behavior and context construction.
src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs Declares and registers the new --target-allows-runtime-code-generation option.
src/coreclr/crossgen-corelib.proj Propagates $(FeatureDynamicCodeCompiled) into crossgen2 via the new option.

<value>Target architecture for cross compilation</value>
</data>
<data name="TargetAllowsRuntimeCodeGenerationOption" xml:space="preserve">
<value>Whether the target supports runtime code generation</value>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<value>Whether the target supports runtime code generation</value>
<value>Override whether the target allows runtime code generation</value>

Starting the description with "Whether" seems inconsistent with other descriptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants