Circular include issues with Boost 1.79

15 views
Skip to first unread message

Chris Green

unread,
Jul 11, 2022, 11:21:37 AM7/11/22
to include-what-you-use
Hi,

I'm a first-time user of include-what-you-use, trying to run it on our software suite. Unfortunately, I've run into an issue with Boost. Fortunately, it can be reproduced with a simple source file with an empty main and only the include <boost/spirit/include/qi.hpp>.

I've tried using the mapping file boost-1.75-all-private.imp; I've also tried generating a specific mapping file for 1.79 following the comments in the 1.75 file, but I still get the following error:

Cycle in include-mapping:
  <boost/preprocessor/iteration/detail/iter/forward1.hpp> ->
  <boost/spirit/home/support/detail/as_variant.hpp> ->
  <boost/preprocessor/iteration/detail/iter/limits/forward1_256.hpp> ->
  <boost/preprocessor/iteration/detail/iter/forward1.hpp> ->
  <boost/preprocessor/iteration/detail/iter/forward1.hpp>
/scratch/greenc/test-products/iwyu/v0_18/src/include-what-you-use-0.18/iwyu_include_picker.cc:1081: Assertion failed: Cycle in include-mapping
Subprocess aborted

Should I be using the boost-1.75-all.imp in addition to boost-1.75-all-private.imp, or generating one for 1.79 and using the two together, or is there something else I'm missing? I've been programming C++ for >25y, but I'm stumped by Boost's use of preprocessor iteration and how IWYU can accommodate it.

I can provide more information/output if it would help.

Thanks for any help or advice,
Chris. 

Kim Gräsman

unread,
Jul 11, 2022, 3:04:14 PM7/11/22
to include-wh...@googlegroups.com
Hi Chris,


Boost is notoriously hard to analyze, as it combines the most wicked use of preprocessor and template metaprogramming to get things done :)

I realized quite recently that the issue is not necessarily a cycle in the include graph, but a cycle in the _mappings_. Unfortunately IWYU (sometimes? always?) generates mappings dynamically as headers are processed, so I think it sets itself up for this failure somehow.

I'll see if I can get to this issue at some point soon, but I have a few other things lined up first. I'd be happy to help out however I can if you want to take a stab at root-causing it.

Thanks,
- Kim

--
You received this message because you are subscribed to the Google Groups "include-what-you-use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to include-what-you...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/include-what-you-use/31df5900-0e89-4f5b-a315-e8393bafec7fn%40googlegroups.com.

Chris Green

unread,
Jul 11, 2022, 4:51:14 PM7/11/22
to include-what-you-use
Hi Kim,

I'd be happy to look into this further, but I think I'm missing something fundamental in my understanding of the relationship between the mapping file and the messages I'm seeing ("Found include..."). There seems to be some information loss which is preventing me from understanding where the circularity might be and how a change to the mapping file would prevent it.

Also, can you tell me why a difference in use of `"` vs `<' and `>' would alter how IWYU would see or not see a circularity?

Thanks,
Chris.

Kim Gräsman

unread,
Jul 11, 2022, 5:20:41 PM7/11/22
to include-wh...@googlegroups.com
Hi,

I can't say I fully understand this, either, but I'll give it a try.

> the relationship between the mapping file and the messages I'm seeing ("Found include...").

'Found include...' is emitted as a result of iwyu_preprocessor.cc seeing an '#include' directive (more or less).

As part of that process, it also notifies iwyu_include_picker.cc that a mapping should be set up between the includer and the include. I'm not entirely sure why this is a good idea, but it's always been the case, I think.

Re quoted vs angled includes, that's also historical. I guess it was built that way because there's no guarantee that "foo.h" and <foo.h> refer to the same thing, and Google (where IWYU originated) had pretty strong conventions around quoted vs angled includes (with a strong preference for quoted, I think). We've considered loosening that a bit so that foo.h could match both as angled or quoted, but not much progress has been made.

For what it's worth,
- Kim

Reply all
Reply to author
Forward
0 new messages