diff options
-rw-r--r-- | Source/cmLinkLineComputer.cxx | 28 | ||||
-rw-r--r-- | Source/cmLinkLineComputer.h | 8 | ||||
-rw-r--r-- | Source/cmLinkLineDeviceComputer.cxx | 41 | ||||
-rw-r--r-- | Source/cmLinkLineDeviceComputer.h | 8 |
4 files changed, 63 insertions, 22 deletions
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index dec25ff..0dc6236 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -222,13 +222,30 @@ std::string cmLinkLineComputer::ComputeFrameworkPath( std::string cmLinkLineComputer::ComputeLinkLibraries( cmComputeLinkInformation& cli, std::string const& stdLibString) { - std::ostringstream fout; - fout << this->ComputeRPath(cli); + std::string linkLibraries; + std::vector<BT<std::string>> linkLibrariesList; + this->ComputeLinkLibraries(cli, stdLibString, linkLibrariesList); + cli.AppendValues(linkLibraries, linkLibrariesList); + return linkLibraries; +} + +void cmLinkLineComputer::ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector<BT<std::string>>& linkLibraries) +{ + std::ostringstream rpathOut; + rpathOut << this->ComputeRPath(cli); + + std::string rpath = rpathOut.str(); + if (!rpath.empty()) { + linkLibraries.emplace_back(std::move(rpath)); + } // Write the library flags to the build rule. - fout << this->ComputeLinkLibs(cli); + this->ComputeLinkLibs(cli, linkLibraries); // Add the linker runtime search path if any. + std::ostringstream fout; std::string rpath_link = cli.GetRPathLinkString(); if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { fout << cli.GetRPathLinkFlag(); @@ -241,7 +258,10 @@ std::string cmLinkLineComputer::ComputeLinkLibraries( fout << stdLibString << " "; } - return fout.str(); + std::string remainingLibs = fout.str(); + if (!remainingLibs.empty()) { + linkLibraries.emplace_back(remainingLibs); + } } std::string cmLinkLineComputer::GetLinkerLanguage(cmGeneratorTarget* target, diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index a6e0ebf..f426976 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -45,8 +45,12 @@ public: std::string ComputeFrameworkPath(cmComputeLinkInformation& cli, std::string const& fwSearchFlag); - virtual std::string ComputeLinkLibraries(cmComputeLinkInformation& cli, - std::string const& stdLibString); + std::string ComputeLinkLibraries(cmComputeLinkInformation& cli, + std::string const& stdLibString); + + virtual void ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector<BT<std::string>>& linkLibraries); virtual std::string GetLinkerLanguage(cmGeneratorTarget* target, std::string const& config); diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 1a602ca..d845652 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -4,13 +4,14 @@ #include "cmLinkLineDeviceComputer.h" #include <set> -#include <sstream> #include <utility> #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmLinkItem.h" +#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmStateDirectory.h" @@ -67,12 +68,10 @@ bool cmLinkLineDeviceComputer::ComputeRequiresDeviceLinking( return false; } -std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( - cmComputeLinkInformation& cli, std::string const& stdLibString) +void cmLinkLineDeviceComputer::ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector<BT<std::string>>& linkLibraries) { - // Write the library flags to the build rule. - std::ostringstream fout; - // Generate the unique set of link items when device linking. // The nvcc device linker is designed so that each static library // with device symbols only needs to be listed once as it doesn't @@ -110,7 +109,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( } } - std::string out; + BT<std::string> linkLib; if (item.IsPath) { // nvcc understands absolute paths to libraries ending in '.a' or '.lib'. // These should be passed to nvlink. Other extensions need to be left @@ -118,7 +117,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( // can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'. if (cmHasLiteralSuffix(item.Value, ".a") || cmHasLiteralSuffix(item.Value, ".lib")) { - out += this->ConvertToOutputFormat( + linkLib.Value += this->ConvertToOutputFormat( this->ConvertToLinkReference(item.Value)); } } else if (item.Value == "-framework") { @@ -127,19 +126,33 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( skipItemAfterFramework = true; continue; } else if (cmLinkItemValidForDevice(item.Value)) { - out += item.Value; + linkLib.Value += item.Value; } - if (emitted.insert(out).second) { - fout << out << " "; + if (emitted.insert(linkLib.Value).second) { + 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); } } if (!stdLibString.empty()) { - fout << stdLibString << " "; + linkLibraries.emplace_back(cmStrCat(stdLibString, ' ')); } - - return fout.str(); } std::string cmLinkLineDeviceComputer::GetLinkerLanguage(cmGeneratorTarget*, diff --git a/Source/cmLinkLineDeviceComputer.h b/Source/cmLinkLineDeviceComputer.h index 0ea5f69..a9b01cd 100644 --- a/Source/cmLinkLineDeviceComputer.h +++ b/Source/cmLinkLineDeviceComputer.h @@ -7,6 +7,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include <string> +#include <vector> #include "cmLinkLineComputer.h" @@ -15,6 +16,8 @@ class cmGeneratorTarget; class cmLocalGenerator; class cmOutputConverter; class cmStateDirectory; +template <typename T> +class BT; class cmLinkLineDeviceComputer : public cmLinkLineComputer { @@ -29,8 +32,9 @@ public: bool ComputeRequiresDeviceLinking(cmComputeLinkInformation& cli); - std::string ComputeLinkLibraries(cmComputeLinkInformation& cli, - std::string const& stdLibString) override; + void ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector<BT<std::string>>& linkLibraries) override; std::string GetLinkerLanguage(cmGeneratorTarget* target, std::string const& config) override; |