Skip to content
Open
340 changes: 160 additions & 180 deletions dotnet/targets/Microsoft.Sdk.R2R.targets

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2647,19 +2647,20 @@ 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>
<DSymName>%(_R2RModule.FrameworkName).framework.dSYM</DSymName>
</_PostProcessingItem>
</ItemGroup>
</Target>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

using Xamarin.Messaging.Build.Client;

#nullable enable

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

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

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

public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return ExecuteRemotely ();

var sb = new StringBuilder ();

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

foreach (var module in R2RModules) {
var symbolName = module.GetMetadata ("SymbolName");
if (string.IsNullOrEmpty (symbolName)) {
Log.LogError ("Missing '{0}' metadata on item '{1}'.", "SymbolName", module.ItemSpec);
continue;
}
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");
if (string.IsNullOrEmpty (moduleName)) {
Log.LogError ("Missing '{0}' metadata on item '{1}'.", "ModuleName", module.ItemSpec);
continue;
}
if (string.IsNullOrEmpty (symbolName))
continue; // already reported above
var escapedModuleName = moduleName.Replace ("\\", "\\\\").Replace ("\"", "\\\"");
sb.AppendLine ($"\t{{ \"{escapedModuleName}\", &{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 ("}");

if (Log.HasLoggedErrors)
return false;

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;
}

public bool ShouldCopyToBuildServer (ITaskItem item) => false;

public bool ShouldCreateOutputFile (ITaskItem item) => true;

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
}
}
15 changes: 12 additions & 3 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,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 +2440,17 @@ -(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;

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)
xamarin_assertion_message ("Failed to find the RTR_HEADER symbol.");
return false;

Dl_info info;
if (dladdr (r2r_header, &info) == 0)
Expand Down
9 changes: 8 additions & 1 deletion runtime/xamarin/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ extern bool xamarin_supports_dynamic_registration;
extern const char *xamarin_runtime_configuration_name;
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
28 changes: 14 additions & 14 deletions tests/dotnet/UnitTests/expected/iOS-CoreCLR-Interpreter-size.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
AppBundleSize: 9,269,302 bytes (9,052.1 KB = 8.8 MB)
AppBundleSize: 9,279,285 bytes (9,061.8 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,224 bytes (158.4 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)
System.IO.Compression.dll: 22,528 bytes (22.0 KB = 0.0 MB)
System.IO.MemoryMappedFiles.dll: 22,016 bytes (21.5 KB = 0.0 MB)
System.Private.CoreLib.dll: 1,566,208 bytes (1,529.5 KB = 1.5 MB)
System.Private.CoreLib.dll: 1,575,424 bytes (1,538.5 KB = 1.5 MB)
System.Reflection.Metadata.dll: 84,480 bytes (82.5 KB = 0.1 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)
36 changes: 18 additions & 18 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,259,253 bytes (12,948.5 KB = 12.6 MB)
AppBundleSize: 13,258,606 bytes (12,947.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: 841 bytes (0.8 KB = 0.0 MB)
Frameworks/libcoreclr.framework/Info.plist: 797 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: 883 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: 839 bytes (0.8 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: 885 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: 841 bytes (0.8 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: 855 bytes (0.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/libSystem.Native: 162,208 bytes (158.4 KB = 0.2 MB)
Frameworks/libSystem.Native.framework/Info.plist: 811 bytes (0.8 KB = 0.0 MB)
Frameworks/libSystem.Native.framework/libSystem.Native: 162,224 bytes (158.4 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: 881 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: 837 bytes (0.8 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: 911 bytes (0.9 KB = 0.0 MB)
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 867 bytes (0.8 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: 844 bytes (0.8 KB = 0.0 MB)
Frameworks/SizeTestApp.framework/SizeTestApp: 3,963,136 bytes (3,870.2 KB = 3.8 MB)
Info.plist: 1,169 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 98,816 bytes (96.5 KB = 0.1 MB)
Frameworks/SizeTestApp.r2r.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
Frameworks/SizeTestApp.r2r.framework/Info.plist: 809 bytes (0.8 KB = 0.0 MB)
Frameworks/SizeTestApp.r2r.framework/SizeTestApp.r2r: 3,963,184 bytes (3,870.3 KB = 3.8 MB)
Info.plist: 1,125 bytes (1.1 KB = 0.0 MB)
Microsoft.iOS.dll: 98,304 bytes (96.0 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: 196,048 bytes (191.5 KB = 0.2 MB)
SizeTestApp: 196,112 bytes (191.5 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,219 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,424 bytes (40.5 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)
10 changes: 5 additions & 5 deletions tests/dotnet/UnitTests/expected/iOS-MonoVM-size.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
AppBundleSize: 9,458,846 bytes (9,237.2 KB = 9.0 MB)
AppBundleSize: 9,458,975 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)
System.Private.CoreLib.aotdata.arm64: 665,512 bytes (649.9 KB = 0.6 MB)
System.Private.CoreLib.dll: 537,088 bytes (524.5 KB = 0.5 MB)
System.Runtime.aotdata.arm64: 784 bytes (0.8 KB = 0.0 MB)
System.Runtime.dll: 5,120 bytes (5.0 KB = 0.0 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