blob: 26352196887100ca8d9ce8bdaa344b71b36161e6 [file] [log] [blame] [view]
Erik Staabfd0792a2024-07-12 13:02:211# Clang and C++ Modules in Chromium
2
3## Overview
4
5Modules in C++ have the potential to significantly speed up building Chromium.
6With textual inclusion, many headers are re-parsed over
7[35000 times](https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html)
8and with modules could be reduced to the order of 10 times.
9
10Clang supports two types of modules:
11[Clang header modules](https://clang.llvm.org/docs/Modules.html) and
12[C++20 modules](https://clang.llvm.org/docs/StandardCPlusPlusModules.html) (also
13called Clang Modules and Standard C++ Modules). We're currently exploring Clang
14header modules because:
151. Other projects (e.g. internally at Google) have had success deploying them to
16their code bases with large performance wins.
172. They can be experimented with without rewrites to the code base or changes to
18the build system.
19
20We're currently experimenting with modules for libc++ and they can be enabled
Takuto Ikuta637a4d92025-07-16 01:53:4221with the GN arg `use_clang_modules. Using this arg is not currently
Matt Starka1ff53c2025-05-30 04:07:0522recommended, due to the limitations mentioned below.
Takuto Ikuta7d1b2b0b2025-02-05 06:53:2223It is only interesting to people working on the feature.
Erik Staabfd0792a2024-07-12 13:02:2124
25## Current limitations
26
Erik Staabfd0792a2024-07-12 13:02:2127### Performance
28
29With Chrome's Clang plugins turned on, modules perform worse than without
Matt Starka1ff53c2025-05-30 04:07:0530modules ([crbug.com/351909443](https://crbug.com/351909443)).
Erik Staabfd0792a2024-07-12 13:02:2131
Matt Starka1ff53c2025-05-30 04:07:0532### Configurations
33
34Clang modules don't play nice with code with RTTI / exceptions depending on
35code without, and vice versa. Work is ongoing to fix this, but for now, it
36remains a problem ([crbug.com/403415459](https://crbug.com/403415459)).
Erik Staabfd0792a2024-07-12 13:02:2137
38### Correctness
39
Matt Starka1ff53c2025-05-30 04:07:0540The configurations issue above can cause unexpected build failures.