How to precompile every header file?

329 views Asked by At

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.

0

There are 0 answers