fix: re-resolve module imports before checking staleness
Adding a data member to a class in a module interface did not rebuild every object compiled against the old layout. The build succeeded with no error or warning and the resulting binary mixed both layouts, surfacing later as a SIGSEGV in a destructor. GetInterfacesAndImplementations scans a TU's `import X;` statements when the source is declared. An import that matches neither a module in the Configuration nor one reachable through `dependencies` was dropped on the floor, leaving that TU with no staleness edge to the interface it consumes. `dependencies` is frequently assigned *after* the scan — AddTest does exactly that, resolving tests/<name>/main.cpp and only then returning a builder whose .Dependencies() supplies the library — so consumers of a dependency's modules routinely carried no edge at all. A layout change then rebuilt the library, relinked the consumer, and kept the consumer's object as it was. Unresolved names are now remembered on the partition/implementation as pendingImports, and Configuration::ResolvePendingImports retries them against the dependency DAG as it stands. Build() calls it immediately before comparing mtimes, which closes the window for every caller rather than only the ones that declare in the right order; TestBuilder::Dependencies also calls it so the Configuration is coherent for anyone inspecting it before the build. Resolves #27
This commit is contained in:
parent
8892154b28
commit
13697cd026
11 changed files with 341 additions and 7 deletions
|
|
@ -483,6 +483,14 @@ TestBuilder& TestBuilder::Args(std::vector<std::string> a) { Ref().args = std::
|
|||
TestBuilder& TestBuilder::Requires(std::string r) { Ref().requires_.push_back(std::move(r)); return *this; }
|
||||
TestBuilder& TestBuilder::Dependencies(std::vector<Configuration*> d) {
|
||||
Ref().config.dependencies = std::move(d);
|
||||
// AddTest already scanned tests/<name>/main.cpp, at which point this test
|
||||
// had no dependencies, so every `import <DepModule>;` in it came back
|
||||
// unresolved. Place them now that the libraries are known — without this
|
||||
// the test's object carries no staleness edge to the interfaces it consumes
|
||||
// and survives a layout change to them (issue #27). Build() re-runs the
|
||||
// same sweep as a backstop; doing it here keeps the Configuration coherent
|
||||
// for anyone inspecting it before the build.
|
||||
Ref().config.ResolvePendingImports();
|
||||
return *this;
|
||||
}
|
||||
TestBuilder& TestBuilder::LinkFlag(std::string f) { Ref().config.linkFlags.push_back(std::move(f)); return *this; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue