1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-08 03:27:04 +09:00

[release/9.0-staging] [Apple mobile] Enable trimming on build machines to match ILLink features (#113466)

* [Apple mobile] Enable trimming on build machines to match ILLink features (#110966)

* Disable failing tests

* Add DataSetXmlSerializationIsSupported to PlatformDetection
This commit is contained in:
Milos Kotlar 2025-04-03 16:38:18 +02:00 committed by GitHub
parent 6303a6c11c
commit bbf23a28e6
Signed by: github
GPG key ID: B5690EEEBB952194
13 changed files with 29 additions and 52 deletions

View file

@ -37,10 +37,9 @@ jobs:
isExtraPlatforms: ${{ parameters.isExtraPlatformsBuild }}
# Don't trim tests on rolling builds
${{ if eq(variables['isRollingBuild'], true) }}:
buildArgs: -s mono+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true $(_runSmokeTestsOnlyArg) /p:BuildTestsOnHelix=true /p:EnableAdditionalTimezoneChecks=true /p:UsePortableRuntimePack=true /p:BuildDarwinFrameworks=true /p:IsManualOrRollingBuild=true /p:EnableAggressiveTrimming=false
buildArgs: -s mono+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true $(_runSmokeTestsOnlyArg) /p:BuildTestsOnHelix=true /p:EnableAdditionalTimezoneChecks=true /p:UsePortableRuntimePack=false /p:BuildDarwinFrameworks=true /p:IsManualOrRollingBuild=true /p:EnableAggressiveTrimming=false
${{ else }}:
# Tracking issue: https://github.com/dotnet/runtime/issues/82637
buildArgs: -s mono+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true $(_runSmokeTestsOnlyArg) /p:BuildTestsOnHelix=true /p:EnableAdditionalTimezoneChecks=true /p:UsePortableRuntimePack=true /p:BuildDarwinFrameworks=true /p:IsManualOrRollingBuild=true /p:EnableAggressiveTrimming=false
buildArgs: -s mono+libs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true $(_runSmokeTestsOnlyArg) /p:BuildTestsOnHelix=true /p:EnableAdditionalTimezoneChecks=true /p:UsePortableRuntimePack=false /p:BuildDarwinFrameworks=true /p:IsManualOrRollingBuild=true /p:EnableAggressiveTrimming=true
timeoutInMinutes: 480
# extra steps, run tests
postBuildSteps:

View file

@ -1010,8 +1010,7 @@ extends:
jobParameters:
testGroup: innerloop
nameSuffix: AllSubsets_Mono
# Tracking issue: https://github.com/dotnet/runtime/issues/82637
buildArgs: -s mono+libs+libs.tests+host+packs -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:RunSmokeTestsOnly=true /p:BuildTestsOnHelix=true /p:EnableAdditionalTimezoneChecks=true /p:UsePortableRuntimePack=true /p:BuildDarwinFrameworks=true /p:EnableAggressiveTrimming=false
buildArgs: -s mono+libs+libs.tests+host+packs -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=- /p:RunAOTCompilation=true /p:RunSmokeTestsOnly=true /p:BuildTestsOnHelix=true /p:EnableAdditionalTimezoneChecks=true /p:UsePortableRuntimePack=false /p:BuildDarwinFrameworks=true /p:EnableAggressiveTrimming=true
timeoutInMinutes: 480
condition: >-
or(

View file

@ -16,7 +16,7 @@
<!-- running aot-helix tests locally, so we can test with the same project file as CI -->
<_AOTBuildCommand Condition="'$(ContinuousIntegrationBuild)' != 'true'">$(_AOTBuildCommand) /p:RuntimeSrcDir=$(RepoRoot) /p:RuntimeConfig=$(Configuration)</_AOTBuildCommand>
<!-- The command below sets default properties for runtime and library tests -->
<_AOTBuildCommand>$(_AOTBuildCommand) /p:XHARNESS_EXECUTION_DIR=&quot;$XHARNESS_EXECUTION_DIR&quot; /p:RunAOTCompilation=$(RunAOTCompilation) /p:UseNativeAOTRuntime=$(UseNativeAOTRuntime) /p:TargetOS=$(TargetOS) /p:TargetArchitecture=$(TargetArchitecture) /p:MonoForceInterpreter=$(MonoForceInterpreter) /p:MonoEnableLLVM=true /p:DevTeamProvisioning=$(DevTeamProvisioning) /p:UsePortableRuntimePack=true /p:Configuration=$(Configuration) /p:EnableAggressiveTrimming=$(EnableAggressiveTrimming)</_AOTBuildCommand>
<_AOTBuildCommand>$(_AOTBuildCommand) /p:XHARNESS_EXECUTION_DIR=&quot;$XHARNESS_EXECUTION_DIR&quot; /p:RunAOTCompilation=$(RunAOTCompilation) /p:UseNativeAOTRuntime=$(UseNativeAOTRuntime) /p:TargetOS=$(TargetOS) /p:TargetArchitecture=$(TargetArchitecture) /p:MonoForceInterpreter=$(MonoForceInterpreter) /p:MonoEnableLLVM=true /p:DevTeamProvisioning=$(DevTeamProvisioning) /p:UsePortableRuntimePack=$(UsePortableRuntimePack) /p:Configuration=$(Configuration)</_AOTBuildCommand>
<_AOTBuildCommand Condition="'$(NativeLib)' != ''">$(_AOTBuildCommand) /p:NativeLib=$(NativeLib) /p:BundlesResources=$(BundlesResources) /p:ForceLibraryModeGenerateAppBundle=$(ForceLibraryModeGenerateAppBundle)</_AOTBuildCommand>
<_AOTBuildCommand>$(_AOTBuildCommand) </_AOTBuildCommand>
@ -77,8 +77,6 @@
<BundleFiles Include="$(MonoProjectRoot)\msbuild\apple\data\*" TargetDir="publish" />
<ExtraFiles Condition="'%(AppleAssembliesToBundle._IsNative)' == 'true'"
Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles\%(AppleAssembliesToBundle.RecursiveDir)" />
<ExtraFiles Condition="Exists(%(TrimmerRootDescriptor.Identity))"
Include="@(TrimmerRootDescriptor)" TargetDir="extraFiles" />
</ItemGroup>
<ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(HybridGlobalization)' == 'false'" >
@ -156,12 +154,6 @@
<_AppleItemsToPass Include="@(ReferenceExtraPathFiles->'%(FileName)%(Extension)')"
OriginalItemName__="AppleReferenceExtraPathFiles" />
<_AppleItemsToPass Include="@(RuntimeHostConfigurationOption)"
OriginalItemName__="_AppleUsedRuntimeHostConfigurationOption" />
<_AppleItemsToPass Include="@(TrimmerRootAssembly)"
OriginalItemName__="TrimmerRootAssembly" />
<!-- Example of passing items to the project
<_AppleItemsToPass Include="@(BundleFiles)" OriginalItemName__="BundleFiles" ConditionToUse__="'$(Foo)' != 'true'" />

View file

@ -24,20 +24,23 @@
<DotnetPgoToolPath>$([MSBuild]::NormalizePath('$(DotnetPgoToolDir)', 'dotnet-pgo'))</DotnetPgoToolPath>
</PropertyGroup>
<!-- When tests are built on Helix, we don't want to invoke ILLink on build machines -->
<PropertyGroup Condition="'$(EnableAggressiveTrimming)' == 'true' and '$(BuildTestsOnHelix)' != 'true'">
<!-- Invoke ILLink on build machines to match ILLink features -->
<PropertyGroup Condition="'$(EnableAggressiveTrimming)' == 'true'">
<PublishTrimmed>true</PublishTrimmed>
<!-- Suppress trimming warnings as these are tests -->
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
<NoWarn>$(NoWarn);IL2103;IL2025;IL2111;IL2122</NoWarn>
<!-- Reduce library test app size by trimming framework library features -->
<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(Configuration)' != 'Debug'">false</DebuggerSupport>
<EnableUnsafeUTF7Encoding Condition="'$(EnableUnsafeUTF7Encoding)' == ''">false</EnableUnsafeUTF7Encoding>
<EventSourceSupport Condition="'$(EventSourceSupport)' == ''">false</EventSourceSupport>
<HttpActivityPropagationSupport Condition="'$(HttpActivityPropagationSupport)' == ''">false</HttpActivityPropagationSupport>
<UseSystemResourceKeys Condition="'$(UseSystemResourceKeys)' == ''">false</UseSystemResourceKeys>
<UseNativeHttpHandler Condition="'$(UseNativeHttpHandler)' == ''">false</UseNativeHttpHandler>
</PropertyGroup>
<!-- Override default trimming switches for Apple mobile -->
<PropertyGroup Condition="'$(EnableAggressiveTrimming)' == 'true' and '$(TargetsAppleMobile)' == 'true'">
<DynamicCodeSupport Condition="'$(DynamicCodeSupport)' == '' and '$(MonoForceInterpreter)' != 'true'">false</DynamicCodeSupport>
<_DefaultValueAttributeSupport Condition="'$(OverrideDefaultValueAndDesignerHostSupport)' == 'true'">true</_DefaultValueAttributeSupport>
<_DesignerHostSupport Condition="'$(OverrideDefaultValueAndDesignerHostSupport)' == 'true'">true</_DesignerHostSupport>
</PropertyGroup>
<!-- When trimming non-exe projects, root the whole intermediate assembly.

View file

@ -288,6 +288,12 @@ namespace System
public static bool IsNotBuiltWithAggressiveTrimming => !IsBuiltWithAggressiveTrimming;
public static bool IsTrimmedWithILLink => IsBuiltWithAggressiveTrimming && !IsNativeAot;
#if NET
public static bool DataSetXmlSerializationIsSupported => AppContext.TryGetSwitch("System.Data.DataSet.XmlSerializationIsSupported", out bool isSupported) ? isSupported : true;
#else
public static bool DataSetXmlSerializationIsSupported => true;
#endif
// Windows - Schannel supports alpn from win8.1/2012 R2 and higher.
// Linux - OpenSsl supports alpn from openssl 1.0.2 and higher.
// Android - Platform supports alpn from API level 29 and higher

View file

@ -18,4 +18,7 @@
<ProjectReference Include="nonentrypointassembly\nonentrypointassembly.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsAppleMobile)' == 'true' and '$(EnableAggressiveTrimming)' == 'true' and '$(UseNativeAotRuntime)' != 'true'" >
<TrimmerRootAssembly Include="nonentrypointassembly" />
</ItemGroup>
</Project>

View file

@ -1,3 +0,0 @@
<linker>
<assembly fullname="TinyAssembly" />
</linker>

View file

@ -22,6 +22,5 @@
<Link>TinyAssembly.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<TrimmerRootDescriptor Condition="'$(TargetsAppleMobile)' == 'true' and '$(EnableAggressiveTrimming)' == 'true' and '$(UseNativeAotRuntime)' != 'true'" Include="$(MSBuildThisFileDirectory)ILLink.Descriptors.xml" />
</ItemGroup>
</Project>

View file

@ -19,7 +19,7 @@ namespace System.Runtime.Serialization.Xml.XsdDataContractExporterTests
_output = output;
}
[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.DataSetXmlSerializationIsSupported))]
public void TypesTest()
{
var types = new List<Type>()
@ -79,7 +79,7 @@ namespace System.Runtime.Serialization.Xml.XsdDataContractExporterTests
};
}
[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.DataSetXmlSerializationIsSupported))]
[SkipOnPlatform(TestPlatforms.Browser, "Inconsistent and unpredictable results.")] // TODO - Why does 'TypeWithReadWriteCollectionAndNoCtorOnCollection' only cause an exception sometimes, but not all the time? What's special about wasm here?
[ActiveIssue("https://github.com/dotnet/runtime/issues/82967", TestPlatforms.Wasi)]
[InlineData(typeof(NoDataContractWithoutParameterlessConstructor), typeof(InvalidDataContractException), @"Type 'System.Runtime.Serialization.Xml.XsdDataContractExporterTests.ExporterTypesTests+NoDataContractWithoutParameterlessConstructor' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.")]

View file

@ -9,11 +9,8 @@
<type fullname="System.Tests.EnumTests" />
<type fullname="System.Tests.ArrayTests" />
<type fullname="System.Reflection.Tests.InvokeRefReturnNetcoreTests" />
<type fullname="System.Reflection.Tests.InvokeRefReturnNetcoreTests+TestClass`1" />
<type fullname="System.Reflection.Tests.MethodBaseTests" />
<type fullname="System.Tests.Types.ModifiedTypeTests+ModifiedTypeHolder" />
<type fullname="System.Tests.ArrayTests" />
<type fullname="System.Tests.ArrayTests+GenericStruct`1" />
</assembly>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Array" />

View file

@ -348,6 +348,10 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj" />
<!-- Reference deleted by _CopyTestArchive https://github.com/dotnet/runtime/issues/80976 -->
<ProjectExclusions Include="$(RepoRoot)/src/tests/FunctionalTests/iOS/Simulator/StartupHook/iOS.Simulator.StartupHook.Test.csproj" />
<!-- Tracking issue: https://github.com/dotnet/runtime/issues/101692 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Formats.Tar/tests/System.Formats.Tar.Tests.csproj" />
<!-- Tracking issue: https://github.com/dotnet/runtime/issues/109282 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime/tests/System.IO.UnmanagedMemoryStream.Tests/System.IO.UnmanagedMemoryStream.Tests.csproj" />
<!-- Source generators tests. Not testing customer scenarios. Low priority -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.Extensions.Logging.Abstractions\tests\Microsoft.Extensions.Logging.Generators.Tests\Microsoft.Extensions.Logging.Generators.Roslyn3.11.Tests.csproj" />

View file

@ -7,7 +7,6 @@
<ExtraFilesPath>$([MSBuild]::NormalizeDirectory($(TestRootDir), '..', 'extraFiles'))</ExtraFilesPath>
<BaseIntermediateOutputPath>$([MSBuild]::NormalizeDirectory($(TestRootDir), '..', 'obj'))</BaseIntermediateOutputPath>
<AppleBuildDependsOn Condition="'$(EnableAggressiveTrimming)' == 'true' and '$(UseNativeAOTRuntime)' != 'true'">ConfigureTrimming;_AdjustTrimmedAssembliesToBundle;$(AppleBuildDependsOn)</AppleBuildDependsOn>
<AppleBuildDependsOn>_PublishRuntimePack;_PrepareForAppleBuildAppOnHelix;$(AppleBuildDependsOn);_AfterAppleBuildOnHelix</AppleBuildDependsOn>
<!-- Forced by ILLink targets -->
<SelfContained>true</SelfContained>
@ -71,7 +70,7 @@
<ItemGroup>
<!-- Figure out if we can support JustInterp mode -->
<AppleAssembliesToBundle Include="$(OriginalPublishDir)**\*.dll" Exclude="$(OriginalPublishDir)\**\*.resources.dll" />
<AppleAssembliesToBundle Include="$(OriginalPublishDir)\*.dll" Exclude="$(OriginalPublishDir)\*.resources.dll" />
<!-- Extra files are NativeLibraries and should be excluded from AppleAssembliesToBundle -->
<_ExtraFiles Include="$(ExtraFilesPath)**\*" />
@ -95,14 +94,6 @@
<RuntimeComponents Include="diagnostics_tracing" />
<RuntimeComponents Include="marshal-ilgen" />
</ItemGroup>
<ItemGroup Condition="'$(EnableAggressiveTrimming)' == 'true' and '$(UseNativeAOTRuntime)' != 'true'">
<TrimmerRootDescriptor Include="$(ExtraFilesPath)**\*.xml" />
<!-- To recreate the state of feature flags (RuntimeHostConfigurationOption) during app build-time we need to discard the default setting, coming from SDK, and used the values passed in ProxyProjectForAOTOnHelix.props -->
<RuntimeHostConfigurationOption Remove="@(_AppleUsedRuntimeHostConfigurationOption)" />
<RuntimeHostConfigurationOption Include="@(_AppleUsedRuntimeHostConfigurationOption)" />
</ItemGroup>
</Target>
<Target Name="_PublishRuntimePack"
@ -117,14 +108,6 @@
DestinationFolder="$(OriginalPublishDir)" />
</Target>
<!-- Since we are reusing the 'publish' folder for different purposes (e.g., using it as a source and destination directory for trimming) we need to adjust the list of assemblies to bundle once trimming is completed. -->
<Target Name="_AdjustTrimmedAssembliesToBundle" DependsOnTargets="ILLink;CopyFilesToPublishDirectory">
<ItemGroup>
<AppleAssembliesToBundle Remove="@(AppleAssembliesToBundle)" />
<AppleAssembliesToBundle Include="$(OriginalPublishDir)**\*.dll" Exclude="$(OriginalPublishDir)\**\*.resources.dll;@(_RemovedManagedAssembly)" />
</ItemGroup>
</Target>
<!-- Move the app to where the xharness runner expects it. -->
<Target Name="_AfterAppleBuildOnHelix">
<PropertyGroup>

View file

@ -19,11 +19,6 @@
<MonoForceInterpreter>false</MonoForceInterpreter>
</PropertyGroup>
<ItemGroup>
<!-- Preserves the UnmanagedCallersOnly method -->
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptors.xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
</ItemGroup>