[cfe-dev] Modules TS: binary module interface dependencies

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 27 12:52:40 PDT 2017


On 27 June 2017 at 02:53, Boris Kolpackov via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I am trying to understand how Clang's Modules TS will work so that we
> have a general-enough model in the build system.
>
> Consider these two modules and a consumer:
>
> // module core
> export module core;
> export void f (int);
>
> // module extra
> export module extra;
> import core;
> export inline void g (int x) {f (x);}
>
> // consumer
> import extra;
> int main () {g ();}
>
> Currently, when compiling the consumer (with -fmodules-ts), Clang only
> requires the binary module interface (BMI) for extra. In contrast, VC
> and GCC require both extra and core (note: even though core is not
> re-exported from extra).
>

Assuming by BMI you mean the .pcm file, this is not true. Clang requires
both the core and extra .pcm files in this case. However, we found it
extremely impractical to explicitly pass all such .pcm files to a
compilation (and indeed on large projects doing so caused us to hit command
line length limits and generally produce *highly* unwieldy command lines),
so we do not require .pcm's that are reachable through the dependencies of
another .pcm file to be explicitly passed to the compiler -- each .pcm
stores names and relative paths to its dependencies, and we load those
dependencies as part of loading the .pcm itself.


> The Clang's model is definitely more desirable from the build system's
> perspective, especially for distributed compilation. So I wonder if this
> is accidental and will change in the future or if this is something that
> Clang is committed to, so to speak?
>
> Here is a more interesting variant of the extra module that highlights
> some of the issues to consider:
>
> // module extra
> export module extra;
> import core;
> export template <typename T> void g (T x) {f (x);}
>
> Now f() can only be resolved (via ADL) when g() is instantiated.
>
> Thanks,
> Boris
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170627/a80dcdf1/attachment.html>


More information about the cfe-dev mailing list