Skip to content
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

[iOS][tvOS] Fix building runtime tests on iOS-like platforms #91542

Conversation

simonrozsival
Copy link
Member

@simonrozsival simonrozsival commented Sep 4, 2023

Closes #91535

@simonrozsival simonrozsival added the NO-REVIEW Experimental/testing PR, do NOT review it label Sep 4, 2023
@ghost ghost assigned simonrozsival Sep 4, 2023
@ghost
Copy link

ghost commented Sep 4, 2023

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

Issue Details

Work in progress.

Author: simonrozsival
Assignees: simonrozsival
Labels:

NO-REVIEW, area-Infrastructure-coreclr

Milestone: -

@simonrozsival
Copy link
Member Author

/azp run runtime-ioslike

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vitek-karas
Copy link
Member

@sbomer please review this (once it's ready).

@@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<EnableDefaultItems>true</EnableDefaultItems>
<IsRoslynComponent>true</IsRoslynComponent>
<PublishTrimmed>false</PublishTrimmed>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that PublishTrimmed behavior is really only defined for applications, would it instead make sense to modify

<PublishTrimmed>true</PublishTrimmed>
to only enable trimming for executables?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a better way of solving the problem. I'm not very familiar with this part of the build process though so I'm not sure what the implications of that would be. cc @mdh1418

Copy link
Member

@kotlarmilos kotlarmilos Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property PublishTrimmed set by default for the runtime tests may improve AOT compilation time by excluding unnecessary assemblies. However, according to the comment below it is not intended behavior.

PublishTrimmed is expected to be set on per-project basis, not globally for entire subtrees.

If we want to set the PublishTrimmed on per-project basis and avoid additional complexity in the MergedRunner , we can remove these props without side effects. I don't expect significant performance changes as AOT Interp mode is used, which compiles the corelib only.

<PropertyGroup Condition="'$(TargetOS)' == 'ios' Or '$(TargetOS)' == 'tvos'">
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>
<PublishTrimmed>true</PublishTrimmed>
<SkipTestUtilitiesReference>true</SkipTestUtilitiesReference>
</PropertyGroup>

Other option is to set these props for executables only, as @vitek-karas suggested.

Note: The XUnitWrapperGenerator project may become obsolete soon, as Xunit wrappers are not used for the Mono runtime tests targeting apple mobile platforms due to parallel AOT compilation on Helix. We plan to do the same for the Native AOT runtime tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PublishTrimmed is expected to be set on per-project basis, not globally for entire subtrees.

That comment was meant in the context of the SDK - as in "The scenario SDK should focus on is when the property is set on per-project basis". Runtime repo is all kinds of special, so I would not necessarily apply it here.

That said - it should be set only for applications - it makes little sense for libraries.
For libraries you should instead set IsTrimmable=true but it has the same limitations (won't work on netstandard2.0 and you will get a similar error there as well).

Copy link
Member

@kotlarmilos kotlarmilos Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonrozsival You may change the property group condition below to include Condition="'$(TargetsAppleMobile)' == 'true' and '$([System.String]::Copy($(OutputType)).ToLower())' == 'exe'".

<PropertyGroup Condition="'$(TargetOS)' == 'ios' Or '$(TargetOS)' == 'tvos'">

I am not sure if there is a cleaner way for OutputType=Exe.

@simonrozsival
Copy link
Member Author

simonrozsival commented Sep 5, 2023

@sbomer even with the change in this PR, the iOS tests build still fail slightly further down the line with an error that I think was caused by the changes in #91233:

Common/mergedrunner.targets#L18
src/tests/Common/mergedrunner.targets(18,5): error : This project has an assembly name identical to another project, if this CoreCLRTestLibrary, you should reference $(TestLibraryProjectPath) instead of constructing the path yourself: /Users/runner/work/1/s/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj

I'm not sure how to fix that, do you have any suggestions?

@simonrozsival
Copy link
Member Author

/azp run runtime-ioslike

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kotlarmilos
Copy link
Member

@simonrozsival You fixed the CI! Let's resolve the comment above and it should be ready for review.

@sbomer
Copy link
Member

sbomer commented Sep 5, 2023

@simonrozsival I think that check is supposed to validate that multiple merged test runners don't produce the same output assemblies. ILLink.Tasks isn't an output assembly - it's only referenced for the purposes of build ordering. I would try adjusting this check to only include ProjectReferences that have '%(ProjectReference.ReferenceOutputAssembly) != 'false'`:

<_ProjectAssemblyReferences Include="@(ProjectReference)" Condition="'%(ProjectReference.OutputItemType)' == ''" />

cc @ViktorHofer @jkoritzinsky

@simonrozsival
Copy link
Member Author

/azp run runtime-ioslike

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simonrozsival simonrozsival changed the title [WIP] Do not trim XUnitWrapperGenerator [WIP] Fix building runtime tests on iOS-like platforms Sep 6, 2023
@ViktorHofer
Copy link
Member

Thanks for fixing.

@simonrozsival simonrozsival changed the title [WIP] Fix building runtime tests on iOS-like platforms [iOS][tvOS] Fix building runtime tests on iOS-like platforms Sep 6, 2023
@simonrozsival simonrozsival marked this pull request as ready for review September 6, 2023 09:50
@simonrozsival
Copy link
Member Author

@sbomer thanks for the suggestion!

The runtime tests now build correctly and the test failures all seem unrelated.

@simonrozsival simonrozsival removed the NO-REVIEW Experimental/testing PR, do NOT review it label Sep 6, 2023
@simonrozsival simonrozsival merged commit 54d9fa8 into dotnet:main Sep 7, 2023
106 of 110 checks passed
@simonrozsival simonrozsival deleted the disable-trimming-for-xunit-wrapper-generator branch September 7, 2023 07:46
@ghost ghost locked as resolved and limited conversation to collaborators Oct 7, 2023
@akoeplinger
Copy link
Member

/backport to release/8.0-staging

Copy link
Contributor

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/7531913098

@github-actions github-actions bot unlocked this conversation Jan 15, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS][tvOS] Building tests fails with "Trimming assemblies requires .NET Core 3.0 or higher"
6 participants