Chaining clang::Modules

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Chaining clang::Modules

Axel Naumann
Hi!

I know I am walking on fragile grounds. But they are just too
interesting, so let me ask nonetheless :-)

I have a module core.pcm that contains Core.h. When generating big.pcm
(which contains Big.h which in turn #include-s Core.h) I want the
Preprocessor and the ASTWriter to make use of core.pcm - for instance to
not have to merge the modules when loading.

What's the best approach here? I don't manage to convince the ASTWriter
to use the chaining mechanism (in analogy to the chaining of PCHs); the
amount of registered "sub-"modules (core and big = 2) does not
correspond to the amount of modules written - which is only big.pcm
which does not have submodules and thus 1, as defined by ASTWriter's
getNumberOfModules().

It seems the ASTWriter expects me to create big.pcm as a super-module
with core.pcm as its submodule. The problem is that I will also generate
bigger.pcm and huge.pcm that would all like to reuse core.pcm, meaning
core.pcm is the submodule of many.

So is the submodule layout really appropriate here?

Cheers, Axel.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Chaining clang::Modules

Jordan Rose
I think you've got "submodules" mixed up with "dependencies". Submodules are modules stored within the same .pcm file and accessed as TopLevelModule.Submodule. Dependencies, on the other hand, are just other modules that the current module refers to and/or re-exports. So in your case, it sounds like "Big" is its own module with "Core" as a dependency.

The trick is that a pcm file can only be used if there is a module map that refers to the header file. So, for example, you could drop this module.map file in next to Core.h:

module Core {
header "Core.h"
export *
}

And then anything that does "#include <Core.h>" should pick up the module map...as long as you are compiling with -fmodules, of course. (I can't remember if '#include "Core.h"' will do it, nor '#include "path/to/Core.h"', but I would expect yes.)

Was that the missing piece?

Jordan


On Aug 12, 2013, at 6:41 , Axel Naumann <[hidden email]> wrote:

Hi!

I know I am walking on fragile grounds. But they are just too
interesting, so let me ask nonetheless :-)

I have a module core.pcm that contains Core.h. When generating big.pcm
(which contains Big.h which in turn #include-s Core.h) I want the
Preprocessor and the ASTWriter to make use of core.pcm - for instance to
not have to merge the modules when loading.

What's the best approach here? I don't manage to convince the ASTWriter
to use the chaining mechanism (in analogy to the chaining of PCHs); the
amount of registered "sub-"modules (core and big = 2) does not
correspond to the amount of modules written - which is only big.pcm
which does not have submodules and thus 1, as defined by ASTWriter's
getNumberOfModules().

It seems the ASTWriter expects me to create big.pcm as a super-module
with core.pcm as its submodule. The problem is that I will also generate
bigger.pcm and huge.pcm that would all like to reuse core.pcm, meaning
core.pcm is the submodule of many.

So is the submodule layout really appropriate here?

Cheers, Axel.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev