Skip to content

[libc++] Per-header header modules #86193

@vgvassilev

Description

@vgvassilev

Commit 571178a introduces per header file module with a main motivation to enable detection of cyclic includes. This means that now, instead of having a single binary artifact std.pcm or similar we get hundreds of pcm files for the same content. That's problematic for us due to several reasons:

  • Makes modules redistribution harder -- we carry build artifacts across nodes and it makes it difficult to enumerate all stl-related modules including private ones.
  • Efficiency -- we care about binary size and in-memory footprint. Going for a many pcm files has an overhead. Consider we have several textual files (such as cassert). The textual content becomes duplicated in every pcm file and in all dependent pcm files too.

If the motivation is only to be able to diagnose cyclic includes we can do that as part of the build process of libc++. For example, echo "#include <libcxx/header>" | clang -xc++ -fsyntax-only - will be a sufficient check ensuring header consistency. Alternatively, we could have a "debug" modulemap with that structure.

If there is more motivation to the one I understood, I'd like to suggest having a separate modulemap, called std.modulemap which keeps the headers into a single pcm file and clients like us can use it instead. Note that the module std [system] { header "__std_clang_module" export * } does not work for us because it triggers building of all gazillion pcms.

@ian-twilightcoder, @ldionne, depending on the direction we get in this issue, I can work on creating the std.modulemap and opening a pull request.

cc: @hahnjo, @dpiparo, @ChuanqiXu9.

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header Moduleslibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions