Skip to content

[XABT] Don't run _LinkAssembliesNoShrink when $(PublishTrimmed) = true. #9887

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

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Mar 6, 2025

Context: #9526

Today, we need to run either ILLink or _LinkAssembliesNoShrink, however they have different triggers:

These can get out of sync, particularly when using global properties, causing both to be run.

Update _LinkAssembliesNoShrink to trigger when $(PublishTrimmed) != true to ensure that we don't run it if ILLink is being run.

Comment on lines 1465 to +1467
<Target Name="_LinkAssembliesNoShrink"
DependsOnTargets="_LinkAssembliesNoShrinkInputs"
Condition="'$(AndroidLinkMode)' == 'None'"
Condition="'$(PublishTrimmed)' != 'true'"
Copy link
Member

Choose a reason for hiding this comment

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

I think this should work, based on the defaults:

<PublishTrimmed Condition=" '$(PublishTrimmed)' == '' and ('$(AndroidLinkMode)' == 'SdkOnly' or '$(AndroidLinkMode)' == 'Full') ">true</PublishTrimmed>
<PublishTrimmed Condition=" '$(PublishTrimmed)' == '' and '$(Configuration)' == 'Release' and '$(AndroidLinkMode)' != 'None' ">true</PublishTrimmed>
<AndroidLinkMode Condition=" '$(AndroidLinkMode)' == '' and '$(PublishTrimmed)' == 'true' ">SdkOnly</AndroidLinkMode>
<AndroidLinkMode Condition=" '$(AndroidLinkMode)' == '' ">None</AndroidLinkMode>

Is there an example error when this breaks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There isn't an error, it successfully runs _LinkAssembliesNoShrink after ILLink.

_LinkAssembliesNoShrink operates on the copies in obj\Release\net10.0-android\android\assets instead of obj\Release\net10.0-android\android-arm64\linked, so the work it performs is just ignored.

However it interferes with my attempts to scan for JLO types in a link step.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test which checks that the targets are skipped (or not) in the correct configurations?

@jonpryor
Copy link
Contributor

jonpryor commented Mar 7, 2025

Context: https://github.com/dotnet/android/issues/9526

Today, we need to run *either* `ILLink` or `_LinkAssembliesNoShrink`.
However, they have different triggers:

  - `ILLink`: [`$(PublishTrimmed)=true`][0]
  - `_LinkAssembliesNoShrink`: `$(AndroidLinkMode)=None`

These can get out of sync, particularly when using global properties,
causing both to be run.  

Update the `_LinkAssembliesNoShrink` target to trigger when
`$(PublishTrimmed)` != `true` to ensure that we don't run it if
`ILLink` is being run.

[0]: https://github.com/dotnet/runtime/blob/f63d96e434576ae81a105a7e52634a877058b978/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets#L92-L96

@jonpryor jonpryor merged commit 08911e7 into main Mar 7, 2025
58 checks passed
@jonpryor jonpryor deleted the dev/jpobst/no-shrink-publish-trimmed branch March 7, 2025 23:33
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants