file (GET_RUNTIME_DEPENDENCIES) : inherited rpath behaviour
Seems to me there is an issue in cmBinUtilsLinuxELFLinker.cxx
with parent rpaths.
126 std::vector<std::string> searchPaths;
127 if (!runpaths.empty()) {
128 searchPaths = runpaths;
129 } else {
130 searchPaths = rpaths;
131 searchPaths.insert(searchPaths.end(), parentRpaths.begin(),
132 parentRpaths.end());
133 }
134
135 std::vector<std::string> ldConfigPaths;
136 if (!this->LDConfigTool->GetLDConfigPaths(ldConfigPaths)) {
137 return false;
138 }
139 searchPaths.insert(searchPaths.end(), ldConfigPaths.begin(),
140 ldConfigPaths.end());
141
142 for (auto const& dep : needed) {
143 if (!this->Archive->IsPreExcluded(dep)) {
144 std::string path;
145 bool resolved = false;
146 if (dep.find('/') != std::string::npos) {
147 this->SetError("Paths to dependencies are not supported");
148 return false;
149 }
150 if (!this->ResolveDependency(dep, searchPaths, path, resolved)) {
151 return false;
152 }
153 if (resolved) {
154 if (!this->Archive->IsPostExcluded(path)) {
155 bool unique;
156 this->Archive->AddResolvedPath(dep, path, unique);
157 if (unique && !this->ScanDependencies(path, rpaths)) {
158 return false;
159 }
160 }
161 } else {
162 this->Archive->AddUnresolvedPath(dep);
163 }
164 }
165 }
When trying to resolve needed dependencies, the rpaths passed through the ScanDependencies call (l.157) only include the current rpath entries, not the parents' ones.
Citing the documentation
1. If the depending file does not have any RUNPATH entries, and the library exists in one of the depending file's RPATH entries, or its parents', in that order, the dependency is resolved to that file.
2. Otherwise, if the depending file has any RUNPATH entries, and the library exists in one of those entries, the dependency is resolved to that file.
3. Otherwise, if the library exists in one of the directories listed by ldconfig, the dependency is resolved to that file.
4. Otherwise, if the library exists in one of the DIRECTORIES entries, the dependency is resolved to that file. In this case, a warning is issued, because finding a file in one of the DIRECTORIES means that the depending file is not complete (it does not list all the directories from which it pulls dependencies).
5. Otherwise, the dependency is unresolved.
the first entry will thus not be fully respected. The result then differs from what is returned by ldd
(using 'vanilla' env, meaning no LD_LIBRARY_PATH, no LD_RUN_PATH, etc.)
The l.130-132 should be rewritten as something like
rpaths.insert(rpaths.end(), parentRpaths.begin(),
parentRpaths.end())
searchPaths = rpaths;
If I'm not mistaken, I would be pleased to make my tribute by submitting a PR on this subject if asked.
Note : would be also pleased to work on a mecanism to output diagnostic messages on this step.
Edited by oleurodecision