Propagate backtraces from LINK_LIBRARIES through to link line items

Since commit d4d0dd0f6a (cmLinkLineComputer: Add ComputeLinkLibs
overload with backtraces, 2019-09-13, v3.16.0-rc1~87^2~4), backtraces
have been collected by `ComputeLinkLibs` by looking back through the
link implementation libraries for one matching the text of the link line
item.  This is slow in projects with long link lines.

Instead, teach `cmComputeLinkDepends` and `cmComputeLinkInformation` to
carry backtrace information explicitly along with the text of each item.

Fixes: #20322
This commit is contained in:
Brad King
2020-02-10 13:34:33 -05:00
parent 44b8937b76
commit e756328434
9 changed files with 85 additions and 93 deletions
+9 -8
View File
@@ -301,11 +301,11 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
// Initialize the item entry. // Initialize the item entry.
int index = lei->second; int index = lei->second;
LinkEntry& entry = this->EntryList[index]; LinkEntry& entry = this->EntryList[index];
entry.Item = item.AsStr(); entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
entry.Target = item.Target; entry.Target = item.Target;
entry.IsFlag = entry.IsFlag = (!entry.Target && entry.Item.Value[0] == '-' &&
(!entry.Target && entry.Item[0] == '-' && entry.Item[1] != 'l' && entry.Item.Value[1] != 'l' &&
entry.Item.substr(0, 10) != "-framework"); entry.Item.Value.substr(0, 10) != "-framework");
// If the item has dependencies queue it to follow them. // If the item has dependencies queue it to follow them.
if (entry.Target) { if (entry.Target) {
@@ -314,7 +314,7 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
this->BFSQueue.push(qe); this->BFSQueue.push(qe);
} else { } else {
// Look for an old-style <item>_LIB_DEPENDS variable. // Look for an old-style <item>_LIB_DEPENDS variable.
std::string var = cmStrCat(entry.Item, "_LIB_DEPENDS"); std::string var = cmStrCat(entry.Item.Value, "_LIB_DEPENDS");
if (const char* val = this->Makefile->GetDefinition(var)) { if (const char* val = this->Makefile->GetDefinition(var)) {
// The item dependencies are known. Follow them. // The item dependencies are known. Follow them.
BFSEntry qe = { index, val }; BFSEntry qe = { index, val };
@@ -396,7 +396,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// Initialize the item entry. // Initialize the item entry.
LinkEntry& entry = this->EntryList[lei->second]; LinkEntry& entry = this->EntryList[lei->second];
entry.Item = dep.Item.AsStr(); entry.Item = BT<std::string>(dep.Item.AsStr(), dep.Item.Backtrace);
entry.Target = dep.Item.Target; entry.Target = dep.Item.Target;
// This item was added specifically because it is a dependent // This item was added specifically because it is a dependent
@@ -671,7 +671,8 @@ void cmComputeLinkDepends::DisplayComponents()
fprintf(stderr, "Component (%u):\n", c); fprintf(stderr, "Component (%u):\n", c);
NodeList const& nl = components[c]; NodeList const& nl = components[c];
for (int i : nl) { for (int i : nl) {
fprintf(stderr, " item %d [%s]\n", i, this->EntryList[i].Item.c_str()); fprintf(stderr, " item %d [%s]\n", i,
this->EntryList[i].Item.Value.c_str());
} }
EdgeList const& ol = this->CCG->GetComponentGraphEdges(c); EdgeList const& ol = this->CCG->GetComponentGraphEdges(c);
for (cmGraphEdge const& oi : ol) { for (cmGraphEdge const& oi : ol) {
@@ -819,7 +820,7 @@ void cmComputeLinkDepends::DisplayFinalEntries()
if (lei.Target) { if (lei.Target) {
fprintf(stderr, " target [%s]\n", lei.Target->GetName().c_str()); fprintf(stderr, " target [%s]\n", lei.Target->GetName().c_str());
} else { } else {
fprintf(stderr, " item [%s]\n", lei.Item.c_str()); fprintf(stderr, " item [%s]\n", lei.Item.Value.c_str());
} }
} }
fprintf(stderr, "\n"); fprintf(stderr, "\n");
+2 -1
View File
@@ -15,6 +15,7 @@
#include "cmGraphAdjacencyList.h" #include "cmGraphAdjacencyList.h"
#include "cmLinkItem.h" #include "cmLinkItem.h"
#include "cmListFileCache.h"
#include "cmTargetLinkLibraryType.h" #include "cmTargetLinkLibraryType.h"
class cmComputeComponentGraph; class cmComputeComponentGraph;
@@ -39,7 +40,7 @@ public:
// Basic information about each link item. // Basic information about each link item.
struct LinkEntry struct LinkEntry
{ {
std::string Item; BT<std::string> Item;
cmGeneratorTarget const* Target = nullptr; cmGeneratorTarget const* Target = nullptr;
bool IsSharedDep = false; bool IsSharedDep = false;
bool IsFlag = false; bool IsFlag = false;
+42 -40
View File
@@ -603,7 +603,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
} }
} }
void cmComputeLinkInformation::AddItem(std::string const& item, void cmComputeLinkInformation::AddItem(BT<std::string> const& item,
cmGeneratorTarget const* tgt) cmGeneratorTarget const* tgt)
{ {
// Compute the proper name to use to link this library. // Compute the proper name to use to link this library.
@@ -629,7 +629,8 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
std::string exe = tgt->GetFullPath(config, artifact, true); std::string exe = tgt->GetFullPath(config, artifact, true);
linkItem += exe; linkItem += exe;
this->Items.emplace_back(linkItem, true, tgt); this->Items.emplace_back(BT<std::string>(linkItem, item.Backtrace), true,
tgt);
this->Depends.push_back(std::move(exe)); this->Depends.push_back(std::move(exe));
} else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { } else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Add the interface library as an item so it can be considered as part // Add the interface library as an item so it can be considered as part
@@ -640,7 +641,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
// Also add the item the interface specifies to be used in its place. // Also add the item the interface specifies to be used in its place.
std::string const& libName = tgt->GetImportedLibName(config); std::string const& libName = tgt->GetImportedLibName(config);
if (!libName.empty()) { if (!libName.empty()) {
this->AddItem(libName, nullptr); this->AddItem(BT<std::string>(libName, item.Backtrace), nullptr);
} }
} else if (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) { } else if (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
// Ignore object library! // Ignore object library!
@@ -652,8 +653,9 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
: cmStateEnums::RuntimeBinaryArtifact; : cmStateEnums::RuntimeBinaryArtifact;
// Pass the full path to the target file. // Pass the full path to the target file.
std::string lib = tgt->GetFullPath(config, artifact, true); BT<std::string> lib = BT<std::string>(
if (tgt->Target->IsAIX() && cmHasLiteralSuffix(lib, "-NOTFOUND") && tgt->GetFullPath(config, artifact, true), item.Backtrace);
if (tgt->Target->IsAIX() && cmHasLiteralSuffix(lib.Value, "-NOTFOUND") &&
artifact == cmStateEnums::ImportLibraryArtifact) { artifact == cmStateEnums::ImportLibraryArtifact) {
// This is an imported executable on AIX that has ENABLE_EXPORTS // This is an imported executable on AIX that has ENABLE_EXPORTS
// but not IMPORTED_IMPLIB. CMake used to produce and accept such // but not IMPORTED_IMPLIB. CMake used to produce and accept such
@@ -664,23 +666,23 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
} }
if (!this->LinkDependsNoShared || if (!this->LinkDependsNoShared ||
tgt->GetType() != cmStateEnums::SHARED_LIBRARY) { tgt->GetType() != cmStateEnums::SHARED_LIBRARY) {
this->Depends.push_back(lib); this->Depends.push_back(lib.Value);
} }
this->AddTargetItem(lib, tgt); this->AddTargetItem(lib, tgt);
this->AddLibraryRuntimeInfo(lib, tgt); this->AddLibraryRuntimeInfo(lib.Value, tgt);
} }
} else { } else {
// This is not a CMake target. Use the name given. // This is not a CMake target. Use the name given.
if (cmSystemTools::FileIsFullPath(item)) { if (cmSystemTools::FileIsFullPath(item.Value)) {
if (cmSystemTools::FileIsDirectory(item)) { if (cmSystemTools::FileIsDirectory(item.Value)) {
// This is a directory. // This is a directory.
this->AddDirectoryItem(item); this->AddDirectoryItem(item.Value);
} else { } else {
// Use the full path given to the library file. // Use the full path given to the library file.
this->Depends.push_back(item); this->Depends.push_back(item.Value);
this->AddFullItem(item); this->AddFullItem(item);
this->AddLibraryRuntimeInfo(item); this->AddLibraryRuntimeInfo(item.Value);
} }
} else { } else {
// This is a library or option specified by the user. // This is a library or option specified by the user.
@@ -689,7 +691,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
} }
} }
void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, void cmComputeLinkInformation::AddSharedDepItem(BT<std::string> const& item,
const cmGeneratorTarget* tgt) const cmGeneratorTarget* tgt)
{ {
// If dropping shared library dependencies, ignore them. // If dropping shared library dependencies, ignore them.
@@ -708,12 +710,12 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
} else { } else {
// Skip items that are not full paths. We will not be able to // Skip items that are not full paths. We will not be able to
// reliably specify them. // reliably specify them.
if (!cmSystemTools::FileIsFullPath(item)) { if (!cmSystemTools::FileIsFullPath(item.Value)) {
return; return;
} }
// Get the name of the library from the file name. // Get the name of the library from the file name.
std::string file = cmSystemTools::GetFilenameName(item); std::string file = cmSystemTools::GetFilenameName(item.Value);
if (!this->ExtractSharedLibraryName.find(file)) { if (!this->ExtractSharedLibraryName.find(file)) {
// This is not the name of a shared library. // This is not the name of a shared library.
return; return;
@@ -737,7 +739,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
lib = tgt->GetFullPath(this->Config, artifact); lib = tgt->GetFullPath(this->Config, artifact);
this->AddLibraryRuntimeInfo(lib, tgt); this->AddLibraryRuntimeInfo(lib, tgt);
} else { } else {
lib = item; lib = item.Value;
this->AddLibraryRuntimeInfo(lib); this->AddLibraryRuntimeInfo(lib);
} }
@@ -994,7 +996,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
} }
} }
void cmComputeLinkInformation::AddTargetItem(std::string const& item, void cmComputeLinkInformation::AddTargetItem(BT<std::string> const& item,
cmGeneratorTarget const* target) cmGeneratorTarget const* target)
{ {
// This is called to handle a link item that is a full path to a target. // This is called to handle a link item that is a full path to a target.
@@ -1015,7 +1017,7 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
// Handle case of an imported shared library with no soname. // Handle case of an imported shared library with no soname.
if (this->NoSONameUsesPath && if (this->NoSONameUsesPath &&
target->IsImportedSharedLibWithoutSOName(this->Config)) { target->IsImportedSharedLibWithoutSOName(this->Config)) {
this->AddSharedLibNoSOName(item); this->AddSharedLibNoSOName(item.Value);
return; return;
} }
@@ -1023,23 +1025,23 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
// the linker search path. // the linker search path.
if (this->OldLinkDirMode && !target->IsFrameworkOnApple() && if (this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
!cmContains(this->OldLinkDirMask, !cmContains(this->OldLinkDirMask,
cmSystemTools::GetFilenamePath(item))) { cmSystemTools::GetFilenamePath(item.Value))) {
this->OldLinkDirItems.push_back(item); this->OldLinkDirItems.push_back(item.Value);
} }
// Now add the full path to the library. // Now add the full path to the library.
this->Items.emplace_back(item, true, target); this->Items.emplace_back(item, true, target);
} }
void cmComputeLinkInformation::AddFullItem(std::string const& item) void cmComputeLinkInformation::AddFullItem(BT<std::string> const& item)
{ {
// Check for the implicit link directory special case. // Check for the implicit link directory special case.
if (this->CheckImplicitDirItem(item)) { if (this->CheckImplicitDirItem(item.Value)) {
return; return;
} }
// Check for case of shared library with no builtin soname. // Check for case of shared library with no builtin soname.
if (this->NoSONameUsesPath && this->CheckSharedLibNoSOName(item)) { if (this->NoSONameUsesPath && this->CheckSharedLibNoSOName(item.Value)) {
return; return;
} }
@@ -1049,9 +1051,9 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
if (this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && if (this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
(generator.find("Visual Studio") != std::string::npos || (generator.find("Visual Studio") != std::string::npos ||
generator.find("Xcode") != std::string::npos)) { generator.find("Xcode") != std::string::npos)) {
std::string file = cmSystemTools::GetFilenameName(item); std::string file = cmSystemTools::GetFilenameName(item.Value);
if (!this->ExtractAnyLibraryName.find(file)) { if (!this->ExtractAnyLibraryName.find(file)) {
this->HandleBadFullItem(item, file); this->HandleBadFullItem(item.Value, file);
return; return;
} }
} }
@@ -1063,10 +1065,10 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// static libraries. If a previous user item changed the link type // static libraries. If a previous user item changed the link type
// to static we need to make sure it is back to shared. // to static we need to make sure it is back to shared.
if (this->LinkTypeEnabled) { if (this->LinkTypeEnabled) {
std::string name = cmSystemTools::GetFilenameName(item); std::string name = cmSystemTools::GetFilenameName(item.Value);
if (this->ExtractSharedLibraryName.find(name)) { if (this->ExtractSharedLibraryName.find(name)) {
this->SetCurrentLinkType(LinkShared); this->SetCurrentLinkType(LinkShared);
} else if (!this->ExtractStaticLibraryName.find(item)) { } else if (!this->ExtractStaticLibraryName.find(item.Value)) {
// We cannot determine the type. Assume it is the target's // We cannot determine the type. Assume it is the target's
// default type. // default type.
this->SetCurrentLinkType(this->StartLinkType); this->SetCurrentLinkType(this->StartLinkType);
@@ -1077,8 +1079,8 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// the linker search path. // the linker search path.
if (this->OldLinkDirMode && if (this->OldLinkDirMode &&
!cmContains(this->OldLinkDirMask, !cmContains(this->OldLinkDirMask,
cmSystemTools::GetFilenamePath(item))) { cmSystemTools::GetFilenamePath(item.Value))) {
this->OldLinkDirItems.push_back(item); this->OldLinkDirItems.push_back(item.Value);
} }
// Now add the full path to the library. // Now add the full path to the library.
@@ -1142,7 +1144,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
return true; return true;
} }
void cmComputeLinkInformation::AddUserItem(std::string const& item, void cmComputeLinkInformation::AddUserItem(BT<std::string> const& item,
bool pathNotKnown) bool pathNotKnown)
{ {
// This is called to handle a link item that does not match a CMake // This is called to handle a link item that does not match a CMake
@@ -1154,14 +1156,14 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// libfoo.a ==> -Wl,-Bstatic -lfoo // libfoo.a ==> -Wl,-Bstatic -lfoo
// Pass flags through untouched. // Pass flags through untouched.
if (item[0] == '-' || item[0] == '$' || item[0] == '`') { if (item.Value[0] == '-' || item.Value[0] == '$' || item.Value[0] == '`') {
// if this is a -l option then we might need to warn about // if this is a -l option then we might need to warn about
// CMP0003 so put it in OldUserFlagItems, if it is not a -l // CMP0003 so put it in OldUserFlagItems, if it is not a -l
// or -Wl,-l (-framework -pthread), then allow it without a // or -Wl,-l (-framework -pthread), then allow it without a
// CMP0003 as -L will not affect those other linker flags // CMP0003 as -L will not affect those other linker flags
if (item.find("-l") == 0 || item.find("-Wl,-l") == 0) { if (item.Value.find("-l") == 0 || item.Value.find("-Wl,-l") == 0) {
// This is a linker option provided by the user. // This is a linker option provided by the user.
this->OldUserFlagItems.push_back(item); this->OldUserFlagItems.push_back(item.Value);
} }
// Restore the target link type since this item does not specify // Restore the target link type since this item does not specify
@@ -1184,7 +1186,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// libraries. On AIX a library with the name libfoo.a can be // libraries. On AIX a library with the name libfoo.a can be
// shared! // shared!
std::string lib; std::string lib;
if (this->ExtractSharedLibraryName.find(item)) { if (this->ExtractSharedLibraryName.find(item.Value)) {
// This matches a shared library file name. // This matches a shared library file name.
#ifdef CM_COMPUTE_LINK_INFO_DEBUG #ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "shared regex matched [%s] [%s] [%s]\n", fprintf(stderr, "shared regex matched [%s] [%s] [%s]\n",
@@ -1197,7 +1199,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// Use just the library name so the linker will search. // Use just the library name so the linker will search.
lib = this->ExtractSharedLibraryName.match(2); lib = this->ExtractSharedLibraryName.match(2);
} else if (this->ExtractStaticLibraryName.find(item)) { } else if (this->ExtractStaticLibraryName.find(item.Value)) {
// This matches a static library file name. // This matches a static library file name.
#ifdef CM_COMPUTE_LINK_INFO_DEBUG #ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "static regex matched [%s] [%s] [%s]\n", fprintf(stderr, "static regex matched [%s] [%s] [%s]\n",
@@ -1210,7 +1212,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
// Use just the library name so the linker will search. // Use just the library name so the linker will search.
lib = this->ExtractStaticLibraryName.match(2); lib = this->ExtractStaticLibraryName.match(2);
} else if (this->ExtractAnyLibraryName.find(item)) { } else if (this->ExtractAnyLibraryName.find(item.Value)) {
// This matches a library file name. // This matches a library file name.
#ifdef CM_COMPUTE_LINK_INFO_DEBUG #ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "any regex matched [%s] [%s] [%s]\n", fprintf(stderr, "any regex matched [%s] [%s] [%s]\n",
@@ -1227,19 +1229,19 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
} else { } else {
// This is a name specified by the user. // This is a name specified by the user.
if (pathNotKnown) { if (pathNotKnown) {
this->OldUserFlagItems.push_back(item); this->OldUserFlagItems.push_back(item.Value);
} }
// We must ask the linker to search for a library with this name. // We must ask the linker to search for a library with this name.
// Restore the target link type since this item does not specify // Restore the target link type since this item does not specify
// one. // one.
this->SetCurrentLinkType(this->StartLinkType); this->SetCurrentLinkType(this->StartLinkType);
lib = item; lib = item.Value;
} }
// Create an option to ask the linker to search for the library. // Create an option to ask the linker to search for the library.
std::string out = cmStrCat(this->LibLinkFlag, lib, this->LibLinkSuffix); std::string out = cmStrCat(this->LibLinkFlag, lib, this->LibLinkSuffix);
this->Items.emplace_back(out, false); this->Items.emplace_back(BT<std::string>(out, item.Backtrace), false);
// Here we could try to find the library the linker will find and // Here we could try to find the library the linker will find and
// add a runtime information entry for it. It would probably not be // add a runtime information entry for it. It would probably not be
@@ -1269,7 +1271,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
this->AddLibraryRuntimeInfo(full_fw); this->AddLibraryRuntimeInfo(full_fw);
// Add the item using the -framework option. // Add the item using the -framework option.
this->Items.emplace_back("-framework", false); this->Items.emplace_back(std::string("-framework"), false);
cmOutputConverter converter(this->Makefile->GetStateSnapshot()); cmOutputConverter converter(this->Makefile->GetStateSnapshot());
fw = converter.EscapeForShell(fw); fw = converter.EscapeForShell(fw);
this->Items.emplace_back(fw, false); this->Items.emplace_back(fw, false);
+11 -9
View File
@@ -13,13 +13,13 @@
#include "cmsys/RegularExpression.hxx" #include "cmsys/RegularExpression.hxx"
#include "cmListFileCache.h"
class cmGeneratorTarget; class cmGeneratorTarget;
class cmGlobalGenerator; class cmGlobalGenerator;
class cmMakefile; class cmMakefile;
class cmOrderDirectories; class cmOrderDirectories;
class cmake; class cmake;
template <typename T>
class BT;
/** \class cmComputeLinkInformation /** \class cmComputeLinkInformation
* \brief Compute link information for a target in one configuration. * \brief Compute link information for a target in one configuration.
@@ -35,13 +35,13 @@ public:
struct Item struct Item
{ {
Item() = default; Item() = default;
Item(std::string v, bool p, cmGeneratorTarget const* target = nullptr) Item(BT<std::string> v, bool p, cmGeneratorTarget const* target = nullptr)
: Value(std::move(v)) : Value(std::move(v))
, IsPath(p) , IsPath(p)
, Target(target) , Target(target)
{ {
} }
std::string Value; BT<std::string> Value;
bool IsPath = true; bool IsPath = true;
cmGeneratorTarget const* Target = nullptr; cmGeneratorTarget const* Target = nullptr;
}; };
@@ -74,8 +74,9 @@ public:
const cmGeneratorTarget* GetTarget() { return this->Target; } const cmGeneratorTarget* GetTarget() { return this->Target; }
private: private:
void AddItem(std::string const& item, const cmGeneratorTarget* tgt); void AddItem(BT<std::string> const& item, const cmGeneratorTarget* tgt);
void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt); void AddSharedDepItem(BT<std::string> const& item,
cmGeneratorTarget const* tgt);
// Output information. // Output information.
ItemVector Items; ItemVector Items;
@@ -146,10 +147,11 @@ private:
std::string NoCaseExpression(const char* str); std::string NoCaseExpression(const char* str);
// Handling of link items. // Handling of link items.
void AddTargetItem(std::string const& item, const cmGeneratorTarget* target); void AddTargetItem(BT<std::string> const& item,
void AddFullItem(std::string const& item); const cmGeneratorTarget* target);
void AddFullItem(BT<std::string> const& item);
bool CheckImplicitDirItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item);
void AddUserItem(std::string const& item, bool pathNotKnown); void AddUserItem(BT<std::string> const& item, bool pathNotKnown);
void AddDirectoryItem(std::string const& item); void AddDirectoryItem(std::string const& item);
void AddFrameworkItem(std::string const& item); void AddFrameworkItem(std::string const& item);
void DropDirectoryItem(std::string const& item); void DropDirectoryItem(std::string const& item);
+2 -2
View File
@@ -2812,11 +2812,11 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
linkLibs += sep; linkLibs += sep;
sep = " "; sep = " ";
if (libName.IsPath) { if (libName.IsPath) {
linkLibs += this->XCodeEscapePath(libName.Value); linkLibs += this->XCodeEscapePath(libName.Value.Value);
} else if (!libName.Target || } else if (!libName.Target ||
libName.Target->GetType() != libName.Target->GetType() !=
cmStateEnums::INTERFACE_LIBRARY) { cmStateEnums::INTERFACE_LIBRARY) {
linkLibs += libName.Value; linkLibs += libName.Value.Value;
} }
if (libName.Target && !libName.Target->IsImported()) { if (libName.Target && !libName.Target->IsImported()) {
target->AddDependTarget(configName, libName.Target->GetName()); target->AddDependTarget(configName, libName.Target->GetName());
+4 -18
View File
@@ -9,7 +9,6 @@
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h" #include "cmGeneratorTarget.h"
#include "cmLinkItem.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cmOutputConverter.h" #include "cmOutputConverter.h"
#include "cmStateDirectory.h" #include "cmStateDirectory.h"
@@ -79,27 +78,14 @@ void cmLinkLineComputer::ComputeLinkLibs(
BT<std::string> linkLib; BT<std::string> linkLib;
if (item.IsPath) { if (item.IsPath) {
linkLib.Value += cli.GetLibLinkFileFlag(); linkLib.Value += cli.GetLibLinkFileFlag();
linkLib.Value += linkLib.Value += this->ConvertToOutputFormat(
this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value)); this->ConvertToLinkReference(item.Value.Value));
linkLib.Backtrace = item.Value.Backtrace;
} else { } else {
linkLib.Value += item.Value; linkLib = item.Value;
} }
linkLib.Value += " "; linkLib.Value += " ";
const cmLinkImplementation* linkImpl =
cli.GetTarget()->GetLinkImplementation(cli.GetConfig());
for (const cmLinkImplItem& iter : linkImpl->Libraries) {
if (iter.Target != nullptr &&
iter.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
std::string libPath = iter.Target->GetLocation(cli.GetConfig());
if (item.Value == libPath) {
linkLib.Backtrace = iter.Backtrace;
break;
}
}
}
linkLibraries.emplace_back(linkLib); linkLibraries.emplace_back(linkLib);
} }
} }
+5 -5
View File
@@ -115,18 +115,18 @@ void cmLinkLineDeviceComputer::ComputeLinkLibraries(
// These should be passed to nvlink. Other extensions need to be left // These should be passed to nvlink. Other extensions need to be left
// out because nvlink may not understand or need them. Even though it // out because nvlink may not understand or need them. Even though it
// can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'. // can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
if (cmHasLiteralSuffix(item.Value, ".a") || if (cmHasLiteralSuffix(item.Value.Value, ".a") ||
cmHasLiteralSuffix(item.Value, ".lib")) { cmHasLiteralSuffix(item.Value.Value, ".lib")) {
linkLib.Value += this->ConvertToOutputFormat( linkLib.Value += this->ConvertToOutputFormat(
this->ConvertToLinkReference(item.Value)); this->ConvertToLinkReference(item.Value.Value));
} }
} else if (item.Value == "-framework") { } else if (item.Value == "-framework") {
// This is the first part of '-framework Name' where the framework // This is the first part of '-framework Name' where the framework
// name is specified as a following item. Ignore both. // name is specified as a following item. Ignore both.
skipItemAfterFramework = true; skipItemAfterFramework = true;
continue; continue;
} else if (cmLinkItemValidForDevice(item.Value)) { } else if (cmLinkItemValidForDevice(item.Value.Value)) {
linkLib.Value += item.Value; linkLib.Value += item.Value.Value;
} }
if (emitted.insert(linkLib.Value).second) { if (emitted.insert(linkLib.Value).second) {
+2 -2
View File
@@ -1256,11 +1256,11 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
for (auto const& lib : libs) { for (auto const& lib : libs) {
if (lib.IsPath) { if (lib.IsPath) {
std::string rel = std::string rel =
lg->MaybeConvertToRelativePath(currentBinDir, lib.Value.c_str()); lg->MaybeConvertToRelativePath(currentBinDir, lib.Value.Value.c_str());
fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " "; fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
} else if (!lib.Target || } else if (!lib.Target ||
lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
fout << lib.Value << " "; fout << lib.Value.Value << " ";
} }
} }
} }
+8 -8
View File
@@ -3233,13 +3233,13 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
if (l.IsPath) { if (l.IsPath) {
std::string path = this->LocalGenerator->MaybeConvertToRelativePath( std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
currentBinDir, l.Value); currentBinDir, l.Value.Value);
ConvertToWindowsSlash(path); ConvertToWindowsSlash(path);
if (!cmVS10IsTargetsFile(l.Value)) { if (!cmVS10IsTargetsFile(l.Value.Value)) {
libVec.push_back(path); libVec.push_back(path);
} }
} else { } else {
libVec.push_back(l.Value); libVec.push_back(l.Value.Value);
} }
} }
@@ -3804,9 +3804,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
std::string currentBinDir = std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory(); this->LocalGenerator->GetCurrentBinaryDirectory();
for (cmComputeLinkInformation::Item const& l : libs) { for (cmComputeLinkInformation::Item const& l : libs) {
if (l.IsPath && cmVS10IsTargetsFile(l.Value)) { if (l.IsPath && cmVS10IsTargetsFile(l.Value.Value)) {
std::string path = this->LocalGenerator->MaybeConvertToRelativePath( std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
currentBinDir, l.Value); currentBinDir, l.Value.Value);
ConvertToWindowsSlash(path); ConvertToWindowsSlash(path);
this->AddTargetsFileAndConfigPair(path, config); this->AddTargetsFileAndConfigPair(path, config);
} }
@@ -3890,16 +3890,16 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
if (l.IsPath) { if (l.IsPath) {
std::string path = this->LocalGenerator->MaybeConvertToRelativePath( std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
currentBinDir, l.Value); currentBinDir, l.Value.Value);
ConvertToWindowsSlash(path); ConvertToWindowsSlash(path);
if (cmVS10IsTargetsFile(l.Value)) { if (cmVS10IsTargetsFile(l.Value.Value)) {
vsTargetVec.push_back(path); vsTargetVec.push_back(path);
} else { } else {
libVec.push_back(path); libVec.push_back(path);
} }
} else if (!l.Target || } else if (!l.Target ||
l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
libVec.push_back(l.Value); libVec.push_back(l.Value.Value);
} }
} }
} }