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

Update runtime repo to use Preview 7 SDK #72145

Merged
merged 19 commits into from
Aug 15, 2022
Merged

Conversation

agocke
Copy link
Member

@agocke agocke commented Jul 13, 2022

No description provided.

@ghost ghost assigned agocke Jul 13, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@agocke agocke marked this pull request as ready for review July 14, 2022 21:48
@agocke agocke requested a review from a team July 14, 2022 23:02
Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

LGTM. Of course, before merging we need to go through the usual process of communicating the change.

@agocke
Copy link
Member Author

agocke commented Jul 14, 2022

@MichalStrehovsky @LakshanF Looks like some NativeAOT libraries tests are failing after an SDK update. Ideas?

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky @LakshanF Looks like some NativeAOT libraries tests are failing after an SDK update. Ideas?

Looking... one thing that's missing is adding handling of the new TrimMode to NativeAOT targets. But the failure mode doesn't look like that's the problem.

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky @LakshanF Looks like some NativeAOT libraries tests are failing after an SDK update. Ideas?

Looking... one thing that's missing is adding handling of the new TrimMode to NativeAOT targets. But the failure mode doesn't look like that's the problem.

It's from the new aggresse trimming default in Preview 6. xUnit is calling PropertyInfo.GetValue on CollectionBehaviorAttribute.DisableTestParallelization but we trimmed the getter (the setter was left because the attribute is applied on something and we need the setter to materialize the Attribute instance at runtime - the getter is fair game).

This is actually a very lucky catch. Only a couple of the tests fail. The rest look like this:

Running assembly:System.Runtime.Tests, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Finished System.Runtime.Tests, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

Tests run: 0, Errors: 0, Failures: 0, Skipped: 0. Time: 0.0130819s

The fix will be along the lines of adding <TrimMode>partial</TrimMode> to eng\testing\tests.singlefile.targets.

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TrimmerDefaultAction>link</TrimmerDefaultAction>
<TrimMode>full</TrimMode>
Copy link
Member

Choose a reason for hiding this comment

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

We'll probably need to do the opposite here - nativeaot tests expect trimming and require the (now default) TrimMode=full. So this line is technically not needed. But the rest of the coreclr test tree will want to keep the partial TrimMode.

@@ -14,7 +14,7 @@
<Configurations>Debug;Release;Checked</Configurations>
<ServerGarbageCollection>true</ServerGarbageCollection>
<!-- Trim all dependent assemblies as though they were all marked IsTrimmable. -->
<TrimmerDefaultAction>link</TrimmerDefaultAction>
<TrimMode>full</TrimMode>
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this line if this is now the default?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we don't, I was just being explicit.

@agocke
Copy link
Member Author

agocke commented Jul 15, 2022

Does NativeAOT understand TrimMode=partial or does that need to be added?

@agocke
Copy link
Member Author

agocke commented Jul 15, 2022

/azp run runtime-extra-platforms,runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@MichalStrehovsky
Copy link
Member

Does NativeAOT understand TrimMode=partial or does that need to be added?

I think #71117 is what's needed. Could be folded into this PR to avoid adding the TODO.

@agocke agocke closed this Jul 15, 2022
@agocke agocke reopened this Jul 15, 2022
@agocke
Copy link
Member Author

agocke commented Jul 15, 2022

/azp run runtime-extra-platforms,runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@agocke
Copy link
Member Author

agocke commented Jul 15, 2022

/azp run runtime-extra-platforms,runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@agocke
Copy link
Member Author

agocke commented Jul 16, 2022

It looks like the installer tests are broken by dotnet/sdk#26462. The test execution happens through Arcade, so we can't pass DOTNET_ROOT as is.

I see two options for workaround:

  1. Add a capability to Arcade to set environment variables for the test process
  2. Update to an SDK daily build that contains the fix.

I don't see any way to use the Preview 6+ SDK otherwise.

@AaronRobinsonMSFT
Copy link
Member

@MichalStrehovsky or @vitek-karas Any thoughts on the NativeAOT failures?

/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92): Trim analysis error IL2070: ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.TypeInfo.DeclaredMethods.get'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [/__w/1/s/src/libraries/System.Runtime.Intrinsics/tests/System.Runtime.Intrinsics.Tests.csproj]
##[error]/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92,0): error IL2070: (NETCORE_ENGINEERING_TELEMETRY=Build) ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.TypeInfo.DeclaredMethods.get'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92): Trim analysis error IL2070: ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.TypeInfo.DeclaredMethods.get'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [/__w/1/s/src/libraries/System.Runtime.Intrinsics/tests/System.Runtime.Intrinsics.Tests.csproj]
##[error]/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92,0): error IL2070: (NETCORE_ENGINEERING_TELEMETRY=Build) ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.TypeInfo.DeclaredMethods.get'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92): Trim analysis error IL2067: ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [/__w/1/s/src/libraries/System.Runtime.Intrinsics/tests/System.Runtime.Intrinsics.Tests.csproj]
##[error]/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92,0): error IL2067: (NETCORE_ENGINEERING_TELEMETRY=Build) ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92): Trim analysis error IL2067: ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. [/__w/1/s/src/libraries/System.Runtime.Intrinsics/tests/System.Runtime.Intrinsics.Tests.csproj]
##[error]/_/src/xunit.execution/Extensions/ReflectionAbstractionExtensions.cs(92,0): error IL2067: (NETCORE_ENGINEERING_TELEMETRY=Build) ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethods(Type)'. The parameter 'type' of method 'ReflectionAbstractionExtensions.GetMethodInfoFromIMethodInfo(Type,IMethodInfo)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

@radical
Copy link
Member

radical commented Aug 13, 2022

/azp run runtime-extra-platforms,runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Aug 15, 2022

@MichalStrehovsky or @vitek-karas Any thoughts on the NativeAOT failures?

This is WarnAsError in action.

Apparently we deleted what it means to SuppressTrimAnalysisWarnings in dotnet/linker#2930 and NativeAOT no longer suppresses these. I've inlined what that means into the targets to work around and filed a 7.0 issue to fix it because this is customer-visible (#73926).

I'm puzzled why we're seeing it here because the break merged into linker repo 10 days ago and there's no way that made it into Preview 7 (in fact, troubleshooting this took longer than I'm willing to admit because the .targets in P7 SDK still have this suppression but we're picking it up from a NuGet instead).

cc @sbomer

@MichalStrehovsky
Copy link
Member

The Linux_musl x64 Debug failure is #73930 (a test touched 4 hours ago, so I'm going with the "unrelated to what we're doing here" theory).

We're good to merge once llvmfullaot is done with its thing.

@@ -74,7 +74,7 @@ public unsafe struct LbrTraceEventData64
public Span<LbrEntry64> Entries(int totalSize)
{
IntPtr entriesOffset = Unsafe.ByteOffset(ref Unsafe.As<LbrTraceEventData64, byte>(ref this), ref Unsafe.As<LbrEntry64, byte>(ref _entries));
return MemoryMarshal.CreateSpan(ref _entries, (totalSize - (int)entriesOffset) / sizeof(LbrEntry64));
return MemoryMarshal.CreateSpan(ref Unsafe.AsRef<LbrEntry64>(Unsafe.AsPointer(ref _entries)), (totalSize - (int)entriesOffset) / sizeof(LbrEntry64));
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't that cause a GC hole? Same with above.

Copy link
Member

Choose a reason for hiding this comment

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

Good catch. We either need to make this a ref struct with a big "DO NOT CLEAN UP THE REF PART" comment, or use fixed to grab the pointer instead.

Copy link
Member

Choose a reason for hiding this comment

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

Yes it will. I'll push a fix.

Copy link
Member

Choose a reason for hiding this comment

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

We either need to make this a ref struct with a big "DO NOT CLEAN UP THE REF PART" comment, or use fixed to grab the pointer instead.

I think we can make these static functions that take the owning struct by ref.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we make it

Suggested change
return MemoryMarshal.CreateSpan(ref Unsafe.AsRef<LbrEntry64>(Unsafe.AsPointer(ref _entries)), (totalSize - (int)entriesOffset) / sizeof(LbrEntry64));
return MemoryMarshal.CreateSpan(ref _entries, (totalSize - (int)entriesOffset) / sizeof(LbrEntry64));

and add [UnscopedRef] to the method?

Copy link
Member

Choose a reason for hiding this comment

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

Since I've also got the owner here, can we get this moved to build against the live build? Building against the repo's SDK is the root issue here.

Copy link
Member

Choose a reason for hiding this comment

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

I can look into it, I'm not totally sure on the constraints about that (we are publishing dotnet-pgo as a nuget package, would that be affected?). I probably need to involve @davidwrighton here.
I assume it can be done separately?

Copy link
Member

Choose a reason for hiding this comment

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

I assume it can be done separately?

Absolutely. My only concern is this project is the only one I found that seems to use the repo's SDK and could be heavily impacted by complex language changes that force updates to the public API surface. This is a longer-term concern and just something to keep in mind as the language evolves to have more of these low-level friendly features.

Copy link
Member

Choose a reason for hiding this comment

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

My only concern is this project is the only one I found that seems to use the repo's SDK and could be heavily impacted by complex language changes that force updates to the public API surface

Everything under src/coreclr/tools builds against the repo's SDK. Building against live bits has build sequencing issues where one wouldn't be able to build crossgen2 without building libs first, or run crossgen2 without building the host.

If we want to switch to live, I would want to know what the VS debug experience for live built things looks like. I would still prefer we don't do that because I kind of like I don't need to build coreclr VM, host, or other stuff for NativeAOT development.

Copy link
Member

Choose a reason for hiding this comment

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

Building against live bits has build sequencing issues

Ah. Thanks @MichalStrehovsky. This is an important consideration to note. Perhaps this wouldn't justify the resulting dev-loop pain.

There was no GC hole here in practice since the users have unmanaged
pointers. However, the better fix is to just mark it as UnscopedRef.
@radical
Copy link
Member

radical commented Aug 15, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical
Copy link
Member

radical commented Aug 15, 2022

@jakobbotsch build failed

@jakobbotsch
Copy link
Member

@jakobbotsch build failed

Hmm strange, it builds fine from within VS locally. I suppose we cannot use this attribute yet in the project. Let me go back to my other fix.

@radical
Copy link
Member

radical commented Aug 15, 2022

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sbomer
Copy link
Member

sbomer commented Aug 15, 2022

I'm puzzled why we're seeing it here because the break merged into linker repo 10 days ago and there's no way that made it into Preview 7 (in fact, troubleshooting this took longer than I'm willing to admit because the .targets in P7 SDK still have this suppression but we're picking it up from a NuGet instead)

dotnet/linker#2837 moved the linker targets to the nuget package, and we are only now picking up the SDK change that imports them from the package. Now the recent targets changes are lighting up because runtime depends on a more recent nuget than the one that was shipped in-box with the P7 SDK.

@radical
Copy link
Member

radical commented Aug 15, 2022

The wasm - AOT/EAT failures are present on main too, and are - #73961 .
The wasm debugger test failure is - #73957

@jkoritzinsky
Copy link
Member

Linux x64 Debug leg failure is #73930

@jkoritzinsky
Copy link
Member

All failures are accounted for. Merging this in.

@jkoritzinsky jkoritzinsky merged commit e3b2af3 into dotnet:main Aug 15, 2022
@ViktorHofer
Copy link
Member

Thanks for getting this in everyone. @jkoritzinsky as usual, can you please send out the notice to the team including instructions on how to obtain the new SDK (for global installs)?

@jkoritzinsky
Copy link
Member

Will do!

@ghost ghost locked as resolved and limited conversation to collaborators Sep 15, 2022
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.

Unpin C# compiler version for repo