[libcxx-commits] [libcxx] [libc++][RFC] Only include what is required by-version in the umbrella headers (PR #83740)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 9 04:12:17 PST 2024
mordante wrote:
> > As mentioned earlier I had a patch on Phab with a slightly different approach. So yes in general I like the idea of reducing the size of the includes.
> > I wonder about the approach you take; your examples only show how to handle granularized headers. I wonder what do you propose for non-granularized headers?
> > For example, `<ostream>` includes `<print>` the `<print>` header has been introduced in C++23. This header has some includes not used in `<ostream>`.
> > Do you propose to keep the `<ostream>` header unchanged or do you want to guard the include of `<print>` with C++23?
>
> I propose to either keep them unchanged, or to granularize it if we think it's worth the reduced include size. IIUC the main problem we have is `<format>` and the different `formatter` specializations that have to be provided through different headers resulting in huge amounts of transitive includes. Since they can be implemented separately from the rest of the files, we can simply move them into new detail headers and include these detail headers conditionally in the umbrella header. In essence, I want the only place where we conditionally include headers to be the umbrella headers.
I'm not sure how feasible splitting-off format would be. For example the `formatter` for `vector` needs to know about `vector`. IMO that is something we can look into for a separate patch if we want to solve these includes.
I think the approach you suggest is simple and easy to maintain. I think we could do more, but that might have an different maintenance trade-off. Taking this approach does not block other optimizations. So I'm happy to move forward with this direction.
https://github.com/llvm/llvm-project/pull/83740
More information about the libcxx-commits
mailing list