Skip to content

Commit aedcc0c

Browse files
authored
[msbuild/dotnet] Add support for 'MonoUseCompressedInterfaceBitmap' to enable compressed interface bitmaps. (#23834)
Add support for the `MonoUseCompressedInterfaceBitmap` MSBuild property to enable the usage of compressed interface bitmaps in Mono.
1 parent 526df6d commit aedcc0c

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

docs/building-apps/build-properties.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,28 @@ Consider using the unified [AppBundleResourcePrefix](#appbundleresourceprefix) p
683683

684684
See also [IPhoneResourcePrefix](#iphoneresourceprefix) and [XamMacResourcePrefix](#xammacresourceprefix).
685685

686+
## MonoUseCompressedInterfaceBitmap
687+
688+
This directs the Mono runtime to use a compressed version of interface bitmaps
689+
(interface bitmaps are used to determine whether a certain types implements a
690+
given interface).
691+
692+
These bitmaps can use a significant amount of memory at runtime, in particular
693+
for apps that have a substantial amount of interfaces.
694+
695+
This setting is disabled by default, but it can be enabled like this, which
696+
will decrease the amount of memory used at runtime:
697+
698+
```xml
699+
<PropertyGroup>
700+
<MonoUseCompressedInterfaceBitmap>true</MonoUseCompressedInterfaceBitmap>
701+
</PropertyGroup>
702+
```
703+
704+
The downside is that type checks (`obj is SomeInterface`) will be slower.
705+
706+
Only applicable when using the Mono runtime.
707+
686708
## MtouchDebug
687709

688710
Enables debug mode for app bundle creation.

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,10 +1380,15 @@
13801380
DependsOnTargets="$(_AOTCompileDependsOn)"
13811381
>
13821382

1383+
<ItemGroup>
1384+
<_AotEnvironment Condition="'$(MonoUseCompressedInterfaceBitmap)' == 'true'" Include="MONO_COMPRESSED_INTERFACE_BITMAP" Value="1" />
1385+
</ItemGroup>
1386+
13831387
<AOTCompile
13841388
SessionId="$(BuildSessionId)"
13851389
Condition="'$(IsMacEnabled)' == 'true'"
13861390
Assemblies="@(_AssembliesToAOT)"
1391+
AotEnvironment="@(_AotEnvironment)"
13871392
AOTCompilerPath="$(_XamarinAOTCompiler)"
13881393
InputDirectory="$(_AOTInputDirectory)"
13891394
MaxDegreeOfParallelism="$(AotCompileMaxDegreeOfParallelism)"

msbuild/Xamarin.MacDev.Tasks/Tasks/AOTCompile.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class AOTCompile : XamarinParallelTask, ITaskCallback, ICancelableTask {
2525
[Required]
2626
public ITaskItem [] Assemblies { get; set; } = Array.Empty<ITaskItem> ();
2727

28+
public ITaskItem [] AotEnvironment { get; set; } = Array.Empty<ITaskItem> ();
29+
2830
[Required]
2931
public string InputDirectory { get; set; } = string.Empty;
3032

@@ -334,8 +336,12 @@ public override bool Execute ()
334336
listOfArguments.Add (new (arguments, input));
335337
}
336338

339+
var environment = new Dictionary<string, string?> ();
340+
foreach (var item in AotEnvironment)
341+
environment [item.ItemSpec] = item.GetMetadata ("Value");
342+
337343
ForEach (listOfArguments, (arg) => {
338-
ExecuteAsync (AOTCompilerPath, arg.Arguments, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */)
344+
ExecuteAsync (AOTCompilerPath, arg.Arguments, environment: environment, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */)
339345
.ContinueWith ((v) => {
340346
if (v.Result.ExitCode != 0)
341347
Log.LogError (MSBStrings.E7118 /* Failed to AOT compile {0}, the AOT compiler exited with code {1} */, Path.GetFileName (arg.Input), v.Result.ExitCode);

msbuild/Xamarin.Shared/Xamarin.Shared.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,10 @@ Copyright (C) 2018 Microsoft. All rights reserved.
22002200
<MarshalObjectiveCExceptionMode Condition="'$(MarshalObjectiveCExceptionMode)' == ''">$(_MarshalObjectiveCExceptionMode)</MarshalObjectiveCExceptionMode>
22012201
</PropertyGroup>
22022202

2203+
<ItemGroup>
2204+
<_BundlerEnvironmentVariables Condition="'$(MonoUseCompressedInterfaceBitmap)' == 'true'" Include="MONO_COMPRESSED_INTERFACE_BITMAP" Value="1" />
2205+
</ItemGroup>
2206+
22032207
<ParseBundlerArguments
22042208
Aot="@(_AotArguments)"
22052209
ExtraArgs="$(AppBundleExtraOptions)"

0 commit comments

Comments
 (0)