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

Boris Kolpackov via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 29 00:13:35 PDT 2017


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

> I don't think we need a mapping mechanism; giving us the module files on
> the command line in topological order should suffice. If we've already been
> handed a module file for module X, and then we load a module file for
> module Y that depends on X, we can simply ignore the path specified in Y's
> .pcm and just use the existing X .pcm. (We'd still perform the check that
> the X .pcm is the same as the one that Y was built against in this case.)

I've done some testing and this is not how it works today. Perhaps you
meant it in the "could be done this way" sense.

BTW, I've also tested moving the entire build directory somewhere else
to check if .pcm's store relative paths to each other. This does not
appear to work either:

fatal error: malformed or corrupted AST file: 'SourceLocation remap refers to unknown module, cannot find core.pcm'

On the more fundamental level, this still poses a problem if the build
system needs to re-map all the .pcm files (e.g., for a distributed build):
we will still have crazy-long command lines and may hit the command line
limits. So, at a minimum, we seem to need a way to load the list of modules
from a file.

Now, for why we may want a mapping, not just a list of .pcm's: if the list
of .pcm's is stored in a file, then chances are some build systems will
opt to have one file per project (or some similar granularity) rather
than per translation unit. Which means not all listed .pcm's will be
needed during every compilation. If it's only a list of .pcm's, then
Clang will have to at least read each file, which seems like a waste.


> We could actually build the topological ordering ourselves, but that would
> require a two-pass approach for loading .pcm files; passing this burden on
> to the build system seems like the better tradeoff.

I agree. Though requiring a sorted list of modules doesn't make build
system's life any easier, especially if it wants to weed out duplicates
(to keep the command line as tidy as possible) and not allocate any
extra memory while doing it.

Boris



More information about the cfe-dev mailing list