Add R2R knob to force value of TargetAllowsRuntimeCodeGeneration - #132889
Open
BrzVlad wants to merge 2 commits into
Open
Add R2R knob to force value of TargetAllowsRuntimeCodeGeneration#132889BrzVlad wants to merge 2 commits into
BrzVlad wants to merge 2 commits into
Conversation
iOS like configuration can be obtained by passing `--target-allows-runtime-code-generation:false`
|
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. |
Contributor
There was a problem hiding this comment.
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-generationoption 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.projbased 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. |
jkotas
reviewed
Aug 28, 2026
Contributor
There was a problem hiding this comment.
🔵 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 abooloption. If the property is ever set to a non-"true" token like0, crossgen2 argument parsing is likely to fail. Consider normalizing/mapping the property to an explicittrue/falsetoken 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
jkotas
approved these changes
Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
iOS like configuration can be obtained by passing
--target-allows-runtime-code-generation:false.When runtime is built with
dynamiccodecompiledfalse, 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/performancejob expected crossgen2 built from runtime withdynamiccodecompiledto haveTargetAllowsRuntimeCodeGenerationautomatically disabled. This regressed following the removal of theFEATURE_DYNAMIC_CODE_COMPILEDhack in https://github.com/dotnet/runtime/pull/130622/changes.