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

Boris Kolpackov via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 27 02:53:05 PDT 2017


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).

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



More information about the cfe-dev mailing list