-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Enable featuredefault Substitutions To Only Apply at App Publish Time #96539
Comments
The However, I think that setting also skips reading command-line substitutions: If we fix this, I think it would make sense to:
|
Could it make sense to flip this around and have an "opt out" list of substitutions on the command line? Basically all the substitutions that happen during the build today of CoreLib should be respected at build time. There are just a handful (at this point - only one) that should be opted out of. |
I would argue that you don't need the embedded ones if you have the same on command line - because trimming will bake the value into and it will turn that property into I don't have a strong opinion either way. It would be easier to do what @sbomer suggest on the linker side, but would require more work in runtime build. And the other way round. |
How much work would it be to add a command line option like Then everything else stays the same. We don't need to mess with any of the existing unconditional substitutions that are happening (which is actually kind of complicated because of all the ways we build CoreLib - mono/coreclr/nativeaot x OS x architecture). |
We could also ignore all embedded features switches in |
Maybe it's time to revisit the "library build" in runtime? is it still worth it? |
IMO the value is in the following places:
|
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas Issue DetailsIn #80246, we are adding support for RuntimeFeature.IsDynamicCodeSupported to be a feature switch, instead of being hard-coded to As part of adding this feature switch, I don't want to regress app sizes for existing apps. Since CoreCLR currently hard-codes RuntimeFeature.IsDynamicCodeSupported ?
new ReflectionEmitCachingMemberAccessor() :
new ReflectionMemberAccessor(); The To do this, I wanted to use a However, since we run the trimmer during the build of System.Private.CoreLib, this We should figure out a way where a library can embed a
|
…blish time Fixes dotnet#96539. Fixes dotnet#102303. Two possible approaches were discussed in dotnet#96539 but doing it in illinker feels more straightforward.
Per discussion at #103463 (comment), I think a better way to accomplish this is to avoid using |
That makes sense to me. Not sure why that wasn't considered when I opened this issue. If we can make the MSBuild targets work for #80398, then we can close this issue. |
In #80246, we are adding support for RuntimeFeature.IsDynamicCodeSupported to be a feature switch, instead of being hard-coded to
true
for CoreCLR. This allows developers to test their code simulating it running with NativeAOT, without actually needing to publish for NativeAOT.As part of adding this feature switch, I don't want to regress app sizes for existing apps. Since CoreCLR currently hard-codes
RuntimeFeature.IsDynamicCodeSupported
totrue
. So when you trim a CoreCLR app with code like the following:The
ReflectionMemberAccessor
class can be trimmed, sinceIsDynamicCodeSupported
will always betrue
.To do this, I wanted to use a
featuredefault
option in myILLink.Substitutions.xml
. This would tell the trimmer that if no one specifies the RuntimeFeature.IsDynamicCodeSupported feature switch, assume it istrue
.However, since we run the trimmer during the build of System.Private.CoreLib, this
featuredefault
is getting applied during the "library build" time. Which means the property is getting hard-coded totrue
at the build time, and the code in the RuntimeFeature.IsDynamicCodeSupported property is getting removed.We should figure out a way where a library can embed a
featuredefault
ILLink.Substitutions.xml element, but only have it apply during "app publish" time.cc @sbomer @vitek-karas
The text was updated successfully, but these errors were encountered: