summaryrefslogtreecommitdiff
path: root/Source/cmLinkLineDeviceComputer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmLinkLineDeviceComputer.cxx')
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 20bd5378c..a93ec1271 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -3,7 +3,9 @@
#include "cmLinkLineDeviceComputer.h"
+#include <set>
#include <sstream>
+#include <utility>
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
@@ -45,6 +47,12 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
{
// 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
+ // care about link order.
+ std::set<std::string> emitted;
typedef cmComputeLinkInformation::ItemVector ItemVector;
ItemVector const& items = cli.GetItems();
std::string config = cli.GetConfig();
@@ -67,6 +75,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
}
}
+ std::string out;
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
@@ -74,13 +83,16 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
// can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
if (cmHasLiteralSuffix(item.Value, ".a") ||
cmHasLiteralSuffix(item.Value, ".lib")) {
- fout << this->ConvertToOutputFormat(
+ out += this->ConvertToOutputFormat(
this->ConvertToLinkReference(item.Value));
}
} else if (cmLinkItemValidForDevice(item.Value)) {
- fout << item.Value;
+ out += item.Value;
+ }
+
+ if (emitted.insert(out).second) {
+ fout << out << " ";
}
- fout << " ";
}
if (!stdLibString.empty()) {