mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 05:26:58 +08:00
CUDA: Filter out host link flags during device linking
Since commit v3.12.0-rc1~278^2 (CUDA: Pass more link libraries to device linking, 2018-03-27) we consider every link item during device linking. However, items that start in `-` may be host-specific link flags that nvcc will not understand during device linking. Filter such items using a white list. In particular, this allows `-pthread` to be used for host linking while not polluting the device link line. Issue: #18008
This commit is contained in:

committed by
Brad King

parent
3e5548784d
commit
e768d96c74
@@ -23,6 +23,23 @@ cmLinkLineDeviceComputer::~cmLinkLineDeviceComputer()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool cmLinkItemValidForDevice(std::string const& item)
|
||||||
|
{
|
||||||
|
// Valid items are:
|
||||||
|
// * Non-flags (does not start in '-')
|
||||||
|
// * Specific flags --library, --library-path, -l, -L
|
||||||
|
// For example:
|
||||||
|
// * 'cublas_device' => pass-along
|
||||||
|
// * '--library pthread' => pass-along
|
||||||
|
// * '-lpthread' => pass-along
|
||||||
|
// * '-pthread' => drop
|
||||||
|
// * '-a' => drop
|
||||||
|
return (!cmHasLiteralPrefix(item, "-") || //
|
||||||
|
cmHasLiteralPrefix(item, "-l") || //
|
||||||
|
cmHasLiteralPrefix(item, "-L") || //
|
||||||
|
cmHasLiteralPrefix(item, "--library"));
|
||||||
|
}
|
||||||
|
|
||||||
std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
|
std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
|
||||||
cmComputeLinkInformation& cli, std::string const& stdLibString)
|
cmComputeLinkInformation& cli, std::string const& stdLibString)
|
||||||
{
|
{
|
||||||
@@ -60,7 +77,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
|
|||||||
}
|
}
|
||||||
fout << this->ConvertToOutputFormat(
|
fout << this->ConvertToOutputFormat(
|
||||||
this->ConvertToLinkReference(item.Value));
|
this->ConvertToLinkReference(item.Value));
|
||||||
} else {
|
} else if (cmLinkItemValidForDevice(item.Value)) {
|
||||||
fout << item.Value;
|
fout << item.Value;
|
||||||
}
|
}
|
||||||
fout << " ";
|
fout << " ";
|
||||||
|
Reference in New Issue
Block a user