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

Added DEBUG switches for roundtrip ILASM #72128

Merged
merged 5 commits into from
Aug 6, 2022

Conversation

TIHan
Copy link
Contributor

@TIHan TIHan commented Jul 13, 2022

Description

Should resolve: #72127 - this was failing because ilasm.exe was not being invoked with the /DEBUG flag when the corresponding project was.

Acceptance Criteria

  • ILASM Roundtrip CI does not have a failure on poison.sh
  • No additional ILASM roundtrip failures

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost assigned TIHan Jul 13, 2022
@TIHan
Copy link
Contributor Author

TIHan commented Jul 13, 2022

/azp run runtime-coreclr ilasm

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@TIHan
Copy link
Contributor Author

TIHan commented Jul 14, 2022

/azp run runtime-coreclr ilasm

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@ghost
Copy link

ghost commented Jul 15, 2022

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Should resolve: #72127 - this was failing because ilasm.exe was not being invoked with the /DEBUG flag when the corresponding project was.

Acceptance Criteria

  • ILASM Roundtrip CI does not have a failure on poison.sh
  • No additional ILASM roundtrip failures
Author: TIHan
Assignees: TIHan
Labels:

area-ILTools-coreclr

Milestone: -

@TIHan
Copy link
Contributor Author

TIHan commented Jul 15, 2022

/azp run runtime-coreclr ilasm

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@TIHan
Copy link
Contributor Author

TIHan commented Jul 18, 2022

@TIHan
Copy link
Contributor Author

TIHan commented Jul 27, 2022

@dotnet/jit-contrib This is ready. I'm running the ilasm roundtrip tests in CI, there are known failures, but we should not see the poison in the list. I tested this manually and adding the <_IlasmSwitches>$(_IlasmSwitches) -DEBUG</_IlasmSwitches> fixes the roundtrip test.

@TIHan
Copy link
Contributor Author

TIHan commented Aug 2, 2022

Pinging @dotnet/jit-contrib again - should be a quick review

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem quite right; it's not general.

Why is this specific to the poison test?

There is already code that uses the various project file configurations to set the correct ilasm flags. Is this not getting used somehow? See:

<_IlasmSwitches>-QUIET -NOLOGO</_IlasmSwitches>
<_IlasmSwitches Condition="'$(FoldIdenticalMethods)' == 'True'">$(_IlasmSwitches) -FOLD</_IlasmSwitches>
<_IlasmSwitches Condition="'$(SizeOfStackReserve)' != ''">$(_IlasmSwitches) -STACK=$(SizeOfStackReserve)</_IlasmSwitches>
<_IlasmSwitches Condition="'$(DebugType)' == 'Full'">$(_IlasmSwitches) -DEBUG</_IlasmSwitches>
<_IlasmSwitches Condition="'$(DebugType)' == 'Impl'">$(_IlasmSwitches) -DEBUG=IMPL</_IlasmSwitches>
<_IlasmSwitches Condition="'$(DebugType)' == 'PdbOnly'">$(_IlasmSwitches) -DEBUG=OPT</_IlasmSwitches>
<_IlasmSwitches Condition="'$(Optimize)' == 'True'">$(_IlasmSwitches) -OPTIMIZE</_IlasmSwitches>
<_IlasmSwitches Condition="'$(IlasmResourceFile)' != ''">$(_IlasmSwitches) -RESOURCES="$(IlasmResourceFile)"</_IlasmSwitches>

@ghost ghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Aug 4, 2022
@TIHan
Copy link
Contributor Author

TIHan commented Aug 5, 2022

@BruceForstall - I did see those targets, but I believe the build uses this if you are compiling an .ilproj right? I think that is the case which is why it never picks up those flags for _IlasmSwitches. Our test targets just happen to use the same name _IlasmSwitches.

Why is this specific to the poison test?

In order to get the correct poisoned value, 0xCD, the assembly must be marked as debuggable, otherwise the runtime will not output the poisoned value, 0xCD, which is why the roundtrip test was failing.

Here is the code in the runtime that checks to poison the variable:

    // Returns true if address-exposed user variables should be poisoned with a recognizable value
    bool compShouldPoisonFrame()
    {
#ifdef FEATURE_ON_STACK_REPLACEMENT
        if (opts.IsOSR())
            return false;
#endif
        return !info.compInitMem && opts.compDbgCode;
    }

opts.compDbgCode would return false if we did not compile the .il with the -DEBUG flag.

it's not general

Before, I did try to generalize this in the test targets if we notice the DebugType as PdbOnly/Full/etc., - see this commit: 564dbfd#diff-7a4e5f3ff147c4363c6363eb39d726682c301afae8ab8e71518eba2dba1bb505R38
But it was not working; the conditions never returned true. So, I went for setting the switches directly in the specific project and that worked. I think it's ok that we set it like this for this one specific test.

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Aug 5, 2022
@BruceForstall
Copy link
Member

I did see those targets, but I believe the build uses this if you are compiling an .ilproj right?

I believe that's right; I realized that last night, too. So the .csproj round-trip testing wouldn't see it.

I did try to generalize this in the test targets if we notice the DebugType as PdbOnly/Full/etc., - see this commit: 564dbfd#diff-7a4e5f3ff147c4363c6363eb39d726682c301afae8ab8e71518eba2dba1bb505R38

That's the fix I was thinking. I tried a slight variant, main...BruceForstall:TryFixIlasmRoundTripDebugFlag, and it seemed to work. I assumed for .ilproj it would add the switches twice, but that doesn't seem to be true (and I don't know why).

Anyway, I'll go ahead and approve.

@TIHan
Copy link
Contributor Author

TIHan commented Aug 5, 2022

I'll update this with your variant. I bet mine didn't work because I didn't put it in a property group...

@TIHan
Copy link
Contributor Author

TIHan commented Aug 6, 2022

CI failure is not related, merging.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ILASM roundtrip fails on poison.sh
2 participants