Skip to content

Trim OperatingSystem.IsXxx checks in library build - #136476

Open
am11 wants to merge 3 commits into
dotnet:mainfrom
am11:illink-os-substitutions
Open

am11 wants to merge 3 commits into
dotnet:mainfrom
am11:illink-os-substitutions

Conversation

@am11

@am11 am11 commented Oct 26, 2026

Copy link
Copy Markdown
Member

Branch illink-os-substitutions (eee2675) compared to main (a81c879), linux-x64, -c Release.

Library main PR Diff
System.Diagnostics.Process 158,720 158,208 −512
System.Formats.Tar 106,496 105,984 −512
System.IO.Compression 188,416 187,904 −512
System.IO.FileSystem.DriveInfo 38,912 38,400 −512
System.Net.Http 579,584 579,072 −512
System.Net.NameResolution 93,184 92,672 −512
System.Net.Ping 41,984 40,960 −1,024
System.Net.Quic 154,624 150,528 −4,096
System.Net.Security 370,688 369,664 −1,024
System.Security.Cryptography 1,129,472 1,125,376 −4,096
Total (all DLLs) 34,301,952 34,288,640 −13,312

@dotnet-policy-service dotnet-policy-service Bot added linkable-framework Issues associated with delivering a linker friendly framework community-contribution Indicates that the PR has been added by a community member labels Oct 26, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@am11

am11 commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

cc @jkotas #132218 (comment)

@agocke

agocke commented Oct 26, 2026

Copy link
Copy Markdown
Member

Rather than generating substitutions, if we think this is valuable we should implement these checks as proper feature switches.

@jkotas

jkotas commented Oct 26, 2026

Copy link
Copy Markdown
Member

these checks as proper feature switches.

How would that work? The values are not user configurable. They are controlled by the runtime environment.

Note that this is just for netcoreapp libraries build that trims individual assemblies and uses reference assemblies for dependencies. This mode is special and comes with number of quirks. I think an alternative way to fix this would be to make this mode less special and reference implementation assemblies when trimming netcoreapp libraries. I suspect it would be more complicated change.

Comment thread eng/illink.targets Outdated
@am11

am11 commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

How would that work? The values are not user configurable. They are controlled by the runtime environment.

I had two versions of this change, one this, the other for all ref assemblies without the user appcontext switches, but it is a bit noisy change (we need to collect all assemblies in shared framework). I can stage it if that is preferred.

@agocke

agocke commented Oct 26, 2026

Copy link
Copy Markdown
Member

How would that work? The values are not user configurable. They are controlled by the runtime environment.

I was imagining that it work just like the subsitutions defined above -- instead of encoding manual substitution XML entries we would define [FeatureSwitchDefinition] for each of the OS helper methods, then functionally we would pass the same --feature flags during library trimming as encoded by the OS compat table. This would avoid using the XML substitution backend.

But I forgot that FeatureSwitchDefinition is only valid for properties, so we can't use it without a new parameterless method feature.

@am11

am11 commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Alternative: #136495

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Infrastructure-libraries community-contribution Indicates that the PR has been added by a community member linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants