[build2] GCC modulemap informations

Boris Kolpackov boris at codesynthesis.com
Fri Dec 1 10:07:56 UTC 2023


Arthur Laurent via users <users at build2.org> writes:

> i see you have implemented this, but i don't understand how it work exactly
> inside your build process can i have some precision on how it is implemented
> if possible ? do you use sockets or pipes ?

We use pipes, more precisely compiler's stdin/stdout (this allows the user
to replay the interaction for debugging, etc).


> the module mapper server is a thread of build2 ? an external process ?

build2 is a multi-threaded build system with each rule performing its
job in a thread. So the rule handles the module mapper communications
directly in this thread. To put it another way (and simplifying a bit),
a C/C++ compile rule without the module mapper spawns the compiler
process and simply blocks waiting for it to finish. With the module
mapper it instead reads the mapper requests and sends responses. You
can find the code in build2/libbuild2/cc/compiler-rule.cxx; search
for gcc_module_mapper and you will find all the relevant places.


> and is it really better than file based API ?

The static module mapper is basically a tidier equivalent of passing
the module to BMI mapping information on the command line. The main
difference compared to the dynamic mapper is that you have to have this
information and the BMIs ready ahead of starting the compiler, which is
not possible[*], at least not for header units. The dynamic mapper allows
you to discover this information and produce the BMIs during compilation.

Whether it's better I guess depends on what you are trying to achieve.
In build2 we use both for different purposes. Specifically, we use
the dynamic mapper to handle header units and static mapper to handle
named modules.

[*] To be precise, it is possible but one would need to implement textual
inclusion with the header unit importation semantics. So far, only Clang
has something like this with MSVC reportedly unlikely to be able to
support this directly in the compiler. For background, see:

https://developercommunity.visualstudio.com/t/scanDependencies-does-not-take-into-acc/10029154



More information about the users mailing list