-
Notifications
You must be signed in to change notification settings - Fork 390
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 mapping generator for libstdc++ #1606
Conversation
also cc @justanotheranonymoususer if you're interested in an example of generated mappings |
Informational: IWYU dogfood resultsinclude-what-you-use (exit: 0)
fix_includes.py (exit: 0)
diff |
I don't know python enough for reviewing this. The changes to the mappings seem reasonable. |
I don't know python either, but more fundamental I don't understand how the library detects automatically the mappings from the lib std++ code alone. What is the advantage of maintaining the python script vs the mappings themselves? |
It's possible to see some patterns in the library code, which lets you tell the difference between public and private headers (this is described in detail in the script doc comments). Armed with that knowledge, you can say that an include from a public header to a private header implies a mapping from public to private. There are exceptions and special cases, and they are also encoded in the script.
See PR description, but yes, pretty much. The mappings were originally generated by shell pipelines for GCC 4.6, then manually edited, then manually patched as issues were found. At this point the set of mappings on master is basically unmaintainable when faced with a new GCC version. |
Interesting, are those patterns general or only applicable to libstdc++? Also, I found that concrete mappings for libstd++ (GNU) and libc++ (LLVM) are very different, for that matter.
I see. Also, would this cover the cases for libc++? |
No, those exact patterns are only relevant for libstdc++. Other libraries have other patterns, as encoded in the other mapgen scripts.
Yeah, libc++ is a different library with different conventions.
I was just thinking about that the other day. Assuming the patterns hold across GCC versions, it should be possible to install and generate mappings for every major GCC version, then keep version-keyed maps in |
d8ecbf0
to
02159c3
Compare
The build failure looks like this: llvm/llvm-project#99819 |
ae408a1
to
0f021a1
Compare
@firewave Thanks, yeah, I started trying to work around it, but there were many different files missing. It would be nice if CMake could be convinced to ignore missing files (or convert the error to a warning); very few of these errors are actually relevant to us. |
There is unfortunately a lack of documentation for the CMake integration. But I had a quick look at the file and it doesn't seem like any of this might be configurable. It also references CMake 2.8 so it seems like this stuff hasn't been touched in ages. |
This replaces the built-in libstdc++ mappings with a machine-generated set. Since debug headers are also part of the generated corpus, remove the special debug header mapping table. Replace gcc.stl.headers.imp with generated mappings, and remove the now-obsolete gcc.stl.debug.imp.
Mostly to have the built-in mapping generator procedure and tradeoffs documented.
0f021a1
to
d39077f
Compare
Informational: IWYU dogfood resultsinclude-what-you-use (exit: 0)
fix_includes.py (exit: 0)
diff |
OK, I'm going to say this is ready for action now. Yolo, etc! |
If this seems to work out, the procedure for updating mappings should be:
followed by some cutting and pasting to get the right lines into the right place (this can obviously be improved over time).
Poor mappings can now be improved in the python code instead of manually in the mapping tables, which makes tracking much easier.
And above all, users running a very new or very old GCC can simply regenerate their mappings in situ and use a generated
.imp
table or patch their IWYU source and rebuild with matching builtin mappings.@firewave @alejandro-colomar @correaa Let me know what you think.