cabal
cabal copied to clipboard
Discussion: C++ modules support
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, 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
Note: this ticket is mostly to make it more discoverable than the discussion in the past two cabal calls. Also, I am unlikely to be involved in implementation, as while I contribute to a C++ project, I am in no sense a C++ developer.