No, it could cache template instantiation needed for the entities defined in the module interface.
Edit: but an implementation could decide to (in a implementation defined fixed filenames) to cache template instantiation in a sort of binary format inside the build directory. But that could be done without modules.
zapcc essentially did just that, as I understand. This is also Rust's approach to improving compile times, since Rust has the technical equivalent of template instantiation overhead but dialed up to an 11.
zapcc pretty much died on the vine due to being a perennially out-dated proprietary fork of clang. Rust seems to be doing fairly well with their caching; they have their own de-facto-standardized build system that can play along however necessary, though, which probably helps.
Yup. This is exactly why compilers will be able to cache template instanciation: each compiler has an internal representation of an instantiated template. A common format would require parsing and transformation to the internal representative, making it slow.
Well, slow-er. Streaming data to/from a common binary format is not at all slow, but it depends on the in-memory format needing to be careful designed for serialization (which incidentally, tends to also mean that it's designed in a data-oriented fashion that makes use at run-time faster, too).
That said, the templates wouldn't be cached in the BMI because that would imply the BMI is mutable based on dependents, which would be bad, so the instantiation cache can be compiler/version specific while the BMI could still be a common format.
5
u/gracicot Jan 28 '19
A BMI could cache template instanciation.