Skip to content

Add R2R knob to force value of TargetAllowsRuntimeCodeGeneration - #132889

Open
BrzVlad wants to merge 2 commits into
dotnet:mainfrom
BrzVlad:fix-r2r-dyn-code-compiled
Open

Add R2R knob to force value of TargetAllowsRuntimeCodeGeneration#132889
BrzVlad wants to merge 2 commits 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.

Comment thread src/coreclr/tools/aot/crossgen2/Properties/Resources.resx Outdated
Copilot AI review requested due to automatic review settings August 29, 2026 07:26

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.

🔵 Needs a closer look

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/coreclr/crossgen-corelib.proj:164

  • $(FeatureDynamicCodeCompiled) is treated as boolean-like across the build (e.g., anything other than "true" is effectively false), but this command line forwards the raw value to a bool option. If the property is ever set to a non-"true" token like 0, crossgen2 argument parsing is likely to fail. Consider normalizing/mapping the property to an explicit true/false token before passing it.
      <CrossGenDllCmd Condition="'$(FeatureDynamicCodeCompiled)' != ''">$(CrossGenDllCmd) --target-allows-runtime-code-generation:$(FeatureDynamicCodeCompiled)</CrossGenDllCmd>
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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