From 8c0f12c4aa4d3b6a83ea663f27d1affed61abcf6 Mon Sep 17 00:00:00 2001 From: tsecer harry Date: Tue, 20 Mar 2018 15:59:00 +0800 Subject: Makefile: Restore use of dependency scanning cache Since commit v2.8.0~27 (Major optimization of C/C++ dependency scanning, 2009-09-23) our `VaildDeps` cache of `depend.internal` content is supposed to avoid re-scanning dependencies of object files whose dependencies have not changed. However, this was broken by changes to `cmDependsC::WriteDependencies` by commit v3.1.0-rc1~272^2~1 (cmDepends: Refactor object file path conversion, 2014-07-22). The object file path written to `depend.internal` was changed to a relative path, but the lookup in the `ValidDeps` cache of that information was not updated too. Therefore the cache is not used. Fix the object file path used for the `ValidDeps` lookup to restore the original optimization. --- Source/cmDependsC.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 62bc8d9..34c0e94 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -96,9 +96,16 @@ bool cmDependsC::WriteDependencies(const std::set& sources, std::set dependencies; bool haveDeps = false; + std::string binDir = this->LocalGenerator->GetBinaryDirectory(); + + // Compute a path to the object file to write to the internal depend file. + // Any existing content of the internal depend file has already been + // loaded in ValidDeps with this path as a key. + std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj); + if (this->ValidDeps != nullptr) { std::map::const_iterator tmpIt = - this->ValidDeps->find(obj); + this->ValidDeps->find(obj_i); if (tmpIt != this->ValidDeps->end()) { dependencies.insert(tmpIt->second.begin(), tmpIt->second.end()); haveDeps = true; @@ -222,8 +229,6 @@ bool cmDependsC::WriteDependencies(const std::set& sources, // written by the original local generator for this directory // convert the dependencies to paths relative to the home output // directory. We must do the same here. - std::string binDir = this->LocalGenerator->GetBinaryDirectory(); - std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj); std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i); internalDepends << obj_i << std::endl; -- cgit v0.12