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

[net10.0] [dotnet] Rework aggressive attribute trimming. Fixes #20906. #21314

Conversation

rolfbjarne
Copy link
Member

@rolfbjarne rolfbjarne commented Sep 26, 2024

The aggressive attribute trimming as exposed by ILLink is undocumented and has
problematic behavior, so disable it (it can't be statically validated) -
ILLink already removed support for it anyway.

However, this has a somewhat significant size increase for our apps, and it
would affect pretty much every app, so re-implement the aggressive attribute
trimming ourselves.

This is accomplished by copying ILLink's list of attributes to remove into our
own xml definition, which we then pass to ILLink.

I tested a release build of monotouch-test for all platforms, and the final
size is almost entirely unchanged, except for a minimal size decrease.

Here's the results for iOS: https://gist.github.com/rolfbjarne/dac3e08620a3ae499ad1fc134765e0d2

Fixes #20906.

@rolfbjarne

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Comment on lines +40 to +44
Note that removing this attribute can change runtime behavior. For example,
System.Xml.Serialization will behave differently if a ctor is Obsolete.
This is low enough risk on when 'ObjCRuntime.AggressiveAttributeTrimming' is enabled to justify
removing the attribute for size savings. The app developer can override this setting
to keep all ObsoleteAttributes.
Copy link
Member

Choose a reason for hiding this comment

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

Should we document this somewhere outside this file? /docs maybe? and maybe link it from build-properties.md entry you added

Copy link
Member Author

Choose a reason for hiding this comment

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

@dalexsoto I expanded a bit on this in the build-properties.md doc.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@rolfbjarne rolfbjarne added the do-not-merge Do not merge this pull request label Oct 1, 2024
@rolfbjarne rolfbjarne changed the base branch from net9.0 to main October 4, 2024 08:09
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review October 10, 2024 09:18
@rolfbjarne rolfbjarne changed the base branch from main to net10.0 October 10, 2024 09:19
The aggressive attribute trimming as exposed by ILLink is undocumented and has
problematic behavior, so disable it (it can't be statically validated) -
ILLink already removed support for it anyway.

However, this has a somewhat significant size increase for our apps, and it
would affect pretty much every app, so re-implement the aggressive attribute
trimming ourselves.

This is accomplished by copying ILLink's list of attributes to remove into our
own xml definition, which we then pass to ILLink.

I tested a release build of monotouch-test for all platforms, and the final
size is almost entirely unchanged, except for a minimal size decrease.

Here's the results for iOS: https://gist.github.com/rolfbjarne/dac3e08620a3ae499ad1fc134765e0d2

Fixes #20906.
@rolfbjarne rolfbjarne force-pushed the dev/rolf/issue-20906-disable-undocumented-attribute-trimming branch from 9f56935 to ec9c808 Compare October 10, 2024 09:20
@rolfbjarne rolfbjarne changed the title [dotnet] Rework aggressive attribute trimming. Fixes #20906. [net10.0] [dotnet] Rework aggressive attribute trimming. Fixes #20906. Oct 10, 2024
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET (No breaking changes)

✅ API diff vs stable

.NET (No breaking changes)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 7abc46143b71b2947bbf0c346555f771ef91fedf [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: 7abc46143b71b2947bbf0c346555f771ef91fedf [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: 7abc46143b71b2947bbf0c346555f771ef91fedf [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: 7abc46143b71b2947bbf0c346555f771ef91fedf [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: 7abc46143b71b2947bbf0c346555f771ef91fedf [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 101 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ generator: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ linker: All 40 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 7 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 10 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. [attempt 3] Html Report (VSDrops) Download
✅ monotouch (tvOS): All 7 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. [attempt 2] Html Report (VSDrops) Download

Pipeline on Agent
Hash: 7abc46143b71b2947bbf0c346555f771ef91fedf [PR build]

@rolfbjarne rolfbjarne merged commit b7a9096 into net10.0 Oct 15, 2024
21 checks passed
@rolfbjarne rolfbjarne deleted the dev/rolf/issue-20906-disable-undocumented-attribute-trimming branch October 15, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop using undocumented attribute trimming
3 participants