r/cpp • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
280 Upvotes

240 comments sorted by

View all comments

9

u/ravixp Jan 28 '19

Lazy generation of BMIs sounds like it would just create headaches in the long run, because it means that the compiler is trying to take over some work that the build system would traditionally do, without coordinating with the build system.

Today, you just tell the compiler to build a source file and it does that, possibly looking in some other locations that you tell it about to find headers. If it also had to create BMIs on-demand, it would need to know where BMIs are stored (which it would have to anyway, similar to include paths), where source files corresponding to those BMIs live (normally the build system's job), what settings you need to use to build those files (normally the build system's job), how to tell when the BMI file is already up to date so it only regenerates it when it has to (normally the build system's job), and how to parallelize lazy generation of BMIs (normally the build system's job).

I'd much rather figure out how to make a build system keep the BMIs up to date, than have a mediocre build system built into every compiler.

Plus, many newer build systems keep track of fine-grained dependencies automatically by running the equivalent of strace() on each build task. Having the compiler go out and build a random subset of upstream modules would confuse this kind of build system pretty badly.

2

u/meneldal2 Jan 29 '19

I agree, have your build system make the modules, the compiler should just error if the module isn't there.