0

I was reading clang modules documentation. I understood a few things, I don't know if i'm true or wrong.

  1. If I just pass -fmodules and -fbuiltin-module-map to every compiled source file as clang arguments, I will get every benefit of modules such as precompiled headers for standard includes, with 0 modifications, because of includes as imports.
  2. There is no need to use precompiled headers. If I stick with modules.

My question is this. How can I automatically precompile every header file? Should I generate modulemap with script for headers, so they will be precompiled? One giant modulemap or one modulemap for every header?

I don't really care about C++ standard committee modules plan or logical aspect of modules. All I need is compilation speedup achieved via precompiling headers, without need of creating precompiled.hpp file (with every possible header) or any huge modifications in the code.

EDIT: Modules in clang implement cache, so in my vision they are pretty similiar to precompiled headers in the sense of the compilation time speedup.

I don't care for committee for time being, because my question is about clang modules (not C++ standard modules), which I know are experimental and are subject of change. I know my risks.

I want to have faster compilation and I see possible route here to take, which IMHO seems to be better than other methods.

Inline
  • 2,566
  • 1
  • 16
  • 32
  • Well, modules are not precompiled headers, so it's not clear what your question is asking. Are you asking how to use Clang's "modules" support to automatically create modules/module-maps for every header in your project? Are you asking if there's some way for Clang to allow more than one PCH per source file? – Nicol Bolas Dec 01 '18 at 17:44
  • Also, you probably *should* care about the "standard committee's modules plan", since if Clang's module feature does track it, then it will change and potentially break all of your code (since the standard modules proposal doesn't appear to magically turn `#include`s into imports). – Nicol Bolas Dec 01 '18 at 17:47
  • @NicolBolas I edited question to clarify it for you :) – Inline Dec 01 '18 at 17:58

0 Answers0