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

Add vs2022 mapping file and support warning level from iwyu_tool #1502

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ThosRTanner
Copy link
Contributor

@ThosRTanner ThosRTanner commented Mar 29, 2024

This adds a couple of small tweaks to help those of us working with visual studio 2022

  1. A .imp file for windows headers. I've made windef, minwindef and winuser.h all map to windows.h because they do not compile by themselves (despite visual c++ include checker suggesting it...)
  2. A small tweak to iwyu_tool to support outputting the messages as warning level instead of error level (useful for working with visual c++ which understands clang messages, but causes the build to come to a dead stop on errors.)

Note this is on not-the-latest iwyu as the latest llvm isn't available in the right sort of way for windows, yet. Which appears to be causing a build error in the check.

@kimgr
Copy link
Contributor

kimgr commented Mar 31, 2024

Nice, thanks! Can I ask you to split it into three distinct commits;

  • .gitignore changes
  • iwyu_tool.py changes
  • mappings

And it might be nice to split it into three different PRs, because they're entirely unrelated, and some might need more iterations before merge than the others.

@kimgr
Copy link
Contributor

kimgr commented Mar 31, 2024

Also, if you rebase on latest IWYU master, CI should be able to build (there's been a breaking change in Clang since you last pulled upstream master).

@ThosRTanner
Copy link
Contributor Author

ThosRTanner commented Apr 2, 2024

well, I can do that but I can't actually build iwyu with that version is clang / llvm version 19 is available pre-packed yet. but will redo as 3 separate PRs, (but honest, it was just to get it usable with visual c++...)

Also I think the CI might be slightly broken if it's not pulling main branch on top of this change before verifying it.

@kimgr
Copy link
Contributor

kimgr commented Apr 2, 2024

I can also do it, if you prefer.

Also I think the CI might be slightly broken if it's not pulling main branch on top of this change before verifying it.

Yeah, I was actually surprised to see a PR running on top of a rebased master in another project today. But doing it that way makes a lot more sense. I'm not sure what I'm doing wrong in our current GitHub Actions workflow: https://github.com/include-what-you-use/include-what-you-use/blob/master/.github/workflows/ci.yml#L45

@firewave
Copy link

firewave commented Apr 3, 2024

I'm not sure what I'm doing wrong in our current GitHub Actions workflow

I am not sure. But I see no need for that IWYU_CHECKOUT_REF stuff. Just do uses: actions/checkout@v4 without any parameters.

@kimgr
Copy link
Contributor

kimgr commented Apr 4, 2024

@ThosRTanner Do you mind if I commandeer these changes? I don't have a Window system to test on, but I'd be happy to split up and adjust the individual changes for mainline if you're not already doing something.

Note: Although visual c++ recommends to include minwinbase (etc etc),
you can't unless you include windows.h first - it just won't compile.

So I've made them all private and map to windows.h
@ThosRTanner
Copy link
Contributor Author

Sure, no problem. I've split them up into 3 commits anyway. My time can be a bit bursty I'm afraid, and I can't build IWYU for the latest llvm until the latter has been built appropriately for windows. (And hopefully this time they won't put in a hard coded reference to visual c++ 2019 professional - see llvm/llvm-project#86250 !)

@ThosRTanner ThosRTanner marked this pull request as draft April 6, 2024 18:43
@ThosRTanner
Copy link
Contributor Author

ThosRTanner commented Apr 6, 2024

Hm. some of the windows mappings seem wrong. windows headers are despicably evil.

The other 2 changes are OK, though

@ThosRTanner ThosRTanner marked this pull request as ready for review April 7, 2024 07:40
@kimgr
Copy link
Contributor

kimgr commented Apr 7, 2024

@ThosRTanner Please take a look: #1515

@@ -0,0 +1,10 @@
[
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not so sure about this mapping as a whole.

It's convenient for a VS2022 user, but it actually covers 3 unrelated libraries:

  • The Windows SDK (which ships on a different cadence than Visual Studio)
  • The MSVC STL (which I think is strictly speaking bound to the compiler release cadence, not the IDE... or maybe the compiler is bound to the IDE, not sure)
  • The Universal CRT (which is Microsoft's attempt at a libc separate from compiler and IDE)

We typically ship mappings per library so they can be versioned as the library changes. It looks to me like these mappings are just what happened to work for your project, in which case it's probably better for you to maintain it as part of the project than as part of IWYU.

Let me know if I'm missing something there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, maybe that should be multiple mapping files then? I didn't do any special settings so these changes look like things that users of visual c++ are likely to stumble across.

I couldn't find anything for windows in the project, so I thought it might be useful for others, not just me. Having said which if it needs to be 3 files, it needs to be 3 files.

Copy link
Contributor

Choose a reason for hiding this comment

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

They look very sparse, I was curious how likely it is that another project using e.g. "shlwapi.h", <map> or <algorithm> would work with these mappings? My guess is not very.

I've tried to build a library mapping generators under https://github.com/include-what-you-use/include-what-you-use/tree/master/mapgen so that users can generate mappings from the actual installed libraries rather than carrying hand-edited mappings for everything in the project. I think it would be better to invest in something like that for the Windows/MSVC libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants