Skip to content
Open
329 changes: 150 additions & 179 deletions dotnet/targets/Microsoft.Sdk.R2R.targets

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2647,19 +2647,21 @@ global using nfloat = global::System.Runtime.InteropServices.NFloat%3B
_CollectR2RFrameworksForPostProcessing;
</_CollectItemsForPostProcessingDependsOn>
</PropertyGroup>
<Target Name="_CollectR2RFrameworksForPostProcessing" DependsOnTargets="_ComputeFrameworksToCreate">
<Target Name="_CollectR2RFrameworksForPostProcessing" DependsOnTargets="_ComputeFrameworksToCreate;_PrepareR2RModules">
<ItemGroup>
<!-- Add CoreCLR runtime -->
<_PostProcessingItem
Include="@(_CreatedFrameworksFromDylibs->'$([System.IO.Path]::GetFileName($(AppBundleDir)))/$(_AppFrameworksRelativePath)%(Filename).framework/%(Filename)')">
<Kind>Framework</Kind>
<FrameworkName>%(Filename)</FrameworkName>
<DSymName>%(Filename).framework.dSYM</DSymName>
</_PostProcessingItem>
<!-- Add R2R composite -->
<!-- Add per-module R2R frameworks -->
<_PostProcessingItem
Include="$([System.IO.Path]::GetFileName('$(AppBundleDir)'))/$(_AppFrameworksRelativePath)$(_R2RFrameworkName).framework/$(_R2RFrameworkName)" Condition="'$(CreateR2RFramework)' == 'true'">
Include="@(_R2RModule->'$([System.IO.Path]::GetFileName($(AppBundleDir)))/$(_AppFrameworksRelativePath)%(FrameworkName).framework/%(FrameworkName)')" Condition="'$(CreateR2RFramework)' == 'true'">
<Kind>Framework</Kind>
<DSymName>$(_R2RFrameworkName).framework.dSYM</DSymName>
<FrameworkName>%(FrameworkName)</FrameworkName>
<DSymName>%(FrameworkName).framework.dSYM</DSymName>
</_PostProcessingItem>
</ItemGroup>
</Target>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.IO;
using System.Text;

using Microsoft.Build.Framework;

#nullable enable

namespace Xamarin.MacDev.Tasks {
public class GenerateR2RModuleRegistration : XamarinTask {

#region Inputs
[Required]
public ITaskItem [] R2RModules { get; set; } = [];

[Required]
public string OutputFile { get; set; } = "";
#endregion

public override bool Execute ()
{
var sb = new StringBuilder ();

sb.AppendLine ("#include \"xamarin/xamarin.h\"");
sb.AppendLine ();

foreach (var module in R2RModules) {
var symbolName = module.GetMetadata ("SymbolName");
sb.AppendLine ($"extern void* {symbolName};");
}

sb.AppendLine ();
sb.AppendLine ("static struct xamarin_r2r_module r2r_module_entries [] = {");

foreach (var module in R2RModules) {
var moduleName = module.GetMetadata ("ModuleName");
var symbolName = module.GetMetadata ("SymbolName");
sb.AppendLine ($"\t{{ \"{moduleName}\", &{symbolName} }},");
}
Comment on lines +34 to +57
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This task writes out C/C++ code using MSBuild item metadata without validating or escaping it. If ModuleName or SymbolName metadata is missing/empty, the generated file will contain invalid declarations/initializers, and if ModuleName contains characters that need escaping in a C string literal (e.g. \ or "), the generated source will not compile. Consider validating required metadata for every item (and logging an MSBuild error when missing) and C-escaping moduleName before embedding it into the string literal.

Copilot uses AI. Check for mistakes.

sb.AppendLine ("};");
sb.AppendLine ();

sb.AppendLine ("__attribute__ ((constructor))");
sb.AppendLine ("static void xamarin_register_r2r_modules ()");
sb.AppendLine ("{");
sb.AppendLine ("\txamarin_r2r_modules = r2r_module_entries;");
sb.AppendLine ("\txamarin_r2r_module_count = sizeof (r2r_module_entries) / sizeof (r2r_module_entries [0]);");
sb.AppendLine ("}");

var content = sb.ToString ();
var outputDir = Path.GetDirectoryName (OutputFile);
if (!string.IsNullOrEmpty (outputDir))
Directory.CreateDirectory (outputDir);

if (!File.Exists (OutputFile) || File.ReadAllText (OutputFile) != content)
File.WriteAllText (OutputFile, content);

return !Log.HasLoggedErrors;
}
}
}
22 changes: 20 additions & 2 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
enum XamarinNativeLinkMode xamarin_libmono_native_link_mode = XamarinNativeLinkModeStaticObject;
const char **xamarin_runtime_libraries = NULL;
void *xamarin_rtr_header = NULL;
struct xamarin_r2r_module *xamarin_r2r_modules = NULL;
int xamarin_r2r_module_count = 0;

/* Callbacks */

Expand Down Expand Up @@ -2439,9 +2441,25 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
if (!context || !data || !context->assembly_path || !context->owner_composite_name)
return false;

void* r2r_header = xamarin_rtr_header;
void* r2r_header = NULL;

// Multi-module: look up by owner_composite_name
if (xamarin_r2r_modules != NULL && xamarin_r2r_module_count > 0) {
for (int i = 0; i < xamarin_r2r_module_count; i++) {
if (strcmp (xamarin_r2r_modules [i].name, context->owner_composite_name) == 0) {
r2r_header = xamarin_r2r_modules [i].header;
break;
}
}
if (r2r_header == NULL)
return false;
} else {
// Single-module fallback for backward compatibility
r2r_header = xamarin_rtr_header;
}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

When xamarin_r2r_modules is non-null, this returns false if no entry matches context->owner_composite_name, instead of falling back to the single-module xamarin_rtr_header as described in the PR. This makes the lookup brittle (any mismatch between owner_composite_name and the generated ModuleName causes R2R to be disabled) and also eliminates the intended backward-compat behavior. Consider falling back to xamarin_rtr_header (when non-NULL) if no module match is found, and/or emitting a diagnostic/assertion to aid troubleshooting.

Copilot uses AI. Check for mistakes.

if (r2r_header == NULL)
xamarin_assertion_message ("Failed to find the RTR_HEADER symbol.");
return false;

Dl_info info;
if (dladdr (r2r_header, &info) == 0)
Expand Down
8 changes: 8 additions & 0 deletions runtime/xamarin/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ extern enum XamarinNativeLinkMode xamarin_libmono_native_link_mode;
extern const char** xamarin_runtime_libraries;
extern void *xamarin_rtr_header;

struct xamarin_r2r_module {
const char *name;
void *header;
};

extern struct xamarin_r2r_module *xamarin_r2r_modules;
extern int xamarin_r2r_module_count;

typedef void (*xamarin_setup_callback) ();
typedef int (*xamarin_extension_main_callback) (int argc, char** argv);

Expand Down
26 changes: 13 additions & 13 deletions tests/dotnet/UnitTests/expected/iOS-CoreCLR-Interpreter-size.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
AppBundleSize: 9,269,302 bytes (9,052.1 KB = 8.8 MB)
AppBundleSize: 9,269,989 bytes (9,052.7 KB = 8.8 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 10,847 bytes (10.6 KB = 0.0 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Frameworks/libcoreclr.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libcoreclr.framework/Info.plist: 840 bytes (0.8 KB = 0.0 MB)
Frameworks/libcoreclr.framework/Info.plist: 833 bytes (0.8 KB = 0.0 MB)
Frameworks/libcoreclr.framework/libcoreclr: 5,220,544 bytes (5,098.2 KB = 5.0 MB)
Frameworks/libSystem.Globalization.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 882 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 109,232 bytes (106.7 KB = 0.1 MB)
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 875 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 109,248 bytes (106.7 KB = 0.1 MB)
Frameworks/libSystem.IO.Compression.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 884 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,431,280 bytes (1,397.7 KB = 1.4 MB)
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 877 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,431,296 bytes (1,397.8 KB = 1.4 MB)
Frameworks/libSystem.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/Info.plist: 854 bytes (0.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/libSystem.Native: 162,128 bytes (158.3 KB = 0.2 MB)
Frameworks/libSystem.Native.framework/Info.plist: 847 bytes (0.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/libSystem.Native: 162,144 bytes (158.3 KB = 0.2 MB)
Frameworks/libSystem.Net.Security.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 880 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,000 bytes (85.9 KB = 0.1 MB)
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 873 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,016 bytes (86.0 KB = 0.1 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 910 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 903 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/libSystem.Security.Cryptography.Native.Apple: 194,256 bytes (189.7 KB = 0.2 MB)
Info.plist: 1,168 bytes (1.1 KB = 0.0 MB)
Info.plist: 1,161 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 98,816 bytes (96.5 KB = 0.1 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,481 bytes (1.4 KB = 0.0 MB)
SizeTestApp: 195,856 bytes (191.3 KB = 0.2 MB)
SizeTestApp: 196,528 bytes (191.9 KB = 0.2 MB)
SizeTestApp.dll: 7,680 bytes (7.5 KB = 0.0 MB)
System.Collections.Immutable.dll: 14,848 bytes (14.5 KB = 0.0 MB)
System.Diagnostics.StackTrace.dll: 8,192 bytes (8.0 KB = 0.0 MB)
Expand Down
34 changes: 17 additions & 17 deletions tests/dotnet/UnitTests/expected/iOS-CoreCLR-R2R-size.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
AppBundleSize: 13,233,325 bytes (12,923.2 KB = 12.6 MB)
AppBundleSize: 13,234,078 bytes (12,923.9 KB = 12.6 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 11,701 bytes (11.4 KB = 0.0 MB)
_CodeSignature/CodeResources: 11,733 bytes (11.5 KB = 0.0 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Frameworks/libcoreclr.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libcoreclr.framework/Info.plist: 840 bytes (0.8 KB = 0.0 MB)
Frameworks/libcoreclr.framework/Info.plist: 833 bytes (0.8 KB = 0.0 MB)
Frameworks/libcoreclr.framework/libcoreclr: 5,220,544 bytes (5,098.2 KB = 5.0 MB)
Frameworks/libSystem.Globalization.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 882 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 109,232 bytes (106.7 KB = 0.1 MB)
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 875 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 109,248 bytes (106.7 KB = 0.1 MB)
Frameworks/libSystem.IO.Compression.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 884 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,431,280 bytes (1,397.7 KB = 1.4 MB)
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 877 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,431,296 bytes (1,397.8 KB = 1.4 MB)
Frameworks/libSystem.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/Info.plist: 854 bytes (0.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/libSystem.Native: 162,128 bytes (158.3 KB = 0.2 MB)
Frameworks/libSystem.Native.framework/Info.plist: 847 bytes (0.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/libSystem.Native: 162,144 bytes (158.3 KB = 0.2 MB)
Frameworks/libSystem.Net.Security.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 880 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,000 bytes (85.9 KB = 0.1 MB)
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 873 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,016 bytes (86.0 KB = 0.1 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 910 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 903 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/libSystem.Security.Cryptography.Native.Apple: 194,256 bytes (189.7 KB = 0.2 MB)
Frameworks/SizeTestApp.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/SizeTestApp.framework/Info.plist: 843 bytes (0.8 KB = 0.0 MB)
Frameworks/SizeTestApp.framework/SizeTestApp: 3,946,656 bytes (3,854.2 KB = 3.8 MB)
Info.plist: 1,168 bytes (1.1 KB = 0.0 MB)
Frameworks/SizeTestApp.r2r.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/SizeTestApp.r2r.framework/Info.plist: 845 bytes (0.8 KB = 0.0 MB)
Frameworks/SizeTestApp.r2r.framework/SizeTestApp.r2r: 3,946,656 bytes (3,854.2 KB = 3.8 MB)
Info.plist: 1,161 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 98,816 bytes (96.5 KB = 0.1 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,481 bytes (1.4 KB = 0.0 MB)
SizeTestApp: 195,904 bytes (191.3 KB = 0.2 MB)
SizeTestApp: 196,608 bytes (192.0 KB = 0.2 MB)
SizeTestApp.dll: 7,680 bytes (7.5 KB = 0.0 MB)
System.Collections.Immutable.dll: 13,824 bytes (13.5 KB = 0.0 MB)
System.Diagnostics.StackTrace.dll: 7,680 bytes (7.5 KB = 0.0 MB)
Expand Down
12 changes: 6 additions & 6 deletions tests/dotnet/UnitTests/expected/iOS-MonoVM-interpreter-size.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
AppBundleSize: 3,617,184 bytes (3,532.4 KB = 3.4 MB)
AppBundleSize: 3,622,195 bytes (3,537.3 KB = 3.5 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 3,997 bytes (3.9 KB = 0.0 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Info.plist: 1,134 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 153,088 bytes (149.5 KB = 0.1 MB)
Info.plist: 1,161 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 154,112 bytes (150.5 KB = 0.1 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,405 bytes (1.4 KB = 0.0 MB)
SizeTestApp: 2,391,264 bytes (2,335.2 KB = 2.3 MB)
SizeTestApp: 2,391,632 bytes (2,335.6 KB = 2.3 MB)
SizeTestApp.dll: 7,680 bytes (7.5 KB = 0.0 MB)
System.Private.CoreLib.aotdata.arm64: 41,392 bytes (40.4 KB = 0.0 MB)
System.Private.CoreLib.dll: 1,003,520 bytes (980.0 KB = 1.0 MB)
System.Private.CoreLib.aotdata.arm64: 41,400 bytes (40.4 KB = 0.0 MB)
System.Private.CoreLib.dll: 1,007,104 bytes (983.5 KB = 1.0 MB)
System.Runtime.dll: 5,120 bytes (5.0 KB = 0.0 MB)
System.Runtime.InteropServices.dll: 8,192 bytes (8.0 KB = 0.0 MB)
8 changes: 4 additions & 4 deletions tests/dotnet/UnitTests/expected/iOS-MonoVM-size.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
AppBundleSize: 9,458,846 bytes (9,237.2 KB = 9.0 MB)
AppBundleSize: 9,459,015 bytes (9,237.3 KB = 9.0 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 5,229 bytes (5.1 KB = 0.0 MB)
aot-instances.aotdata.arm64: 818,536 bytes (799.4 KB = 0.8 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Info.plist: 1,168 bytes (1.1 KB = 0.0 MB)
Info.plist: 1,161 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.aotdata.arm64: 22,888 bytes (22.4 KB = 0.0 MB)
Microsoft.iOS.dll: 49,152 bytes (48.0 KB = 0.0 MB)
Microsoft.iOS.dll: 48,640 bytes (47.5 KB = 0.0 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,481 bytes (1.4 KB = 0.0 MB)
SizeTestApp: 7,333,840 bytes (7,162.0 KB = 7.0 MB)
SizeTestApp: 7,334,528 bytes (7,162.6 KB = 7.0 MB)
SizeTestApp.aotdata.arm64: 1,456 bytes (1.4 KB = 0.0 MB)
SizeTestApp.dll: 7,168 bytes (7.0 KB = 0.0 MB)
System.Private.CoreLib.aotdata.arm64: 665,552 bytes (650.0 KB = 0.6 MB)
Expand Down
6 changes: 3 additions & 3 deletions tests/dotnet/UnitTests/expected/iOS-NativeAOT-size.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
AppBundleSize: 2,486,550 bytes (2,428.3 KB = 2.4 MB)
AppBundleSize: 2,486,702 bytes (2,428.4 KB = 2.4 MB)
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
_CodeSignature/CodeResources: 2,589 bytes (2.5 KB = 0.0 MB)
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
Info.plist: 1,169 bytes (1.1 KB = 0.0 MB)
Info.plist: 1,161 bytes (1.1 KB = 0.0 MB)
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
runtimeconfig.bin: 1,808 bytes (1.8 KB = 0.0 MB)
SizeTestApp: 2,480,592 bytes (2,422.5 KB = 2.4 MB)
SizeTestApp: 2,480,752 bytes (2,422.6 KB = 2.4 MB)
7 changes: 0 additions & 7 deletions tools/common/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,6 @@ void GenerateMainImpl (StringWriter sw, Abi abi)
sw.WriteLine ();
sw.WriteLine (assembly_externs);

if (app.PublishReadyToRun == true) {
sw.WriteLine ("extern void* RTR_HEADER;");
sw.WriteLine ();
}

sw.WriteLine ("void xamarin_register_modules_impl ()");
sw.WriteLine ("{");
sw.WriteLine (assembly_aot_modules);
Expand Down Expand Up @@ -440,8 +435,6 @@ void GenerateMainImpl (StringWriter sw, Abi abi)
sw.WriteLine ("\txamarin_runtime_configuration_name = {0};", string.IsNullOrEmpty (app.RuntimeConfigurationFile) ? "NULL" : $"\"{app.RuntimeConfigurationFile}\"");
if (app.Registrar == RegistrarMode.ManagedStatic)
sw.WriteLine ("\txamarin_set_is_managed_static_registrar (true);");
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

xamarin_rtr_header no longer appears to be assigned anywhere (Target.cs removed the generated xamarin_rtr_header = &RTR_HEADER;, and runtime/runtime.m only declares it). Since runtime/runtime.m still has a single-module fallback path that uses xamarin_rtr_header, this change can break any scenario where the module table isn't populated (or when building older single-module R2R outputs). Either keep setting xamarin_rtr_header for the single-module case, or ensure the generated registration file also populates xamarin_rtr_header appropriately for backward compatibility.

Suggested change
sw.WriteLine ("\txamarin_set_is_managed_static_registrar (true);");
sw.WriteLine ("\txamarin_set_is_managed_static_registrar (true);");
if (app.XamarinRuntime == XamarinRuntime.NativeAOT)
sw.WriteLine ("\txamarin_rtr_header = &RTR_HEADER;");

Copilot uses AI. Check for mistakes.
if (app.PublishReadyToRun == true)
sw.WriteLine ("\txamarin_rtr_header = &RTR_HEADER;");
sw.WriteLine ("}");
sw.WriteLine ();
sw.Write ("int main");
Expand Down
Loading