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

Use ReferencePathWithRefAssemblies for libs ILLink #79595

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Dec 13, 2022

Fixes #79513

The libraries build invokes ILLink to perform "library" mode trimming. The libraries build step is expected to be runtime agnostic and shouldn't bind against a specific CoreLib runtime implementation.

During compilation, even though we have a ProjectReference pointing to the CoreLib/src project, we build against CoreLib/ref. But that ILLink invocation doesn't honor that as it uses the ReferencePath msbuild item instead of ReferencePathWithRefAssemblies.

Fixes #79513

The libraries build invokes ILLink to perform "library" mode trimming. The libraries build step is expected to be runtime agnostic and shouldn't bind against a specific CoreLib runtime implementation.

During compilation, even though we have a ProjectReference pointing to the CoreLib/src project, we build against CoreLib/ref. But that ILLink invocation doesn't honor that as it uses the ReferencePath msbuild item instead of ReferencePathWithRefAssemblies.
@ghost ghost added the linkable-framework Issues associated with delivering a linker friendly framework label Dec 13, 2022
@ghost ghost assigned ViktorHofer Dec 13, 2022
@ghost
Copy link

ghost commented Dec 13, 2022

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #79513

The libraries build invokes ILLink to perform "library" mode trimming. The libraries build step is expected to be runtime agnostic and shouldn't bind against a specific CoreLib runtime implementation.

During compilation, even though we have a ProjectReference pointing to the CoreLib/src project, we build against CoreLib/ref. But that ILLink invocation doesn't honor that as it uses the ReferencePath msbuild item instead of ReferencePathWithRefAssemblies.

Author: ViktorHofer
Assignees: -
Labels:

area-Infrastructure-libraries, linkable-framework

Milestone: -

@jkotas
Copy link
Member

jkotas commented Dec 13, 2022

I need to understand the implications of passing in ref/CoreLib instead of src/CoreLib

Yes, it is going to fix the problem. We are going to lose some trimming that is happening right now. It should not be in the noise range for CoreCLR (about 3kB across whole netcoreapp). It can be more for Mono mobile targets, but I do not think it is a problem there since mobile targets should always run trimming step during publish and so it is not going to impact size of the final app.

@jkotas
Copy link
Member

jkotas commented Dec 13, 2022

You can also revert #79523 as part of this change. It should not be necessary anymore.

@jkotas
Copy link
Member

jkotas commented Dec 13, 2022

@marek-safar Any concerns about impact of this change on mobile targets?

@marek-safar
Copy link
Contributor

@jkotas no concerns, mobile runtime packs are massive for other reasons so any sdk like trimming has no visible impact.

@ViktorHofer ViktorHofer marked this pull request as ready for review December 13, 2022 18:53
@ViktorHofer
Copy link
Member Author

You can also revert #79523 as part of this change. It should not be necessary anymore.

Will do that in a follow-up PR.

@akoeplinger
Copy link
Member

Should we backport this?

@ViktorHofer
Copy link
Member Author

I defer to @jkotas and @MichalStrehovsky regarding the likeliness of this affecting customers. As this also impacts inbox binaries which ship inside a package, we would need to also re-ship those (< 10 libs). I.e. System.Text.Json.

@MichalStrehovsky
Copy link
Member

I defer to @jkotas and @MichalStrehovsky regarding the likeliness of this affecting customers. As this also impacts inbox binaries which ship inside a package, we would need to also re-ship those (< 10 libs). I.e. System.Text.Json.

We have #78532 lined up for servicing that is fixing DiagnosticSource to work with NativeAOT. The fix is to call RuntimeFeature.IsDynamicCodeSupported, and this call is outside corelib. Those are the same conditions that triggered #79513 that this PR is fixing. I didn't check, but I think this will trigger the same issue and we're going to run into this during the servicing validation. Might as well preempt that and backport this.

@jkotas
Copy link
Member

jkotas commented Dec 15, 2022

As this also impacts inbox binaries which ship inside a package

This should only affect binaries that reference CoreLib project directly. None of binaries that reference CoreLib project directly ship in a package.

S.D.DiagnosticSource does not reference CoreLib project directly so it should not be affected.

This is the list of assemblies affected by this change (diffed IL before/after):

  • System.Collections.Concurrent - IntPtr.Size, Array.MaxLength
  • System.Collections - Array.MaxLength
  • System.Data.Common - RuntimeHelpers.IsDynamicCodeSupported
  • System.Diagnostics.TraceSource - Environment.NewLine
  • System.Memory - Array.MaxLength
  • System.Private.Uri - OperatingSystem.IsWindows()

System.Data.Common is the only assembly where the problem is observable.

I think it would be hard to justify pushing the fix to servicing given the limited impact. We do not have any reports of customers hitting the problem in System.Data.Common, and it is likely that anybody trying to use System.Data.Common at this point with native AOT is going to hit number of issues and warnings (the managed database providers are not Aot clean) so having one more caused by a runtime bug is not a big deal.

@MichalStrehovsky
Copy link
Member

Ah, makes sense. Thank you for checking! It is a great testament to the libs test code coverage that the only issue we had was actually found in testing!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure-libraries linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Framework trimming inlines CoreCLR's CoreLib into other inbox libraries
5 participants