C++ Logo


Advanced search

Re: [SG15] Will any change in a module source or dependencies cause change in the public/reachable surface of the built module?

From: Olga Arkhipova <olgaark_at_[hidden]>
Date: Wed, 31 Jul 2019 19:30:43 +0000
Any thoughts on this?

From: Olga Arkhipova
Sent: Thursday, July 18, 2019 2:14 PM
To: Hernandez, Gerardo <Gerardo.Hernandez_at_[hidden]>; nathan_at_[hidden]; Gabriel Dos Reis <gdr_at_[hidden]>; Cameron DaCamara <Cameron.DaCamara_at_[hidden]>; Gor Nishanov <gorn_at_[hidden]>; Richard Smith <richardsmith_at_[hidden]>; blopes_at_[hidden]
Cc: sg15_at_[hidden]
Subject: Will any change in a module source or dependencies cause change in the public/reachable surface of the built module?

Hi all,
This question came as a part of the discussion with Gerardo and Nathan (see attached).

Geraldo and I assumed that compilers and build systems will be able to detect somehow that adding, say, a comment to a module source should not cause rebuild of all components which depend on this module. This is currently the case for other languages (like c# and java, which have declarations and implementation in one binary, so they had to figure out which changes affect the dependent components and which do not).

Nathan and Gaby pointed out that currently built modules contain locations (line/pos I assume) of the declarations in the source file(s), so pretty much any change in the module sources and dependencies (except maybe very trivial ones) will produce a different CMI (CMI is new name for BMI).

You can argue that module CMI change when source changes will cause the same rebuild of the dependent components as a header file before. This is probably true, but with header files we did not really have an option. With modules, it seems to be a possibility to do better. Also, when a header file changes, all source files which #include it (directly or indirectly) can potentially be built in parallel. With modules, we can only build dependent modules sequentially, and the sooner we realize that we don't really have to rebuild some components, the better we (users, actually) are.

So I am wondering what people think about the following questions:

  1. Is it worth investigating? If we do nothing, we’ll be rebuilding the same components as we’d do for a header file change. Which is often more that it really should be.
  2. Is it actually feasible to detect that public/reachable surface of a built module has not changed for some source/dependencies changes? In other words, can compiler produce some sort of a hash only for the public/reachable surface of a built module (not the whole CMI)?


Received on 2019-07-31 14:32:44