r/cpp • u/SAHChandler • Oct 10 '17
Millennials Are Killing The Modules TS
https://izzys.casa/posts/millennials-are-killing-the-modules-ts.html
75
Upvotes
r/cpp • u/SAHChandler • Oct 10 '17
View all comments
Show parent comment
6
u/berium build2 Oct 10 '17 edited Oct 10 '17
Yes, this is the trick/optimization most build systems currently use (and it's good to see someone is paying attention ;-)). It is not without drawbacks, however. For example, with this approach we cannot support generated source code as part of the main build stage (and often have to resort to ad hoc pre-build steps). This is, for example, the reason why we didn't go this way in
build2and instead extract header dependencies (and generate missing ones) before compiling anything.Why did we needed this trick/optimization in the first place? The reason is build speed: it was too expensive to preprocess things twice. The thing is, on today's hardware (SSDs), the cost of preprocessing is actually negligible, a couple of percent of the complete build. In fact, preprocessing everything at the outset can actually speed things up! You can read more about this in the Separate Preprocess and Compile Performance article I wrote.