Discussion: C++ modules support
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
This came up in the context of building C and C++ sources in parallel. I don't see either an issue or a PR for it currently.
**Describe the feature request**
_If_ C / C++ sources are to be built in parallel, an exception would need to be made for C++20 modules, which need to be at minimum compiled to CMIs (roughly the equivalent of `.hi` files) before C++ sources that import them are compiled.
At present, only `clang++` supports separate compilation of CMIs, so we can't separate that phase out; moreover, `g++` doesn't use a distinct suffix for importable modules (`clang++` recommends `.cppm`), so source inspection would be necessary to distinguish modules.
There is also a question of whether we should attempt a topological sort of C++ module dependencies to ensure that modules are built in the correct order, or to push that onto the user by making them list them in the desired order in `c++-sources`. (That said, I seem to recall something in flight which [changes our storage of those into sets](https://github.com/haskell/cabal/pull/9843), which would mean we lose that ordering.)
**References**
Clang: https://clang.llvm.org/docs/StandardCPlusPlusModules.html
G++: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Modules.html
Contributor guide
Research direction
Start by reviewing the issue's Clang and GCC C++20 modules references, then inspect how c++-sources are represented and built in Cabal. The issue names no files or tests and leaves module detection, compilation ordering, and user ordering unresolved, so a concrete definition of done is not yet established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100