diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2018-10-22 14:54:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-10-24 13:54:25 (GMT) |
commit | e768d96c74579c79e184027775e51b08cd77fe45 (patch) | |
tree | 08acb89465f4926d82c36bebbb6ff38419bc8dcd /Source/cmLinkLineDeviceComputer.cxx | |
parent | 3e5548784da085ee3a5ce3f7213c0cf281b68f31 (diff) | |
download | CMake-e768d96c74579c79e184027775e51b08cd77fe45.zip CMake-e768d96c74579c79e184027775e51b08cd77fe45.tar.gz CMake-e768d96c74579c79e184027775e51b08cd77fe45.tar.bz2 |
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
Diffstat (limited to 'Source/cmLinkLineDeviceComputer.cxx')
-rw-r--r-- | Source/cmLinkLineDeviceComputer.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 557fa41..470f394 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -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( cmComputeLinkInformation& cli, std::string const& stdLibString) { @@ -60,7 +77,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( } fout << this->ConvertToOutputFormat( this->ConvertToLinkReference(item.Value)); - } else { + } else if (cmLinkItemValidForDevice(item.Value)) { fout << item.Value; } fout << " "; |