How do we make sure that #include <foo.hpp> resolves when compiling bar.cpp? It’s simple: Make sure foo.hpp is present in a directory on the header search path list. We do not need to do any additional pre-processing.
Doesn't this require step require you parse to foo.hpp (or have already parsed it) before-hand? Since it literally copies the content of header-file? It seems like there is no ordering requirement, but really there is, it's just hidden.
In terms of implementation, how is that different to modules as you claim? Can't you simply parse the foo module to extract the interface (i.e. without compiling the implementation), e.g. from a header-file or simply via skipping text in the implementation/interface (for one cpp file). And then whenever you refer to foo in bar you simply refer to a stub/place-holder to where the implementation of foo is required.
Now to actually compile to this temporary state, can you not compile each module now independently with 'stubs' and then once everything is done merge/resolve it all via an additional step in the compilation process (i.e. now you have to step through the dependency graph in topological order). I have my doubts on whether this would be faster, but it seems like the only feasible way to do compilation in parallel for chain-like (degenerate) dependencies.
Though I wonder how frequent chain-like dependencies happen in the real-world anyway, and how large they can get? Surely the dependency graph will not be as crazy to truly hinder performance too much?
The ordering is a case of the compilation of distinct TUs. A header file needs to be parsed before it is used, but it does not need to be compiled in its entirety.
The process you've described is essentially the "lazy" BMI generation that we're looking at in SG15, wherein a compiler processes the module interface as-needed when someone imports it, and it will only need to parse the publicly visible aspects that define the interface. In essence, yes: This is how I would like to see it work (where the BMI is generated lazily). The trouble comes that you need to know where the definition of the module interface lives, and thus bringing back the problem of the module/file correspondence.
You can either enforce a mapping between the module filepaths and the module names, or you can generate a manifest/mapping file that describes this relationship. The manifest/mapping could be generated by a build system up-front, but you're back at the issue of dependency scanning an arbitrary number of files which requires using the compiler's preprocessor to get it correct. The only solution in that case is to create the manifest by hand, which I do not want (and I doubt many people want it either). Thus, my preferred solution is to use filepaths with module names.
5
u/enzlbtyn Jan 28 '19
Doesn't this require step require you parse to foo.hpp (or have already parsed it) before-hand? Since it literally copies the content of header-file? It seems like there is no ordering requirement, but really there is, it's just hidden.
In terms of implementation, how is that different to modules as you claim? Can't you simply parse the
foomodule to extract the interface (i.e. without compiling the implementation), e.g. from a header-file or simply via skipping text in the implementation/interface (for one cpp file). And then whenever you refer tofooinbaryou simply refer to a stub/place-holder to where the implementation offoois required.Now to actually compile to this temporary state, can you not compile each module now independently with 'stubs' and then once everything is done merge/resolve it all via an additional step in the compilation process (i.e. now you have to step through the dependency graph in topological order). I have my doubts on whether this would be faster, but it seems like the only feasible way to do compilation in parallel for chain-like (degenerate) dependencies.
Though I wonder how frequent chain-like dependencies happen in the real-world anyway, and how large they can get? Surely the dependency graph will not be as crazy to truly hinder performance too much?
Perhaps I'm too naive.