[cfe-dev] [Modules TS] Have the file formats been decided?

Hamza Sood via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 17 14:45:08 PST 2017


Thanks for clarifying parts of the current implementation. I wasn’t sure what’s incomplete and what’s by design.

> Rather than producing two ASTs, it would be preferable to simply export less of the AST into the pcm file. As noted above, this optimization is not yet implemented (along with some of the semantics of the Modules TS).
Since it’s currently possible to generate a complete object file from a pcm, I assumed that such an optimisation wouldn't be possible with the current format. In fact a fully optimised pcm is pretty much what I was trying to describe here, but I wasn’t sure if being able to go from pcm -> obj is an essential part of what a pcm is.
Just writing less of the AST to a file is certainly better than producing two ASTs, and I attempted that with my original tests. However I wasn’t able to find anything in ASTWriter that lets you to control which parts of the AST are written; all I could get working is producing a second AST from the original (with modifications of course) and passing that through to ASTWriter. Is there an API that I missed?

> Clang's module files are explicitly not a distribution format. You are expected to ship your module interface files, not a precompiled form of them.
Would library developers want to ship their module interfaces considering they could potentially contain a lot of code?
Microsoft for example have come up with a distributable binary format so that library developers don’t have to ship their module interface files.

> Even with modules, large codebases will still want to maintain an interface / implementation separation discipline, in order to avoid every change to a low-level library's implementation triggering unnecessary recompilation of dependent code. (Keep in mind that a change that affects line numbers in a low-level library could affect the debug information generated for any transitive dependency, so we can't necessarily bail out of the compilation if the abstract interface of the module is unchanged.)
That brings up the question of how a module based build system would look, which I don’t think I’ve seen mentioned anywhere. Should the compiler be in charge by seeking out imported modules based on search paths and automatically building them if needed? Or should it be more like the dependency file generation that occurs with headers, which leaves a tool such as GNU make in charge?


More information about the cfe-dev mailing list