-
Notifications
You must be signed in to change notification settings - Fork 561
[tools] Add a new 'trimmable-static' registrar, that uses trimmable type maps. Fixes #23108. #25079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4102814
88cee67
ccd5a79
139a3b5
d6e09ac
b5272b7
327a382
7c709ab
e758700
e247d72
483d8ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -94,7 +94,7 @@ | |||||
| <ProjectCapability Include="MacCatalystBinding" Condition="'$(_ProjectType)' == 'MacCatalystBindingProject'" /> | ||||||
| <ProjectCapability Include="MacCatalystClassLibrary" Condition="'$(_ProjectType)' == 'MacCatalystClassLibrary'" /> | ||||||
|
|
||||||
| <ProjectCapability Condition="'$(_KeepLaunchProfiles)' != 'true'" Remove="LaunchProfiles" /> | ||||||
| <ProjectCapability Condition="'$(_KeepLaunchProfiles)' != 'true' And '$(_PlatformName)' != 'macOS'" Remove="LaunchProfiles" /> | ||||||
| </ItemGroup> | ||||||
|
|
||||||
| <!-- Default item includes (globs and implicit references) --> | ||||||
|
|
@@ -541,7 +541,10 @@ | |||||
| <!-- Validate the linker mode --> | ||||||
| <Error Text="Invalid link mode: '$(_LinkMode)'. Valid link modes are: 'None', 'SdkOnly' and 'Full'" Condition="'$(_LinkMode)' != 'None' And '$(_LinkMode)' != 'SdkOnly' And '$(_LinkMode)' != 'Full' And '$(_LinkMode)' != 'TrimMode'" /> | ||||||
|
|
||||||
| <Error Text="The only valid registrar when using NativeAOT is 'managed-static' (current value: '$(Registrar)'). Please either delete the 'Registrar' property, or change it to be 'managed-static'." Condition="'$(_UseNativeAot)' == 'true' And '$(Registrar)' != '' And '$(Registrar)' != 'managed-static'" /> | ||||||
| <Error | ||||||
| Text="The only valid registrars when using NativeAOT are 'managed-static' or 'trimmable-static' (current value: '$(Registrar)'). Please either delete the 'Registrar' property, or change it to be 'managed-static' or 'trimmable-static'." | ||||||
| Condition="'$(_UseNativeAot)' == 'true' And '$(Registrar)' != '' And '$(Registrar)' != 'managed-static' And '$(Registrar)' != 'trimmable-static'" | ||||||
| /> | ||||||
|
|
||||||
| <Warning Text="All assemblies must be processed by the linker when using NativeAOT. Please don't set neither the '$(_LinkModeProperty)' nor the 'TrimMode' property, so that the build can default to linking all assemblies." Condition="'$(_UseNativeAot)' == 'true' And '$(_LinkMode)' != 'Full'" /> | ||||||
|
|
||||||
|
|
@@ -584,6 +587,10 @@ | |||||
| <_IsManagedStaticRegistrarFeature Condition="'$(Registrar)' == 'managed-static'">true</_IsManagedStaticRegistrarFeature> | ||||||
| <_IsManagedStaticRegistrarFeature Condition="'$(Registrar)' != 'managed-static'">false</_IsManagedStaticRegistrarFeature> | ||||||
|
|
||||||
| <!-- Set managed static registrar value --> | ||||||
| <_IsTrimmableStaticRegistrarFeature Condition="'$(Registrar)' == 'trimmable-static'">true</_IsTrimmableStaticRegistrarFeature> | ||||||
| <_IsTrimmableStaticRegistrarFeature Condition="'$(Registrar)' != 'trimmable-static'">false</_IsTrimmableStaticRegistrarFeature> | ||||||
|
|
||||||
| <!-- Set NativeAOT value --> | ||||||
| <_IsNativeAOTFeature Condition="'$(_XamarinRuntime)' == 'NativeAOT'">true</_IsNativeAOTFeature> | ||||||
| <_IsNativeAOTFeature Condition="'$(_XamarinRuntime)' != 'NativeAOT'">false</_IsNativeAOTFeature> | ||||||
|
|
@@ -643,6 +650,8 @@ | |||||
| SkipMarkingNSObjectsInUserAssemblies=$(_SkipMarkingNSObjectsInUserAssemblies) | ||||||
| TargetArchitectures=$(TargetArchitectures) | ||||||
| TargetFramework=$(_ComputedTargetFrameworkMoniker) | ||||||
| TypeMapAssemblyName=$(_TypeMapAssemblyName) | ||||||
| TypeMapOutputDirectory=$(_TypeMapOutputDirectory) | ||||||
| UseLlvm=$(MtouchUseLlvm) | ||||||
| Verbosity=$(_BundlerVerbosity) | ||||||
| Warn=$(_BundlerWarn) | ||||||
|
|
@@ -725,6 +734,7 @@ | |||||
| <RuntimeHostConfigurationOption Include="ObjCRUntime.AggressiveAttributeTrimmingOnlyWithStaticRegistrar" value="true" Trim="true" Condition="'$(MobileAggressiveAttributeTrimming)' == 'true' And ('$(Registrar)' == 'static' Or '$(Registrar)' == 'managed-static')" /> | ||||||
| <RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.Arch.IsSimulator" Value="$(_IsSimulatorFeature)" Trim="true" /> | ||||||
| <RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.IsManagedStaticRegistrar" Value="$(_IsManagedStaticRegistrarFeature)" Trim="true" /> | ||||||
| <RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.IsTrimmableStaticRegistrar" Value="$(_IsTrimmableStaticRegistrarFeature)" Trim="true" /> | ||||||
| <RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.IsNativeAOT" Value="$(_IsNativeAOTFeature)" Trim="true" /> | ||||||
| <RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.IsCoreCLR" Value="true" Trim="true" Condition="'$(UseMonoRuntime)' != 'true'" /> | ||||||
| <RuntimeHostConfigurationOption Include="ObjCRuntime.Runtime.IsCoreCLR" Value="false" Trim="true" Condition="'$(UseMonoRuntime)' == 'true'" /> | ||||||
|
|
@@ -758,7 +768,8 @@ | |||||
| <_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)" BeforeStep="MarkStep" Type="MonoTouch.Tuner.RegistrarRemovalTrackingStep" /> | ||||||
| <!-- TODO: these steps should probably run after mark. --> | ||||||
| <_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)" BeforeStep="MarkStep" Condition="'$(_AreAnyAssembliesTrimmed)' == 'true'" Type="Xamarin.Linker.Steps.PreMarkDispatcher" /> | ||||||
| <_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)" BeforeStep="MarkStep" Type="Xamarin.Linker.ManagedRegistrarStep" Condition="'$(Registrar)' == 'managed-static'" /> | ||||||
| <_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)" BeforeStep="MarkStep" Type="Xamarin.Linker.ManagedRegistrarStep" Condition="'$(Registrar)' == 'managed-static' Or '$(Registrar)' == 'trimmable-static'" /> | ||||||
| <_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)" BeforeStep="MarkStep" Type="Xamarin.Linker.TrimmableRegistrarStep" Condition="'$(Registrar)' == 'trimmable-static'" /> | ||||||
|
|
||||||
| <!-- | ||||||
| IMarkHandlers which run during Mark | ||||||
|
|
@@ -1107,6 +1118,17 @@ | |||||
| <_FrameworkToPublish Include="@(_AllLinkerItems)" Condition="'%(_AllLinkerItems.SourceFile)' == '_FrameworkToPublish.items'" /> | ||||||
| <_DynamicLibraryToPublish Include="@(_AllLinkerItems)" Condition="'%(_AllLinkerItems.SourceFile)' == '_DynamicLibraryToPublish.items'" /> | ||||||
| </ItemGroup> | ||||||
|
|
||||||
| <ItemGroup Condition="'$(Registrar)' == 'trimmable-static'"> | ||||||
| <_TypeMapAssemblies Include="$(_TypeMapOutputDirectory)/*.dll" /> | ||||||
| <ResolvedFileToPublish Include="@(_TypeMapAssemblies)"> | ||||||
| <PublishFolderType>Assembly</PublishFolderType> | ||||||
| <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> | ||||||
| <RelativePath>$(_AssemblyPublishDir)%(Filename)%(Extension)</RelativePath> | ||||||
| <OriginalRelativePath>%(Filename)%(Extension)</OriginalRelativePath> | ||||||
| </ResolvedFileToPublish> | ||||||
| <FileWrites Include="@(_TypeMapAssemblies)" /> | ||||||
| </ItemGroup> | ||||||
| </Target> | ||||||
|
|
||||||
| <!-- Native code --> | ||||||
|
|
@@ -1260,6 +1282,14 @@ | |||||
| <_RuntimeConfigurationFile>runtimeconfig.bin</_RuntimeConfigurationFile> | ||||||
| </PropertyGroup> | ||||||
|
|
||||||
| <PropertyGroup Condition="'$(Registrar)' == 'trimmable-static'"> | ||||||
| <_TypeMapAssemblyName Condition="'$(_TypeMapAssemblyName)' == ''">_Microsoft.$(_PlatformName).TypeMaps</_TypeMapAssemblyName> | ||||||
| <_TypeMapOutputDirectory Condition="'$(_TypeMapOutputDirectory)' == ''">$(DeviceSpecificIntermediateOutputPath)typemap\</_TypeMapOutputDirectory> | ||||||
| </PropertyGroup> | ||||||
| <ItemGroup Condition="'$(Registrar)' == 'trimmable-static'"> | ||||||
| <RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.TypeMappingEntryAssembly" Value="$(_TypeMapAssemblyName)" Link="true" /> | ||||||
|
||||||
| <RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.TypeMappingEntryAssembly" Value="$(_TypeMapAssemblyName)" Link="true" /> | |
| <RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.TypeMappingEntryAssembly" Value="$(_TypeMapAssemblyName)" Trim="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ObjCRuntime.AggressiveAttributeTrimmingOnlyWithStaticRegistraris conditioned on Registrar beingstaticormanaged-static, but the newtrimmable-staticregistrar is also a static registrar mode. If this feature gate is intended to apply to all static registrar modes, please includetrimmable-staticin the condition as well so behavior stays consistent.