C++ modules

Hello,

I'm totally new to Clang and LLVM, but I want to give it a try as a test platform for new C++ features. I'm mostly interested in the proposals around modifying the C++ build process to introduce the notion of modules, and I would need some help from people who know the architecture to look at the right places.

My first question is the following: Do you believe implementing modules in C++ can be done at the Clang level, or does it require changes to the LLVM level too?

Thank you,

Hello,

I'm totally new to Clang and LLVM, but I want to give it a try as a test
platform for new C++ features. I'm mostly interested in the proposals
around modifying the C++ build process to introduce the notion of
modules, and I would need some help from people who know the
architecture to look at the right places.

Most of the work I'm doing is in three places. The Serialization module, which takes care of serializing/deserializing an already-parsed AST, is the hardest part: it's the infrastructure that allows one to compile a module on its own, storing the serialized AST to disk, and then load that module into another translation unit later on. This part is likely to be the same regardless of how modules behave.

The module map part of the Lex module handles the mapping between headers and modules. It's mainly a transitional a little sub-language that allows one to describe the relationships between headers (which are used everywhere today) and modules.

The easy part is the parsing of module imports, labeling what is exported/hidden, and name-lookup semantics. It's also the part that people will want to discuss endlessly, so for now the various keywords are uglified so that we don't commit to any one syntax.

My first question is the following: Do you believe implementing modules
in C++ can be done at the Clang level, or does it require changes to the
LLVM level too?

The vast majority of the work will be at the Clang level, because all of the hard problems are there. It's possible that there will a tiny amount of work in LLVM in the future, e.g., to pass module-import information down to the linker, but that's gravy.

  - Doug

Most of the work I'm doing is in three places. The Serialization
module, which takes care of serializing/deserializing an
already-parsed AST, is the hardest part: it's the infrastructure that
allows one to compile a module on its own, storing the serialized AST
to disk, and then load that module into another translation unit
later on. This part is likely to be the same regardless of how
modules behave.

If I am the author of a module, am I expected to distribute the AST
files or will clang produce and cache them on the fly (or should their
creation be handled by the build system)?

- Doug

Thanks,
Rafael

Clang will produce and cache them on the fly.

  - Doug