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

NativeAOT implement warning as errors as a compiler feature #96567

Merged
merged 4 commits into from
Jan 19, 2024

Conversation

vitek-karas
Copy link
Member

@vitek-karas vitek-karas commented Jan 5, 2024

Both roslyn and trimmer implement "warn as error" as a compiler feature - specifically the TreatWarningsAsErrors property only affects tools which explicitly react to it. There's a related MSBuild command line option which will affect all warnings, but that's not the one VS sets from the UI and what most customers use. See the comments in #94178.

This implements the same behavior as the trimmer. It adds 3 new command line options to ilc and enable "warn as error" globally and to enable/disable specific warning codes. Note that illink implements a more complex command line parsing where order of parameters matters and sometimes the later ones can override the earlier ones. This was trying to emulate csc behavior. For ilc I don't see a reason to emulate that because running ilc on its own is not supported, only going through the SDK, which will never pass the new parameters multiple times.

For testing this enables the existing trimmer tests for this functionality. This uncovered a small issue in substitution parser, which is also fixed here. For simplicity the test infra emulates the illink command line behavior over ilc (which is easy as they're very similar).

Open question:
Trimmer introduces ILLinkTreatWarningsAsErrors property which defaults to TreatWarningsAsErrors but can be overriden and it specifically applies on to illink. I didn't introduce a new one for ilc as I don't see much value in doing so, but I may be missing something. @sbomer - do you think we should add IlcTreatWarningsAsErrors?

Update:
We agreed to add IlcTreatWarningsAsErrors.

@ghost
Copy link

ghost commented Jan 5, 2024

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Both roslyn and trimmer implement "warn as error" as a compiler feature - specifically the TreatWarningsAsErrors property only affects tools which explicitly react to it. There's a related MSBuild command line option which will affect all warnings, but that's not the one VS sets from the UI and what most customers use. See the comments in #94178.

This implements the same behavior as the trimmer. It adds 3 new command line options to ilc and enable "warn as error" globally and to enable/disable specific warning codes. Note that illink implements a more complex command line parsing where order of parameters matters and sometimes the later ones can override the earlier ones. This was trying to emulate csc behavior. For ilc I don't see a reason to emulate that because running ilc on its own is not supported, only going through the SDK, which will never pass the new parameters multiple times.

For testing this enables the existing trimmer tests for this functionality. This uncovered a small issue in substitution parser, which is also fixed here. For simplicity the test infra emulates the illink command line behavior over ilc (which is easy as they're very similar).

Open question:
Trimmer introduces ILLinkTreatWarningsAsErrors property which defaults to TreatWarningsAsErrors but can be overriden and it specifically applies on to illink. I didn't introduce a new one for ilc as I don't see much value in doing so, but I may be missing something. @sbomer - do you think we should add IlcTreatWarningsAsErrors?

Author: vitek-karas
Assignees: vitek-karas
Labels:

area-NativeAOT-coreclr

Milestone: -

Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

Looks like tests will need some warning disabling since the warnings now trigger a build failure.

Renames the command line arguments as per PR feedback

Adds suppressions to smoke tests as necessary
@sbomer
Copy link
Member

sbomer commented Jan 8, 2024

@sbomer - do you think we should add IlcTreatWarningsAsErrors

No strong opinion. I would probably add it in case it comes in handy for someone, but it's probably not going to be widely useful. We can also always add it later if needed.

@MichalStrehovsky
Copy link
Member

Thank you for doing the "nice" suppressions in the tests (instead of just blanket disabling everything).

Looks like there's more failures outside nativeaot/SmokeTests.

We should also run the pri0 suite since I assume there will be more of these in the test tree. If you don't want to run it locally, I suggest disabling WarnAsError in the PR temporarily so that the build doesn't just stop after a couple of these (or look at warnings in some older PRs where we did azp run runtime-nativeaot-outerloop).

@vitek-karas
Copy link
Member Author

I added the IlcTreatWarningsAsErrors.
And then I used it in tests to disable it - to avoid breaking tests if some code doesn't correctly suppress all the right warnings. Basically as before the change.
I guess we could try fixing the tests, but this felt simpler.

@vitek-karas
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vitek-karas
Copy link
Member Author

All the failures seem to be known (The S.T.Json failure is the crash without a dump problem reported elsewhere already).
@MichalStrehovsky could you please take a look at the recent test changes if you like it?

Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

Thank you! Sorry for the delay, I thought I signed off already.

@vitek-karas vitek-karas merged commit b4488ec into dotnet:main Jan 19, 2024
154 of 161 checks passed
@vitek-karas vitek-karas deleted the WarnAsError branch January 19, 2024 19:45
tmds pushed a commit to tmds/runtime that referenced this pull request Jan 23, 2024
…6567)

Both roslyn and trimmer implement "warn as error" as a compiler feature - specifically the `TreatWarningsAsErrors` property only affects tools which explicitly react to it. There's a related MSBuild command line option which will affect all warnings, but that's not the one VS sets from the UI and what most customers use. See the comments in dotnet#94178.

This implements the same behavior as the trimmer. It adds 3 new command line options to `ilc` and enable "warn as error" globally and to enable/disable specific warning codes. Note that `illink` implements a more complex command line parsing where order of parameters matters and sometimes the later ones can override the earlier ones. This was trying to emulate `csc` behavior. For `ilc` I don't see a reason to emulate that because running `ilc` on its own is not supported, only going through the SDK, which will never pass the new parameters multiple times.

For testing this enables the existing trimmer tests for this functionality. This uncovered a small issue in substitution parser, which is also fixed here. For simplicity the test infra emulates the `illink` command line behavior over `ilc` (which is easy as they're very similar).
rmarinho pushed a commit to dotnet/maui that referenced this pull request Jan 31, 2024
…view1 (#20268)

* Align expected NativeAOT build warning messages in integration tests

* Do not treat NativeAOT build warnings as errors - introduced with dotnet/runtime#96567
rmarinho added a commit to dotnet/maui that referenced this pull request Feb 5, 2024
* Update versions

* Update Versions.props

* Update versions

* Update Versions.props

* Update Versions.props

* Fix ios versions

* Update versions of Tizen

* Update iOS

* Update Version.Details.xml

* Update Versions.props

* Update versions again

* Update sdk

* Dont build net8

* Add loging

* skip this one and see

* [ci] Push artifacts for the sample tests (#20269)

* [ci] Always publish the artifacts

* remove verbosity

* Enable stable branding

* NativeAOT: Update NativeAOT integration tests to run with 9.0.1xx-preview1 (#20268)

* Align expected NativeAOT build warning messages in integration tests

* Do not treat NativeAOT build warnings as errors - introduced with dotnet/runtime#96567

* [release/9.0.1xx-preview1] Update versions (#20279)

* Update versions

* Ignore blazor tests on old webview

* [release/9.0.1xx-preview1]  Revert "Dont build net8" (#20286)

* Revert "Dont build net8"

This reverts commit 4d59c64.

* Update versions

* Update Compatibility.csproj

* Update versions

* Update dotnet.cake

Update dotnet.cake

Set env variables before build  device tests

Update DotnetInternal.cs

Update dotnet.cake

* Don't build template tests again

---------

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com>
rmarinho pushed a commit to dotnet/maui that referenced this pull request Feb 12, 2024
…n tests (#20471)

* Fix RunOniOS test

* Do not treat NativeAOT build warnings as errors - introduced with dotnet/runtime#96567

---------

Co-authored-by: Simon Rozsival <simon@rozsival.com>
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2024
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.

3 participants