Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Option to keep assemblies that have only type forwarders referenced. - #12

Merged
marek-safar merged 1 commit into
dotnet:masterfrom
erozenfeld:KeepTypeForwarders
Feb 13, 2017
Merged

marek-safar merged 1 commit into
dotnet:masterfrom
erozenfeld:KeepTypeForwarders

Conversation

@erozenfeld

Copy link
Copy Markdown
Contributor

The linker had an optimization that removed assemblies that had only type forwarders referenced.
#2 broke that optimization by adding a line that
marked assembly.MainModule whenever a type forwarder was marked.

This change introduces a new switch -t that controls this optimization. The optimization is on
by default; if -t is specified, the optimization is disabled and assemblies with referenced type
forwarders are kept.

Additionally, this includes a change that marks all type forwarders in assemblies specified with -a.

@dnfclas

dnfclas commented Feb 2, 2017

Copy link
Copy Markdown

Hi @erozenfeld, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@erozenfeld

erozenfeld commented Feb 2, 2017 •

Copy link
Copy Markdown
Contributor Author

@akoeplinger

Copy link
Copy Markdown
Member

@mmitche it seems PR testing isn't working anymore for this PR (it did for e.g. #10), can you please check why?

@akoeplinger akoeplinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but I'm no authority on this codebase so I'll let the other guys chime in :)

Comment thread linker/Mono.Linker/Driver.cs Outdated
break;
case 't':
context.KeepTypeForwarderOnlyAssemblies = true;
break;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@spouliot

spouliot commented Feb 3, 2017

Copy link
Copy Markdown
Contributor

As I noted in #2 (comment) we can move this option to be specific to the code that XI ships. However I don't mind making it an option in the linker code itself.

// type forwarders from Delete assemblies
// thus try to resolve all the type references and see
// if some changed the scope. if yes change the action to Save
if (ResolveAllTypeReferences (assembly))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be just && instead of extra if

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.


MarkType (context, type);

if (assembly.MainModule.HasExportedTypes) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we not copy this block of code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that only the first part of the block is the same as in MarkStep. I'm happy to factor them into a method but I'm not sure where to put that method. MarkStep and ResolveFromAssemblyStep don't share a common base. Any suggestions?

continue;
var resolvedExportedType = exported.Resolve ();
var resolvedTypeAssembly = context.Resolve (resolvedExportedType.Scope);
context.Annotations.Push (resolvedTypeAssembly);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What do you need it for ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If a library assembly is specified as a root via -a, that means that anything in the library can be accessed. I think exported types should be included for consistency. For example, I may specify -a for an assembly because I believe anything in it can potentially be a target of a reflection. That should include exported types.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My question was why do you need to do context.Annotations.Push (resolvedTypeAssembly);

@mmitche

mmitche commented Feb 3, 2017

Copy link
Copy Markdown
Member

@akoeplinger It looks like it doesn't have permissions to update the mono/linker status again.

@mmitche

mmitche commented Feb 3, 2017

Copy link
Copy Markdown
Member

@dotnet-bot test this please

@akoeplinger

Copy link
Copy Markdown
Member

@mmitche hmm weird, I see dotnet-bot has write access:

image

@mmitche

mmitche commented Feb 3, 2017

Copy link
Copy Markdown
Member

It's not dotnet-bot doing to the update. It's the CI application. Someone revoked access.

Annotations.SetAction (assembly, AssemblyAction.Save);
if (!Context.KeepTypeForwarderOnlyAssemblies) {
ResolveAllTypeReferences (assembly);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the above lines in this round of review. There is no reason to resolve all type references if type forwarder-only assemblies are kept.

ResolveAllTypeReferences (assembly);
if (!Context.KeepTypeForwarderOnlyAssemblies) {
ResolveAllTypeReferences (assembly);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the above lines in this round of review. There is no reason to resolve all type references if type forwarder-only assemblies are kept.

@erozenfeld

Copy link
Copy Markdown
Contributor Author

@marek-safar @akoeplinger @spouliot I addressed code review feedback and made a couple of additional changes. PTAL

Comment thread linker/Mono.Linker/Driver.cs Outdated
LinkContext context = new LinkContext (pipeline);
context.CoreAction = AssemblyAction.Skip;
context.OutputDirectory = "output";
context.KeepTypeForwarderOnlyAssemblies = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to re-set default false value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this line.

continue;
var resolvedExportedType = exported.Resolve ();
var resolvedTypeAssembly = context.Resolve (resolvedExportedType.Scope);
context.Annotations.Push (resolvedTypeAssembly);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My question was why do you need to do context.Annotations.Push (resolvedTypeAssembly);

The linker had an optimization that removed assemblies that had only type forwarders referenced.
dotnet#2 broke that optimization by adding a line that
marked assembly.MainModule whenever a type forwarder was marked.

This change introduces a new switch -t that controls this optimization. The optimization is on
by default; if -t is specified, the optimization is disabled and assemblies with referenced type
forwarders are kept.

Additionally, this includes a change that marks all type forwarders in assemblies specified with -a.
@erozenfeld

Copy link
Copy Markdown
Contributor Author

I removed the calls to context.Annotations.Push (resolvedTypeAssembly); and context.Annotations.Pop (); they are indeed not needed.

@erozenfeld

Copy link
Copy Markdown
Contributor Author

@marek-safar I addressed your feedback, PTAL.

@erozenfeld

Copy link
Copy Markdown
Contributor Author

@mmitche @akoeplinger How can we sort out the CI application access issue?

@mmitche

mmitche commented Feb 9, 2017

Copy link
Copy Markdown
Member

Can you give me admin access to this repo temporarily so I can see the settings?

@mmitche

mmitche commented Feb 9, 2017

Copy link
Copy Markdown
Member

@dotnet-bot test this please

@marek-safar
marek-safar merged commit b118b30 into dotnet:master Feb 13, 2017
jtschuster added a commit to jtschuster/linker that referenced this pull request Jan 19, 2022
…aaecdb38a68e44

parent 3b9ffe6
author Jackson Schuster <[email protected]> 1642552996 -0800
committer Jackson Schuster <[email protected]> 1642552996 -0800

parent ea177be
author Jackson Schuster <[email protected]> 1642552698 -0800
committer Jackson Schuster <[email protected]> 1642552698 -0800

Add Function to parse xml and return a list of injected attributes

Finalize schema so all test xml is valid

Add restrictions on some attributes and change uses of "nothing" to
"none"

Remove schema reference in generated file expectation

Initial Schema work

Add restrictions on some attributes and change uses of "nothing" to
"none"

Adds a more restrictive schema for LinkAttributes and updates paths for
linux

Update docs to use 'none' instead of 'nothing'

remove schema from xml expectation file

remove namespace from xml schema location

# This is the commit message dotnet#12:

intial xml parsing
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.

6 participants