From 5f6a34bec123338e94511df1e22e98f180eea161 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Fri, 28 Aug 2026 16:44:49 +0300 Subject: [PATCH 1/2] Add knob to force value of TargetAllowsRuntimeCodeGeneration iOS like configuration can be obtained by passing `--target-allows-runtime-code-generation:false` --- src/coreclr/crossgen-corelib.proj | 1 + src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs | 3 +++ src/coreclr/tools/aot/crossgen2/Program.cs | 3 ++- src/coreclr/tools/aot/crossgen2/Properties/Resources.resx | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/coreclr/crossgen-corelib.proj b/src/coreclr/crossgen-corelib.proj index 363c82d242359c..ebe09a78aa9dad 100644 --- a/src/coreclr/crossgen-corelib.proj +++ b/src/coreclr/crossgen-corelib.proj @@ -161,6 +161,7 @@ $(CrossGenDllCmd) "--opt-cross-module:*" $(CrossGenDllCmd) --composite $(CrossGenDllCmd) --targetos:$(TargetOS) + $(CrossGenDllCmd) --target-allows-runtime-code-generation:$(FeatureDynamicCodeCompiled) $(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data $(CrossGenDllCmd) -O diff --git a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs index 644fe3d92b02ff..396e5b42f6e896 100644 --- a/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs +++ b/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs @@ -94,6 +94,8 @@ internal class Crossgen2RootCommand : RootCommand new("--maxgenericcyclebreadth") { DefaultValueFactory = _ => ReadyToRunCompilerContext.DefaultGenericCycleBreadthCutoff, Description = SR.GenericCycleBreadthCutoff }; public Option TargetOS { get; } = new("--targetos") { Description = SR.TargetOSOption }; + public Option TargetAllowsRuntimeCodeGeneration { get; } = + new("--target-allows-runtime-code-generation") { Description = SR.TargetAllowsRuntimeCodeGenerationOption }; public Option JitPath { get; } = new("--jitpath") { Description = SR.JitPathOption }; public Option PrintReproInstructions { get; } = @@ -199,6 +201,7 @@ public Crossgen2RootCommand(string[] args) : base(SR.Crossgen2BannerText) Options.Add(GenericCycleBreadthCutoff); Options.Add(TargetArchitecture); Options.Add(TargetOS); + Options.Add(TargetAllowsRuntimeCodeGeneration); Options.Add(JitPath); Options.Add(PrintReproInstructions); Options.Add(SingleMethodTypeName); diff --git a/src/coreclr/tools/aot/crossgen2/Program.cs b/src/coreclr/tools/aot/crossgen2/Program.cs index 691add6dd78b2a..75892ef120f613 100644 --- a/src/coreclr/tools/aot/crossgen2/Program.cs +++ b/src/coreclr/tools/aot/crossgen2/Program.cs @@ -78,7 +78,8 @@ public int Run() (TargetArchitecture targetArchitecture, TargetOS targetOS, TargetAbi targetAbi) = Helpers.GetTargetSpec(Get(_command.TargetArchitecture), Get(_command.TargetOS)); - bool targetAllowsRuntimeCodeGeneration = GetTargetAllowsRuntimeCodeGeneration(targetOS, targetArchitecture); + bool targetAllowsRuntimeCodeGeneration = Get(_command.TargetAllowsRuntimeCodeGeneration) + ?? GetTargetAllowsRuntimeCodeGeneration(targetOS, targetArchitecture); // Crossgen2 is partial AOT and its pre-compiled methods can be thrown away at runtime if // they mismatch in required ISAs or computed layouts of structs. On targets that allow diff --git a/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx b/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx index 8a34770d35e215..1253393d39490b 100644 --- a/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx +++ b/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx @@ -282,6 +282,9 @@ Target architecture for cross compilation + + Whether the target supports runtime code generation + Target OS for cross compilation From 438e5ac83137b872235fc6ae2f440ed5def134f3 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Sat, 29 Aug 2026 10:26:27 +0300 Subject: [PATCH 2/2] fix description --- src/coreclr/tools/aot/crossgen2/Properties/Resources.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx b/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx index 1253393d39490b..f07167b26a351f 100644 --- a/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx +++ b/src/coreclr/tools/aot/crossgen2/Properties/Resources.resx @@ -283,7 +283,7 @@ Target architecture for cross compilation - Whether the target supports runtime code generation + Override whether the target supports runtime code generation Target OS for cross compilation