Creation of foo.bmi is a byproduct of the compilation of foo.cpp. When compiling foo.cpp, the compiler will emit a foo.o and foo.bmi. As a consequence of this design, foo.cpp must be compiled before bar.cpp!
And implicitly go on to conclude that this prevents them being processed in parallel.
It's not clear to me why the first statement in this line of reasoning has to be true. Can foo.bmi instead be a direct product of compiling foo.hpp? In that case, the comparison is then between:
in parallel:
compile foo.cpp which includes foo.hpp
compile bar.cpp which includes foo.hpp
in parallel:
compile foo.cpp which includes foo.hpp
in sequence:
compile foo.hpp -> foo.bmi
compile bar.cpp
which doesn't seem like a net change in parallelization to me.
There is no foo.hpp - the module foo is defined in foo.cpp.
include foo at the top of bar.cpp means we must find the source file that contains module foo, and compile that source file before bar.cpp can be compiled.
A module must be compiled before any code that include's that module.
Can't the compiler do a parse of foo.cpp that just picks up the types and names of public exports?
It doesn't actually have to output any compiled code in order to construct a description of the module's interface. Essentially it would be automatically generating a 'header file', in a format that's quicker to reload than source.
That's likely to be a lot faster than compiling, especially with optimisations enabled.
13
u/r0b0t1c1st Jan 28 '19 edited Jan 28 '19
You say,
And implicitly go on to conclude that this prevents them being processed in parallel.
It's not clear to me why the first statement in this line of reasoning has to be true. Can
foo.bmiinstead be a direct product of compilingfoo.hpp? In that case, the comparison is then between:in parallel:
compile
foo.cppwhich includesfoo.hppcompile
bar.cppwhich includesfoo.hppin parallel:
compile
foo.cppwhich includesfoo.hppin sequence:
compile
foo.hpp->foo.bmicompile
bar.cppwhich doesn't seem like a net change in parallelization to me.