mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-26 16:39:44 -06:00
Merge topic 'nvcc_dlink_dedup_static_libs'
fd0523a215CUDA: Properly de-duplicate libs when doing device linkingb07c71831cCUDA: Add a test to verify device linking can handle circular deps Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2214
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
|
||||
#include "cmLinkLineDeviceComputer.h"
|
||||
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmComputeLinkInformation.h"
|
||||
@@ -28,6 +30,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();
|
||||
@@ -50,20 +58,24 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
|
||||
}
|
||||
}
|
||||
|
||||
std::string out;
|
||||
if (item.IsPath) {
|
||||
// nvcc understands absolute paths to libraries ending in '.a' should
|
||||
// be passed to nvlink. Other extensions like '.so' or '.dylib' are
|
||||
// rejected by the nvcc front-end even though nvlink knows to ignore
|
||||
// them. Bypass the front-end via '-Xnvlink'.
|
||||
if (!cmHasLiteralSuffix(item.Value, ".a")) {
|
||||
fout << "-Xnvlink ";
|
||||
out += "-Xnvlink ";
|
||||
}
|
||||
fout << this->ConvertToOutputFormat(
|
||||
this->ConvertToLinkReference(item.Value));
|
||||
out +=
|
||||
this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value));
|
||||
} else {
|
||||
fout << item.Value;
|
||||
out += item.Value;
|
||||
}
|
||||
|
||||
if (emitted.insert(out).second) {
|
||||
fout << out << " ";
|
||||
}
|
||||
fout << " ";
|
||||
}
|
||||
|
||||
if (!stdLibString.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user