-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Default new runtime feature switches #23932
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,14 @@ Copyright (c) .NET Foundation. All rights reserved. | |
<!-- Trimmer defaults --> | ||
<PublishTrimmed Condition="'$(PublishTrimmed)' == ''">true</PublishTrimmed> | ||
<TrimMode Condition="'$(TrimMode)' == ''">link</TrimMode> | ||
<TrimmerRemoveSymbols Condition="'$(TrimmerRemoveSymbols)' == ''">false</TrimmerRemoveSymbols> | ||
|
||
<!-- Runtime feature defaults to trim unnecessary code --> | ||
<EventSourceSupport Condition="'$(EventSourceSupport)' == ''">false</EventSourceSupport> | ||
<UseSystemResourceKeys Condition="'$(UseSystemResourceKeys)' == ''">true</UseSystemResourceKeys> | ||
<EnableUnsafeUTF7Encoding Condition="'$(EnableUnsafeUTF7Encoding)' == ''">false</EnableUnsafeUTF7Encoding> | ||
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I know it's not related to this change, but it just caught my eye... the naming is so inconsistent. We have "SomethingSupport" then "UseSomething" and then also "EnableSomething". Would be nice to have some system to this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The difference between "SomethingSupport" and "EnableSomething" is what the default behavior is. By default, "EventSource", "Debugger", and "HttpActivityPropagation" are all supported by default. UTF7 Encoding is disabled by default, and you need to enable it to use it. Since the default is enabled, it wouldn't make sense to say Side Note on EnableUnsafeUTF7Encoding: ILLink.Substitutions + default feature switch values don't work very well with the way we link the runtime libraries during the build. We would need a way to ignore the substitution during the runtime build, but still embed it into the assembly. I had a conversation with @sbomer about this, and we decided that for now, setting EnableUnsafeUTF7Encoding to the default value here is probably the best option for 5.0.
Any suggestions on how to make this better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe Re having susbtitutions which are not applied during library build - I would have to think about this some more, but I'm definitely willing to add something to the linker to make this possible. CoreFx is special in that we ship the linked binaries, but I do expect other libraries to run linker for the purposes of analysis - so they might run into similar problem. |
||
<HttpActivityPropagationSupport Condition="'$(HttpActivityPropagationSupport)' == ''">false</HttpActivityPropagationSupport> | ||
<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(Configuration)' == 'Release'">false</DebuggerSupport> | ||
|
||
<StaticWebAssetBasePath Condition="'$(StaticWebAssetBasePath)' == ''">/</StaticWebAssetBasePath> | ||
<BlazorCacheBootResources Condition="'$(BlazorCacheBootResources)' == ''">true</BlazorCacheBootResources> | ||
|
@@ -414,7 +422,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |
Condition="'%(ResolvedFileToPublish.RelativePath)' != 'web.config' AND !$([System.String]::Copy('%(ResolvedFileToPublish.RelativePath)').Replace('\','/').StartsWith('wwwroot/'))" /> | ||
|
||
<!-- Remove pdbs from the publish output --> | ||
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition="'$(BlazorWebAssemblyEnableDebugging)' != 'true' AND '%(Extension)' == '.pdb'" /> | ||
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition="'$(DebuggerSupport)' == 'false' AND '%(Extension)' == '.pdb'" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'@(ResolvedFileToPublish->AnyHaveMetadataValue('RelativePath', 'web.config'))' != 'true'"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SDK defaults
TrimmerRemoveSymbols
based onDebuggerSupport
. IfDebuggerSupport
isfalse
, then the linker will remove the symbols. Since the Blazor SDK removes symbols from the publish output, I thought it was reasonable to always defaultTrimmerRemoveSymbols=false
so even if DebuggerSupport is false in Release mode, we still get the linked symbols, in case the developer wants to archive the linked symbols.cc @sbomer @vitek-karas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me - I doubt that processing symbols significantly changes link time. Curious that the logic to remove symbols from publish isn't shared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the trimmer already has support for removing symbols, it might be useful to just piggy back on it. Would it help if we removed
BlazorWebAssemblyEnableDebugging
and defaultedDebuggerSupport
tofalse
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense - might as well use the established properties in the core SDK and the runtime.
Is there ever a case where you'd want to preserve
.pdb
s for later debugging or perf sampling? I guess if users wanted symbols (but wanted to trim out the debug-only code for smaller apps) they could just setTrimmerRemoveSymbols
themselves. I guess the current default behavior in Blazor WASM is to not get symbols. So I think that would be fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I agree, only one concern:
I guess it depends on how we think people we use the PDBs for Blazor (and if they bring any value).
For example for server .NET Core apps (ASP.NET) I personally would definitely vote for always producing PDBs and just not bundling them to the final package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One place this brings value is when we start producing linker warnings. If the pdb is available, the linker will give source and line info in the warning. The developer will see the exact line of code causing the warning. That's super useful IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking is that having the .pdbs available somewhere - e.g. in the
obj
folder - by default, even if they are removed from the published assets, is useful. Honestly, I'm not sure whydotnet publish
puts symbols in the publish folder by default.https://github.com/dotnet/sdk/blob/44e5d1aa5ee51726096156f9c0d49e3b90c33f01/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L484
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those should still be around. We don't prevent creating the pdbs, just stop it from being copied to the publish output.
Couldn't the linker still use pdbs and then discard these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
TrimmerRemoveSymbols
is set totrue
, the linker won't update the symbols for the linked assemblies. Having the pre-trimmed symbols won't do you any good if you are using the trimmed assemblies - they won't match.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re source line info from linker: For this the linker needs the pdbs on the input - it doesn't matter if the linker itself will not write a pdb for this feature. That said I agree that having the pdbs (after linking) around somewhere is a good thing.