-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix linker PDB behavior and add DebuggerSupport property #12144
Conversation
I'm wondering if we need this option at all. I can think of two major scenarios where debug symbols play a role. Linker link/copy/copyused managed assemblyI think it should not matter what TrimMode is used but the illinker should always do the right thing and produce PDBs, if they exist, which are correct. The user should not be asked to set up anything in this mode. Debugging is disabledWe already have feature-switch for that and we should fold the logic of removing any debug symbols into the same option instead of adding another combination. |
I agree with @marek-safar for the most part. The only additional question is if we should have an option to not copy symbols to the output - as a separate option from "Debugging disabled". Maybe the answer is no - we don't need it. Basically:
|
What is the feature switch for that? I know the linker .exe has a command line option, but how does a user toggle it? |
@eerhardt Isn't dotnet/runtime#37288 basically introduce a feature switch for that? It's runtime only for now, but we should also expose it do projects as an MSBuild property. The linker changes here won't need the property though, as they can adapt the behavior based on the item group with all of the feature switches which is passed to the linker. |
I take this to mean that the default should be equivalent to
I take this to mean that when the feature switch dotnet/runtime#37288 is ready, we should add an msbuild property, say,
I don't think we should wait for the feature switch to be ready to fix the PDB behavior. It seems to me we'll need something like |
It depends on what TrimmerRemoveSymbols should do. The intention is to by default ignore PDBs if there are none, fix them if they need fixing, copy them if they don't need fixing.
No, let's add correct MSBuild property now and link it to the feature switch when is available but hook it up correctly to debug symbols removal linker options |
I think the better solution would be to make the behavior of the linker depend solely on the |
I see. Thinking more about a property like
|
Totally agree and that's what mean by introducing MSBuild property. It should be similar to how
I see where you are heading but I'm not sure we should make that automatic, especially if there are more combinations (like
I'd go with a warning only |
- Filter out pre-link PDBs from the publish output - Introduce 'TrimSymbols' public option to allow removing symbols
"DebuggerSupport" will now serve as the public property that controls the linker's PDB behavior. It is intended to be used in RuntimeHostConfigurationOption to disable debugger support as well. When DebuggerSupport is true, the linker will output PDBs that match the processed IL (if PDBs were present in the input). When DebuggerSupport is false, it will remove all debug information from the input. Roslyn will continue to respect existing settings DebugSymbols and DebugType, regardless of DebuggerSupport.
I've added a |
@vitek-karas does the |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ILLink.targets
Outdated
Show resolved
Hide resolved
I guess it depends how we want to treat
If it's the former, then using Basically the question is how do we tie the link task options to feature switches... I "think" it's ok to go with the first option - in which case all we need to make sure of is that there's really only one MSBuild property which controls both the link task behavior and the feature switch. (The advanced scenario which Eric mentions that one wants debug symbols but with the feature switch off - we can probably say it's currently unsupported and let people mock with the internal properties if they really need it). |
The difference is that
Agreed. If someone sets
Currently there's a 1-to-1 mapping for feature switch arguments: |
Makes sense - let's do that. |
<_TrimmerLinkSymbols Condition=" '$(_TrimmerLinkSymbols)' == '' ">$(DebuggerSupport)</_TrimmerLinkSymbols> | ||
<_TrimmerLinkSymbols Condition=" '$(_TrimmerLinkSymbols)' == '' ">true</_TrimmerLinkSymbols> |
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.
Do we actually need _TrimmerLinkSymbols
property at all?
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.
We need some way to set the linker option to true
when DebuggerSupport
is empty. We could do that by defaulting DebuggerSupport
itself to true
, but I don't want to commit to making that default available at a particular place in the import chain - it would have to happen before RuntimeHostConfigurationOption
, but if it happens too early, then SDK components won't be able to distinguish between the default true
and an explicit true
set by the user.
Aside from that, this provides an "escape hatch" for people who want to tweak just the linker settings and are ok with relying on an unsupported property to experiment with things - see @eerhardt's comment for example.
This option gets its defaults from DebuggerSupport, but can be set explicitly.
I've updated this to include the two properties we talked about ( |
<_TrimmerLinkSymbols Condition=" '$(TrimmerRemoveSymbols)' == 'true' ">false</_TrimmerLinkSymbols> | ||
<_TrimmerLinkSymbols Condition=" '$(TrimmerRemoveSymbols)' != 'true' ">true</_TrimmerLinkSymbols> |
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.
Do we need the _TrimmerLinkSymbols
property anymore?
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.
Since the naming is inverted, it is probably easier to read this way. Unless we wanted to invert the ILLink Task option.
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.
It's necessary because the existing task option has the opposite polarity of the public property. (I don't think you can pass ="! $(TrimmerRemoveSymbols)"
). We could remove this by changing the task option (and maybe the command-line arguments). edit: @eerhardt beat me to it. :)
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.
<PropertyGroup Condition=" '$(TrimmerRemoveSymbols)' == '' "> | ||
<!-- The default is to remove symbols when debugger support is disabled, and keep them otherwise. --> | ||
<TrimmerRemoveSymbols Condition=" '$(DebuggerSupport)' == 'false' ">true</TrimmerRemoveSymbols> | ||
<TrimmerRemoveSymbols Condition=" '$(DebuggerSupport)' != 'false' ">false</TrimmerRemoveSymbols> |
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.
TrimmerRemoveSymbols hooking up into linker will be done separately, right?
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.
It's already hooked up - TrimmerRemoveSymbols
sets _TrimmerLinkSymbols
(inverted) which is already consumed by the linker (LinkSymbols
on the task -> -b
). If you would like, I can change the linker task option (in a separate change) to RemoveSymbols
so that we can simplify this.
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.
Simplifications in follow up PR sounds great
This replaces the LinkSymbols option, and has the opposite meaning. This will match the polarity of the SDK option introduced in dotnet/sdk#12144. This removes the integration tests since they no longer provide much value now that we insert directly into the SDK. (We used to insert into the product in core-sdk before changes were picked up by SDK). This will make it easier to change task input names without a cyclic dependency.
This replaces the LinkSymbols option, and has the opposite meaning. This will match the polarity of the SDK option introduced in dotnet/sdk#12144. This removes the integration tests since they no longer provide much value now that we insert directly into the SDK. (We used to insert into the product in core-sdk before changes were picked up by SDK). This will make it easier to change task input names without a cyclic dependency.
* Add RemoveSymbols option to task This replaces the LinkSymbols option, and has the opposite meaning. This will match the polarity of the SDK option introduced in dotnet/sdk#12144. This removes the integration tests since they no longer provide much value now that we insert directly into the SDK. (We used to insert into the product in core-sdk before changes were picked up by SDK). This will make it easier to change task input names without a cyclic dependency. * Fix build - Remove integration tests from sln - Fix xunit warning
* Add RemoveSymbols option to task This replaces the LinkSymbols option, and has the opposite meaning. This will match the polarity of the SDK option introduced in dotnet/sdk#12144. This removes the integration tests since they no longer provide much value now that we insert directly into the SDK. (We used to insert into the product in core-sdk before changes were picked up by SDK). This will make it easier to change task input names without a cyclic dependency. * Fix build - Remove integration tests from sln - Fix xunit warning Commit migrated from dotnet/linker@5eaaad2
(Edited)
Linker symbol behavior
Based on discussion with @eerhardt, @marek-safar, @vitek-karas, we have decided that there should be two properties, one to control debugger support all-up, and one to control linker symbol behavior. The latter should get defaults matching the debugger support property, but it should be possible to override the defaults by setting it explicitly. We also agreed that these settings should be independent of the compiler options (
DebugSymbols
/DebugType
).Ideally we would not have a linker symbol knob, and instead it would always fix up symbols in the input - and the SDK would have options to publish with or without symbols (or with symbols in a separate output directory). Lacking that ability, we expect the linker option to be useful especially for cases where the inputs contain embedded symbols that would be published otherwise.
Implementation
This change introduces two properties,
DebuggerSupport
andTrimmerRemoveSymbols
.DebuggerSupport
will eventually enableRuntimeHostConfigurationOption
to remove debugger support (see dotnet/runtime#37288). In this change, it only influences the defaults forTrimmerRemoveSymbols
:TrimmerRemoveSymbols
is set explicitly, this will be respected. If not set explicitly:DebuggerSupport
is empty ortrue
,TrimmerRemoveSymbols
defaults tofalse
.DebuggerSupport
isfalse
,TrimmerRemoveSymbols
defaults totrue
.TrimmerRemoveSymbols
will cause the linker to drop symbols from all inputs. If it is nottrue
, the linker will modify input symbols the same way that it modifies the corresponding IL (barring bugs).@samsp-msft could you please review the proposed naming of the options
DebuggerSupport
andTrimmerRemoveSymbols
? Rationale was:DebuggerSupport
matches existing feature flags likeInvariantGlobalization
.TrimmerRemoveSymbols
avoids the ambiguity ofTrimSymbols
(see the naming notes below).Below are the original notes, which are out of date.
Outdated notes
TrimSymbols
public option to allow removing symbols (replaces_LinkSymbols
)Naming:
TrimSymbols
matches the "trim" terminology we've been using, but is odd in that it suggests selective trimming, but actually means complete removal. Symbols are either "trimmed" with the same granularity as the assembly (defined by the newTrimMode
option), or not at all.Remove
/Strip
/Drop
might make more sense for the verb, but if we want consistency with the other options, maybe it should be calledTrimmerRemoveSymbols
for example. This is descriptive, but a bit verbose._LinkSymbols
.true
means the "trimmed" symbols are kept, andfalse
means they are discarded.Link
makes some sense in this context, but isn't accurate either - maybe a better name would beTrimmerPreserveSymbols
if we went this route.Defaults:
TrimSymbols
can be set tofalse
to keep the PDBs (which are modified to match the trimmed IL).@marek-safar @vitek-karas @eerhardt @samsp-msft I would appreciate feedback on the defaults and naming. Initially I thought
TrimSymbols
made sense, but after writing thisTrimmerRemoveSymbols
seems less confusing.