[cfe-dev] Modules TS: various problems

Boris Kolpackov via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 20 00:58:42 PDT 2017


Richard Smith <richard at metafoo.co.uk> writes:

> .pcm files are not a distribution format. You still need the module
> interface to be available at the point of use (Clang will use them to emit
> text snippets in diagnostics, as well as for some internal purposes where
> we avoid making copies of data that's present in a source file).

My source file is partially preprocessed (-frewrite-includes) and is
transient. More generally, this won't play nice with distributed
compilation or being able to move build directories around.


David Blaikie <dblaikie at gmail.com> writes:

> This should be able to be addressed by using -Xclang
> -fmodules-embed-all-files [...]

Yes, this works, thanks.


Richard Smith <richard at metafoo.co.uk> writes:

> This line number doesn't match the above code.

Yes, my bad, I've killed a couple of irrelevant lines. It was the line
with '#include <string>'.


> I'm not surprised. Clang does not claim to fully implement the Modules TS
> yet; the implementation is incomplete. In particular, there is no support
> for the semantics of export declarations -- instead, we export everything
> declared within the module interface unit. As a result, you're importing
> the contents of <string> but not its include guards, so you will see
> redefinition errors for all definitions in that header.
> 
> If you want to experiment with Modules TS code using the standard library
> anyway, the easiest way to get the above code working would be to use a
> standard library implementation that provides a module map (for instance,
> build with -stdlib=libc++ -fmodules).

Let me see if I understand how this will work: if I build libc++ modules,
then '#include <string>' directives will be treated by Clang as module
imports and this will prevent the imported std::string declarations from
being all-exported from my module?

Also, from your previous replies I pieced together that one can use the
import declaration to import "header modules". So, theoretically, I
should be able to replace my '#include <string>' with something like
'import std.core' provided I build an appropriate .pcm?

Thanks,
Boris



More information about the cfe-dev mailing list