Hi Denis, thanks for taking an active interest in the Swift Google Summer of Code project. Let me answer your questions:
- what exactly is the purpose of the swift module explorer and who'd be potential users of it?
A Swift Module is a serialized representation of the Swift AST - something we require because Swift doesn't have header files. The compiler is capable of emitting complete Swift Modules, or it is capable of outputting partial Swift Module files for (batched) incremental compilation and stitching those partial modules together into the final complete module. There's a lot of opportunities for different failure modes to arise during those processes. This Swift Module could serialize a broken or partial AST node, it could incorrectly form a cross-link to another declaration in a broken module, merging partial Swift modules might fail for a multitude of reasons, etc.
Serialization and Deserialization (the two components responsible for the bookkeeping for Swift Modules) are not well-instrumented to fail in loud and obvious ways (they're getting better though), leading to situations where we have to either reproduce with the entire setup that led to the creation of a broken module or in the few cases where it's blatantly obvious we can drop down to the
llvm-bcanalyzer tool and slog through a giant XML dump to e.g. pinpoint a broken crosslink.
As you can probably tell, the people this tool was envisioned for would be compiler engineers. If done in a more accessible way than just a command line tool - perhaps if it were exposed as a library that could be used to build a GUI tool, it might serve a more general-purpose educational role for the rest of our users.
- what exactly is the desired output in comparison to what
llvm-bcanalyzer doesn't do?
llvm-bcanalyzer is a very limited tool that is primarily meant for dumping bitstream files and stats about bitstream files. Its dump output is incredibly verbose, its verification powers are limited, and where they exist they do not help us accomplish our goal of identifying what is broken about a Swift module. Try dumping the standard library's
.swiftmodule file sometime to get a feel for how hard it is to work with.
To take another example, it's pretty rare that the verification part of
llmv-bcanalyzer would help us since Serialization and Deserialization use a C++ template-based DSL that guarantees we'll respect the bitstream file format and round-trip properly. So what matters to somebody working on those components is not what the bitstream file looks like, but whether the entities inside of it are consistent.
- is one interested in the API which module exposes and modules on which it depends on/imports?
Not particularly. The API surface of the module is a nice thing to be able to produce, sure, but as you note dumping that out of swift modules is already a facility we have in the compiler. In addition to the IDE dumping facility, the Swift Compiler can also generate Swift Interface files from a given Swift Module file, and does so today for most of the public SDK. Errors in Serialization or Deserialization often render these facilities useless for debugging because one or the other will usually crash before the module's contents can be read.
- present the
.swiftmodule file internal structure in a more "user-friendly" way?
This one is key. Having Swift-specific structured output would give us a lot of insights into a module file's higher-level structure and would be an enormous help to anybody that is trying to decipher anything about that structure.