diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2022-04-22 16:51:26 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2022-07-22 14:34:45 (GMT) |
commit | 96bc59b1ca01be231347404d178445263687dd22 (patch) | |
tree | d9c015f30a1e43f0d5ded6dc75a638471f085ed6 /Source/cmLocalGenerator.cxx | |
parent | 1527d48cd0071e3e1737b51db3738f7f76ddbf80 (diff) | |
download | CMake-96bc59b1ca01be231347404d178445263687dd22.zip CMake-96bc59b1ca01be231347404d178445263687dd22.tar.gz CMake-96bc59b1ca01be231347404d178445263687dd22.tar.bz2 |
CUDA: Add Device LTO support for nvcc
Fixes #22200
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 67c8bf2..7b823da 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -36,6 +36,7 @@ #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmLinkLineComputer.h" +#include "cmLinkLineDeviceComputer.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmRulePlaceholderExpander.h" @@ -1381,7 +1382,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetStaticLibraryFlags( } void cmLocalGenerator::GetDeviceLinkFlags( - cmLinkLineComputer& linkLineComputer, const std::string& config, + cmLinkLineDeviceComputer& linkLineComputer, const std::string& config, std::string& linkLibs, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target) { @@ -1389,6 +1390,18 @@ void cmLocalGenerator::GetDeviceLinkFlags( cmComputeLinkInformation* pcli = target->GetLinkInformation(config); + auto linklang = linkLineComputer.GetLinkerLanguage(target, config); + auto ipoEnabled = target->IsIPOEnabled(linklang, config); + if (!ipoEnabled) { + ipoEnabled = linkLineComputer.ComputeRequiresDeviceLinkingIPOFlag(*pcli); + } + if (ipoEnabled) { + if (cmValue cudaIPOFlags = this->Makefile->GetDefinition( + "CMAKE_CUDA_DEVICE_LINK_OPTIONS_IPO")) { + linkFlags += cudaIPOFlags; + } + } + if (pcli) { // Compute the required device link libraries when // resolving gpu lang device symbols @@ -1396,6 +1409,8 @@ void cmLocalGenerator::GetDeviceLinkFlags( linkPath); } + // iterate link deps and see if any of them need IPO + std::vector<std::string> linkOpts; target->GetLinkOptions(linkOpts, config, "CUDA"); // LINK_OPTIONS are escaped. @@ -1590,7 +1605,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetTargetCompileFlags( cmMakefile* mf = this->GetMakefile(); // Add language-specific flags. - this->AddLanguageFlags(compileFlags, target, lang, config); + this->AddLanguageFlags(compileFlags, target, cmBuildStep::Compile, lang, + config); if (target->IsIPOEnabled(lang, config)) { this->AppendFeatureOptions(compileFlags, lang, "IPO"); @@ -1903,6 +1919,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, void cmLocalGenerator::AddLanguageFlags(std::string& flags, cmGeneratorTarget const* target, + cmBuildStep compileOrLink, const std::string& lang, const std::string& config) { @@ -1926,7 +1943,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } } } else if (lang == "CUDA") { - target->AddCUDAArchitectureFlags(flags); + target->AddCUDAArchitectureFlags(compileOrLink, config, flags); target->AddCUDAToolkitFlags(flags); } else if (lang == "ISPC") { target->AddISPCTargetFlags(flags); @@ -2038,7 +2055,7 @@ void cmLocalGenerator::AddLanguageFlagsForLinking( this->AddCompilerRequirementFlag(flags, target, lang, config); } - this->AddLanguageFlags(flags, target, lang, config); + this->AddLanguageFlags(flags, target, cmBuildStep::Link, lang, config); if (target->IsIPOEnabled(lang, config)) { this->AppendFeatureOptions(flags, lang, "IPO"); |