How to generate module map for compilation database? #1979
-
Recently i watched a fantastic talk from @dmpolukhin named 2023 LLVM Dev Mtg - Improving clangd document open time with preamble caching. Dmitry mentioned some unbelievable speed up in reopening time in clangd - from 120s to 3s. I would like to reproduce this result on my own project. But my knowledge in c++ modules is limited. Could you please help me to figure out how to generate c++ module map and inject it into compilation database for clangd? I guess, module map will be just a file with all headers used in my project. And this file will be injected in compile_commands.json using -fmodule-map-file command. If it's correct the question is how to generate such file. My current setup is: cmake 3.28, g++ (for build), clangd 18. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@Genomorf we use Python script that extracts all
Instead of implementing include resolver in a script you can add compiler option Unfortunately, other urgent things get me destructed from implementing cache inside clangd itself but I still plan to work on this. |
Beta Was this translation helpful? Give feedback.
@Genomorf we use Python script that extracts all
#include
directives from the file, resolves them to real files using include paths from CDB, makes them relative to the directory where you will generate modulemap file like this:Instead of implementing include resolver in a script you can add compiler option
-H
and run only preprocessor on the file and it will print include graph, files on the first level of the graph is what you need. After that you will need to inject the module and other options see full list on the last backup slide.Unfortunately, other urgent things get…