Skip to content

Commit c004dde

Browse files
authored
[net11.0] Add CoreCLR and R2R framework to post-processing for symbol stripping (#24678)
## Description This PR adds CoreCLR and R2R frameworks to _PostProcessingItem for native stripping. There are two sets of items: CoreCLR frameworks and R2R composite framework. In a MAUI sample app, stripping frameworks reduced the device Release app bundle size from 77.82 MB to 41.62 MB. --------- Co-authored-by: Milos Kotlar <kotlarmilos@gmail.com>
1 parent 106b1b4 commit c004dde

4 files changed

Lines changed: 56 additions & 35 deletions

File tree

dotnet/targets/Xamarin.Shared.Sdk.targets

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,32 @@ global using nfloat = global::System.Runtime.InteropServices.NFloat%3B
25832583
</ItemGroup>
25842584
</Target>
25852585

2586+
<!--
2587+
Add CoreCLR/R2R framework to post-processing so they get stripped.
2588+
-->
2589+
<PropertyGroup>
2590+
<_CollectItemsForPostProcessingDependsOn>
2591+
$(_CollectItemsForPostProcessingDependsOn);
2592+
_CollectR2RFrameworksForPostProcessing;
2593+
</_CollectItemsForPostProcessingDependsOn>
2594+
</PropertyGroup>
2595+
<Target Name="_CollectR2RFrameworksForPostProcessing" DependsOnTargets="_ComputeFrameworksToCreate">
2596+
<ItemGroup>
2597+
<!-- Add CoreCLR runtime -->
2598+
<_PostProcessingItem
2599+
Include="@(_CreatedFrameworksFromDylibs->'$([System.IO.Path]::GetFileName($(AppBundleDir)))/$(_AppFrameworksRelativePath)%(Filename).framework/%(Filename)')">
2600+
<Kind>Framework</Kind>
2601+
<DSymName>%(Filename).framework.dSYM</DSymName>
2602+
</_PostProcessingItem>
2603+
<!-- Add R2R composite -->
2604+
<_PostProcessingItem
2605+
Include="$([System.IO.Path]::GetFileName('$(AppBundleDir)'))/$(_AppFrameworksRelativePath)$(_R2RFrameworkName).framework/$(_R2RFrameworkName)" Condition="'$(CreateR2RFramework)' == 'true'">
2606+
<Kind>Framework</Kind>
2607+
<DSymName>$(_R2RFrameworkName).framework.dSYM</DSymName>
2608+
</_PostProcessingItem>
2609+
</ItemGroup>
2610+
</Target>
2611+
25862612
<!-- Import existing targets -->
25872613

25882614
<PropertyGroup>

msbuild/Xamarin.Shared/Xamarin.Shared.targets

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2963,11 +2963,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
29632963
<BCSymbolMapName>%(Filename)%(Extension).bcsymbolmap</BCSymbolMapName>
29642964
</_PostProcessingItem>
29652965

2966-
<!-- Don't strip dylibs from the .NET runtime - they may contain symbols that can't be stripped (https://github.com/dotnet/runtime/issues/124570) -->
2967-
<_PostProcessingItem Condition="$([MSBuild]::ValueOrDefault('%(_PostProcessingItem.NuGetPackageId)', '').StartsWith('Microsoft.NETCore.App.Runtime'))">
2968-
<NoSymbolStrip>true</NoSymbolStrip>
2969-
</_PostProcessingItem>
2970-
29712966
<!-- Add any items from app extensions -->
29722967
<_PostProcessingAppExtensions Include="@(_AppExtensionPostProcessingItems)" Condition="'%(_AppExtensionPostProcessingItems.IsAppExtension)' == 'true' And '%(_AppExtensionPostProcessingItems.IsXPCService)' != 'true'" />
29732968
<_PostProcessingXpcServices Include="@(_AppExtensionPostProcessingItems)" Condition="'%(_AppExtensionPostProcessingItems.IsAppExtension)' == 'true' And '%(_AppExtensionPostProcessingItems.IsXPCService)' == 'true'" />

tests/dotnet/UnitTests/expected/iOS-CoreCLR-Interpreter-size.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
AppBundleSize: 10,718,502 bytes (10,467.3 KB = 10.2 MB)
1+
AppBundleSize: 9,240,684 bytes (9,024.1 KB = 8.8 MB)
22
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
33
_CodeSignature/CodeResources: 10,847 bytes (10.6 KB = 0.0 MB)
44
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
55
Frameworks/libcoreclr.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
6-
Frameworks/libcoreclr.framework/Info.plist: 840 bytes (0.8 KB = 0.0 MB)
7-
Frameworks/libcoreclr.framework/libcoreclr: 6,623,056 bytes (6,467.8 KB = 6.3 MB)
6+
Frameworks/libcoreclr.framework/Info.plist: 818 bytes (0.8 KB = 0.0 MB)
7+
Frameworks/libcoreclr.framework/libcoreclr: 5,204,000 bytes (5,082.0 KB = 5.0 MB)
88
Frameworks/libSystem.Globalization.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
9-
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 882 bytes (0.9 KB = 0.0 MB)
10-
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 110,064 bytes (107.5 KB = 0.1 MB)
9+
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 860 bytes (0.8 KB = 0.0 MB)
10+
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 109,248 bytes (106.7 KB = 0.1 MB)
1111
Frameworks/libSystem.IO.Compression.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
12-
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 884 bytes (0.9 KB = 0.0 MB)
13-
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,459,024 bytes (1,424.8 KB = 1.4 MB)
12+
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 862 bytes (0.8 KB = 0.0 MB)
13+
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,431,296 bytes (1,397.8 KB = 1.4 MB)
1414
Frameworks/libSystem.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
15-
Frameworks/libSystem.Native.framework/Info.plist: 854 bytes (0.8 KB = 0.0 MB)
16-
Frameworks/libSystem.Native.framework/libSystem.Native: 163,312 bytes (159.5 KB = 0.2 MB)
15+
Frameworks/libSystem.Native.framework/Info.plist: 832 bytes (0.8 KB = 0.0 MB)
16+
Frameworks/libSystem.Native.framework/libSystem.Native: 161,920 bytes (158.1 KB = 0.2 MB)
1717
Frameworks/libSystem.Net.Security.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
18-
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 880 bytes (0.9 KB = 0.0 MB)
19-
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,048 bytes (86.0 KB = 0.1 MB)
18+
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 858 bytes (0.8 KB = 0.0 MB)
19+
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,016 bytes (86.0 KB = 0.1 MB)
2020
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
21-
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 910 bytes (0.9 KB = 0.0 MB)
22-
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/libSystem.Security.Cryptography.Native.Apple: 222,896 bytes (217.7 KB = 0.2 MB)
23-
Info.plist: 1,168 bytes (1.1 KB = 0.0 MB)
21+
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 888 bytes (0.9 KB = 0.0 MB)
22+
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/libSystem.Security.Cryptography.Native.Apple: 194,256 bytes (189.7 KB = 0.2 MB)
23+
Info.plist: 1,146 bytes (1.1 KB = 0.0 MB)
2424
Microsoft.iOS.dll: 98,816 bytes (96.5 KB = 0.1 MB)
2525
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
2626
runtimeconfig.bin: 1,481 bytes (1.4 KB = 0.0 MB)

tests/dotnet/UnitTests/expected/iOS-CoreCLR-R2R-size.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
AppBundleSize: 15,304,461 bytes (14,945.8 KB = 14.6 MB)
1+
AppBundleSize: 13,826,109 bytes (13,502.1 KB = 13.2 MB)
22
# The following list of files and their sizes is just informational / for review, and isn't used in the test:
33
_CodeSignature/CodeResources: 11,701 bytes (11.4 KB = 0.0 MB)
44
archived-expanded-entitlements.xcent: 384 bytes (0.4 KB = 0.0 MB)
55
Frameworks/libcoreclr.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
6-
Frameworks/libcoreclr.framework/Info.plist: 840 bytes (0.8 KB = 0.0 MB)
7-
Frameworks/libcoreclr.framework/libcoreclr: 6,623,056 bytes (6,467.8 KB = 6.3 MB)
6+
Frameworks/libcoreclr.framework/Info.plist: 818 bytes (0.8 KB = 0.0 MB)
7+
Frameworks/libcoreclr.framework/libcoreclr: 5,204,000 bytes (5,082.0 KB = 5.0 MB)
88
Frameworks/libSystem.Globalization.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
9-
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 882 bytes (0.9 KB = 0.0 MB)
10-
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 110,064 bytes (107.5 KB = 0.1 MB)
9+
Frameworks/libSystem.Globalization.Native.framework/Info.plist: 860 bytes (0.8 KB = 0.0 MB)
10+
Frameworks/libSystem.Globalization.Native.framework/libSystem.Globalization.Native: 109,248 bytes (106.7 KB = 0.1 MB)
1111
Frameworks/libSystem.IO.Compression.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
12-
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 884 bytes (0.9 KB = 0.0 MB)
13-
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,459,024 bytes (1,424.8 KB = 1.4 MB)
12+
Frameworks/libSystem.IO.Compression.Native.framework/Info.plist: 862 bytes (0.8 KB = 0.0 MB)
13+
Frameworks/libSystem.IO.Compression.Native.framework/libSystem.IO.Compression.Native: 1,431,296 bytes (1,397.8 KB = 1.4 MB)
1414
Frameworks/libSystem.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
15-
Frameworks/libSystem.Native.framework/Info.plist: 854 bytes (0.8 KB = 0.0 MB)
16-
Frameworks/libSystem.Native.framework/libSystem.Native: 163,312 bytes (159.5 KB = 0.2 MB)
15+
Frameworks/libSystem.Native.framework/Info.plist: 832 bytes (0.8 KB = 0.0 MB)
16+
Frameworks/libSystem.Native.framework/libSystem.Native: 161,920 bytes (158.1 KB = 0.2 MB)
1717
Frameworks/libSystem.Net.Security.Native.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
18-
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 880 bytes (0.9 KB = 0.0 MB)
19-
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,048 bytes (86.0 KB = 0.1 MB)
18+
Frameworks/libSystem.Net.Security.Native.framework/Info.plist: 858 bytes (0.8 KB = 0.0 MB)
19+
Frameworks/libSystem.Net.Security.Native.framework/libSystem.Net.Security.Native: 88,016 bytes (86.0 KB = 0.1 MB)
2020
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
21-
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 910 bytes (0.9 KB = 0.0 MB)
22-
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/libSystem.Security.Cryptography.Native.Apple: 222,896 bytes (217.7 KB = 0.2 MB)
21+
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/Info.plist: 888 bytes (0.9 KB = 0.0 MB)
22+
Frameworks/libSystem.Security.Cryptography.Native.Apple.framework/libSystem.Security.Cryptography.Native.Apple: 194,256 bytes (189.7 KB = 0.2 MB)
2323
Frameworks/SizeTestApp.framework/_CodeSignature/CodeResources: 1,798 bytes (1.8 KB = 0.0 MB)
24-
Frameworks/SizeTestApp.framework/Info.plist: 843 bytes (0.8 KB = 0.0 MB)
24+
Frameworks/SizeTestApp.framework/Info.plist: 821 bytes (0.8 KB = 0.0 MB)
2525
Frameworks/SizeTestApp.framework/SizeTestApp: 3,913,744 bytes (3,822.0 KB = 3.7 MB)
26-
Info.plist: 1,168 bytes (1.1 KB = 0.0 MB)
27-
Microsoft.iOS.dll: 164,352 bytes (160.5 KB = 0.2 MB)
26+
Info.plist: 1,146 bytes (1.1 KB = 0.0 MB)
27+
Microsoft.iOS.dll: 163,840 bytes (160.0 KB = 0.2 MB)
2828
PkgInfo: 8 bytes (0.0 KB = 0.0 MB)
2929
runtimeconfig.bin: 1,481 bytes (1.4 KB = 0.0 MB)
3030
SizeTestApp: 196,432 bytes (191.8 KB = 0.2 MB)

0 commit comments

Comments
 (0)