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

Add star into link attributes #81407

Merged
merged 7 commits into from
Feb 10, 2023
Merged

Conversation

tlakollo
Copy link
Contributor

@tlakollo tlakollo commented Jan 31, 2023

One of the functionalities of the LinkAttributes files is to occurrences of custom attributes on the current assembly, on top of this functionality there is a special functionality that is only permitted if it's embedded in an XML inside the System.Private.CorLib module that allows the deletion of custom attributes from all the assemblies.
Given that NativeAOT is multithreaded it cannot process all the assemblies to remove attributes as ILLink does, it also does not have a shared storage in which it can store the information about the removed attributes from System.Private.CoreLib.
This PR adds logic to process the special functionality in the embedded System.Private.CoreLib XML every time an assembly is being processed.
In order to make this more performant, an extra argument is passed to the XML reader to only look at the assembly="*" to get the set of attributes that need to be deleted from all assemblies.

Fixes #77753

Tlakollo added 3 commits January 24, 2023 17:59
…for NativeAOT.

Add testing infrastructure from illink
…o actual testing of the AllAssembly functionality

Refactor some of the code
@ghost
Copy link

ghost commented Jan 31, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

One of the functionalities of the LinkAttributes files is to occurrences of custom attributes on the current assembly, on top of this functionality there is a special functionality that is only permitted if it's embedded in an XML inside the System.Private.CorLib module that allows the deletion of custom attributes from all the assemblies.
Given that NativeAOT is multithreaded it cannot process all the assemblies to remove attributes as ILLink does, it also does not have a shared storage in which it can store the information about the removed attributes from System.Private.CoreLib.
This PR adds logic to process the special functionality in the embedded System.Private.CoreLib XML every time an assembly is being processed.
In order to make this more performant, an extra argument is passed to the XML reader to only look at the assembly="*" to get the set of attributes that need to be deleted from all assemblies.

Author: tlakollo
Assignees: tlakollo
Labels:

area-NativeAOT-coreclr

Milestone: 8.0.0


public void ParseLinkAttributesXml(EcmaModule module, Logger logger, IReadOnlyDictionary<string, bool> featureSwitchValues, bool globalAttributeRemoval)
{
EcmaModule xmlModule = globalAttributeRemoval ? (EcmaModule) module.Context.SystemModule : module;
Copy link
Member

Choose a reason for hiding this comment

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

I rarely have to comment on formatting but the IL Linker formatting rules appearing where they shouldn't is starting to be a nuisance (this comment is not directly on your PR - I've commented on these in other PRs of people who work in both codebases in the past weeks, cc @vitek-karas).

There's an undeniable overhead in switching between styles. This is starting to be a friction point in PRs. Formatting never was a friction point. Honestly the linker coding style is creating a problem that I haven't seen in my 10 years on the team.

Suggested change
EcmaModule xmlModule = globalAttributeRemoval ? (EcmaModule) module.Context.SystemModule : module;
EcmaModule xmlModule = globalAttributeRemoval ? (EcmaModule)module.Context.SystemModule : module;

Copy link
Member

Choose a reason for hiding this comment

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

We should switch to linker in runtime repo real soon (hopefully this week). Once that is done I think the first thing we do on the linker is to update the formatting to match runtime rules. And then all of this will be history...

Copy link
Member

Choose a reason for hiding this comment

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

the first thing we do on the linker is to update the formatting to match runtime rules

Before doing that, it might be good to catch up parts of NativeAOT that are line-by-line ports of ILLink and delete ReferenceSource. Reformatting will introduce lots of diffs to ReferenceSource. It's not impossible to do the catchup later, but it will be an extra annoyance. Once it's all caught up, we don't need ReferenceSource anymore - we just have to be diligent in PRs to update both files always.

Apply feedback
Avoid using LogWarning in ReadyToRun
…k before that

reorg conditions to print warnings only if _globalAttributeRemoval is false
Move assembly to process check for non star members only
Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

Looks great!

@runfoapp runfoapp bot mentioned this pull request Feb 8, 2023
@tlakollo tlakollo merged commit 98514de into dotnet:main Feb 10, 2023
@tlakollo tlakollo deleted the AddStarIntoLinkAttributes branch February 10, 2023 19:12
@ghost ghost locked as resolved and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants