Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,14 @@ The product definition template (`.plist`) to be used when creating the product

Only applicable to macOS and Mac Catalyst apps.

## PublishReadyToRunComposite

Specifies whether ReadyToRun (R2R) compilation produces a single composite image containing all the assemblies, or one image per assembly.

Only composite ReadyToRun compilation is supported for iOS, tvOS and Mac Catalyst apps, because the ReadyToRun code is embedded in the app bundle as native Mach-O code, and the runtime only knows how to locate such code for a composite image. Setting this property to `false` will produce a build error; set [PublishReadyToRun](https://learn.microsoft.com/dotnet/core/deploying/ready-to-run) to `false` to turn off ReadyToRun compilation completely instead.
Comment thread
rolfbjarne marked this conversation as resolved.

Default: `true` (when `PublishReadyToRun` is `true`).

## RecommendedXcodeVersion

The version of Xcode recommended for use with this version of .NET for iOS, tvOS, macOS and Mac Catalyst.
Expand Down
12 changes: 12 additions & 0 deletions dotnet/targets/Microsoft.Sdk.R2R.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.ComputeInstructionSet" AssemblyFile="$(_TaskAssemblyName)" />
<UsingTask Runtime="$(_TaskRuntime)" TaskName="Xamarin.MacDev.Tasks.GenerateR2RModuleRegistration" AssemblyFile="$(_TaskAssemblyName)" />

<!--
Only composite ReadyToRun compilation is supported with the 'macho' container format: crossgen2
emits a Mach-O object file per assembly, but it doesn't emit the corresponding component assemblies,
and the runtime only knows how to locate platform-native ReadyToRun code for a composite image.
See https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/readytorun-platform-native-envelope.md
-->
<Target Name="_ValidateReadyToRunComposite"
Condition="'$(PublishReadyToRun)' == 'true' And '$(PublishReadyToRunContainerFormat)' == 'macho' And '$(PublishReadyToRunComposite)' != 'true' And '$(_CanOutputAppBundle)' == 'true'"
BeforeTargets="_PrepareForReadyToRunCompilation">
<Error Text="Setting 'PublishReadyToRunComposite' to '$(PublishReadyToRunComposite)' isn't supported for $(_PlatformName) projects, only composite ReadyToRun compilation is supported. Either remove the 'PublishReadyToRunComposite' property, or set 'PublishReadyToRun=false' to turn off ReadyToRun compilation completely." />
</Target>

<!-- Set per-module R2R header symbol names so each .o file exports a unique symbol directly,
avoiding the need for post-link symbol aliasing. -->
<Target Name="_SetR2RHeaderSymbolNames"
Expand Down
19 changes: 19 additions & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,25 @@ public void PublishSingleFile_IsNotSupported (ApplePlatform platform, string run
Assert.That (errors.Select (e => e.Message), Has.Some.Contains ("does not support publishing to a single file"), "Error message");
}

[Test]
[TestCase (ApplePlatform.iOS, "iossimulator-arm64")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-arm64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64")]
public void PublishReadyToRunComposite_False_IsNotSupported (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);

var project_path = GetProjectPath (project, platform: platform);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["PublishReadyToRunComposite"] = "false";
var rv = DotNet.AssertBuildFailure (project_path, properties);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
Assert.That (errors.Length, Is.EqualTo (1), "Error count");
Assert.That (errors [0].Message, Does.StartWith ("Setting 'PublishReadyToRunComposite' to 'false' isn't supported"), "Error message");
}

[Test]
[TestCase (ApplePlatform.iOS, "ios-arm64;iossimulator-x64")]
[TestCase (ApplePlatform.iOS, "ios-arm64;iossimulator-arm64")]
Expand Down
Loading