On 18/04/2024 14:48, Ruben Perez via Boost wrote:
Hi all,
Following the recent discussion on Boost and C++20 modules, I've been performing further investigations on the possible benefits and costs of offering module support in Boost. I've summarized my findings here: https://anarthal.github.io/cppblog/modules2
Thank you Ruben for a nice summary. I've also been experimenting with modules in Regex - it's a smaller more confined effort than the one I also started in Math - but even so it's proved to be extremely time consuming and rather frustrating. The current state of play in the draft PR here: https://github.com/boostorg/regex/pull/174 is as follows: 1) It more or less works with latest MSVC and clang. Latest GCC fails hopelessly. 2) Build time improvements are similar to yours, time for a serial build of all the examples is 14s with modules and 38s with #includes. That excludes the module build time. I also had to move the most common template instances into module implementation files (these are hidden behind non-template factory functions) to see the speedup. 3) Tooling support for CI just plain sucks, I ended up writing batch and shell scripts just to test this. 4) It's ever so very flaky. For example I simply could not figure out the correct way to #include third party headers in module implementation units - this is not helped by different tutorials giving different answers to this issue. The only method that clang and msvc seem to agree on is: module; #include "third_Party.hpp" module boost.regex; // note not exported in implementation unit. I'm actually reasonably sure this is not legal code outside of the module definition. 5) Using the regex is an all or nothing affair, with msvc this works: import boost.regex; int main(int argc) { boost::regex e; return 0; } as does: import std; import boost.regex; int main(int argc) { boost::regex e; return 0; } But this blows up: #include <iostream> import boost.regex; int main(int argc) { boost::regex e; return 0; } This makes it literally impossible to port the main test program to test the module because it relies on third party headers which pull in std lib headers (ie other boost headers). I'm probably halting this for now... it's been a somewhat fun experiment, but I feel we need a few more compiler releases and better tooling before this can move forward, oh and a well written tutorial on modules which isn't full of misleading information. John.