Skip to content

Add SkipLocalsInitAttribute#454

Merged
jkotas merged 5 commits into
masterfrom
add-skiplocalsinitattribute
Dec 15, 2019
Merged

Add SkipLocalsInitAttribute#454
jkotas merged 5 commits into
masterfrom
add-skiplocalsinitattribute

Conversation

@agocke

@agocke agocke commented Dec 2, 2019

Copy link
Copy Markdown
Member

This attribute supports a new compiler feature that allows a user to
specify that they don't want to emit the CLR .locals init portion of
the header in methods. This can sometimes produce a performance
improvement but, in some cases, can reveal uninitialized memory to the
application.

Ported from dotnet/coreclr#20093

This attribute supports a new compiler feature that allows a user to
specify that they don't want to emit the CLR `.locals init` portion of
the header in methods. This can sometimes produce a performance
improvement but, in some cases, can reveal uninitialized memory to the
application.

Ported from dotnet/coreclr#20093

@stephentoub stephentoub 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.

Thanks, @agocke.

@jkotas

jkotas commented Dec 2, 2019

Copy link
Copy Markdown
Member

Nit: For future PRs, we prefer creating the branch in fork: https://github.com/dotnet/runtime/blob/master/docs/issues-pr-management.md#what-will-be-dotnetruntimes-branch-policy

@agocke

agocke commented Dec 2, 2019

Copy link
Copy Markdown
Member Author

yeah, sorry, that was my mistake in cloning the repo, future PRs will be in my fork.

@tannergooding

Copy link
Copy Markdown
Member

CC. @TIHan, @cartermp for F# (in case you want to start respecting the attribute as well 😄)

public object WrappedException { get { throw null; } }
public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event, Inherited = false)]

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.

These should be fully qualified, e.g. System.AttributeUsage and System.AttributeTargets.Module. The class should also be partial.

I believe that generating the System.Runtime reference assembly is still a manual process for the most part (CC. @safern), but its still good to avoid the conflicts for when someone does auto-generate it later.

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.

For System.Runtime you can add --follow-typeforwards parameter to the GenAPI call in the target that we have in order to generate the reference assembly.

Basically just append it here:

<Exec Command="$(_GenAPICmd)" />

Then you can call dotnet msbuild /t:GenerateReferenceSource in the System.Runtime src project and it should update ref/System.Runtime.cs.

System.Runtime.cs has a lot of manual updates so there might be some other stuff changed that you'll need to ignore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried this, and the build failed with

C:\Users\angocke\code\runtime\src\libraries\Directory.Build.targets(151,5): error MSB3073: The command " "C:\Users\angocke\code\runtime\artifacts\obj\System.Reflection.TestModule\netstandard2.0-Debug\System.Reflection.TestModule.dll" --lib-path "C:\Users\angocke\code\runtime\artifacts\bin\ref\netstandard2.0" --out "C:\Users\angocke\code\runtime\src\libraries\System.Runtime\tests\ref\System.Reflection.TestModule.cs" --exclude-attributes-list "C:\Users\angocke\code\runtime\eng\DefaultGenApiDocIds.txt" --header-file "C:\Users\angocke\code\runtime\eng\LicenseHeader.txt" --lang-version "latest" --follow-type-forwards" exited with code 3. [C:\Users\angocke\code\runtime\src\libraries\System.Runtime\tests\TestModule\System.Reflection.TestModule.ilproj]

The system cannot find the path specified.

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.

It seems like you ran it against the solution file. Try running it under the project src directory directly so that it runs on the src csproj only.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK, did that, and no errors, but it basically just deleted most of the System.Runtime.cs file.

@agocke agocke Dec 5, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Also, will this fix the "seed assembly" problem I mentioned below?

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.

OK, did that, and no errors, but it basically just deleted most of the System.Runtime.cs file.

Hmm weird. Did you build against a locally built System.Private.CoreLib? Could you paste the command that it generated when invoking GenAPI? You can get it via a binlog.

Also, will this fix the "seed assembly" problem I mentioned below?

That is a GenFacades issue. @ericstj or @Anipik would be able to help you best.

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.

Also, will this fix the "seed assembly" problem I mentioned below?

Probably it is because you didn't built against an updated S.P.CoreLib which contains your new type.

@agocke

agocke commented Dec 5, 2019

Copy link
Copy Markdown
Member Author

I'm getting the error:

##[error].packages\microsoft.dotnet.genfacades\5.0.0-beta.19577.4\build\Microsoft.DotNet.GenPartialFacadeSource.targets(30,5): error : Did not find type 'System.Runtime.CompilerServices.SkipLocalsInitAttribute' in any of the seed assemblies.

What's a seed assembly?

@agocke

agocke commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

@ericstj Any idea what I'm doing wrong here?

@safern

safern commented Dec 6, 2019

Copy link
Copy Markdown
Member

Did you build agains a live CoreCLR?

@agocke

agocke commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

I did nothing except run build in the root

@safern

safern commented Dec 6, 2019

Copy link
Copy Markdown
Member

I did nothing except run build in the root.

I see. So actually that will build libraries against 2 week old version of coreclr which is the last transport package produced before we consolidated the repo. In order to be able to build locally against a live build of coreclr you need to first build:

coreclr.cmd you could just build S.P.CoreLib for this purpose so, coreclr.cmd -windowsmscorlib.

Then you want to build libraries against that by running:
libraries.cmd /p:CoreCLROverridePath=<path-to-folder-containing-S.P.CoreLib>

In PR builds we're already building against a live CoreCLR as of yesterday morning, so we could retrigger CI and you will not see this issue in your PR builds. However, until: #494 is merged we shouldn't be merging cross repo changes as it would break local people development, so I'm adding NO-MERGE to this PR in the meantime.

@safern

safern commented Dec 6, 2019

Copy link
Copy Markdown
Member

/azp run runtime-libraries

@safern safern added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Dec 6, 2019
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@agocke

agocke commented Dec 10, 2019

Copy link
Copy Markdown
Member Author

@safern Looks like the build is stalling out

@agocke agocke closed this Dec 10, 2019
@agocke agocke reopened this Dec 10, 2019
@safern

safern commented Dec 13, 2019

Copy link
Copy Markdown
Member

This can now be merged as we've merged the PR to build live-live locally. However I'd like to re-run CI just to make sure is up-to-date and green.

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.

7 participants