summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorRobert Maynard <rmaynard@nvidia.com>2023-02-27 21:01:18 (GMT)
committerRobert Maynard <rmaynard@nvidia.com>2023-02-28 20:39:55 (GMT)
commitc5305cf493a442f0a3fdc2f987343db48d9e3330 (patch)
tree5e7be30c40d263b641a478bbba86d0d85e136ee4 /Source
parent157e361ff7aae3f20b2d71229182d304ea792f05 (diff)
downloadCMake-c5305cf493a442f0a3fdc2f987343db48d9e3330.zip
CMake-c5305cf493a442f0a3fdc2f987343db48d9e3330.tar.gz
CMake-c5305cf493a442f0a3fdc2f987343db48d9e3330.tar.bz2
Makefile: Don't pass the CUDA compiler response files with UTF8_BOM
Fixes #24544
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx9
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx8
-rw-r--r--Source/cmMakefileTargetGenerator.cxx22
-rw-r--r--Source/cmMakefileTargetGenerator.h6
4 files changed, 25 insertions, 20 deletions
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 41daa5a..1960073 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -185,14 +185,15 @@ void cmMakefileExecutableTargetGenerator::WriteNvidiaDeviceExecutableRule(
std::string linkLibs;
this->CreateLinkLibs(
linkLineComputer.get(), linkLibs, useResponseFileForLibs, depends,
- cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink);
+ linkLanguage, cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink);
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
this->CreateObjectLists(
useLinkScript, false, useResponseFileForObjects, buildObjs, depends,
- false, cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink);
+ false, linkLanguage,
+ cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink);
cmRulePlaceholderExpander::RuleVariables vars;
std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
@@ -503,13 +504,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Collect up flags to link in needed libraries.
std::string linkLibs;
this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
- useResponseFileForLibs, depends);
+ useResponseFileForLibs, depends, linkLanguage);
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
this->CreateObjectLists(useLinkScript, false, useResponseFileForObjects,
- buildObjs, depends, useWatcomQuote);
+ buildObjs, depends, useWatcomQuote, linkLanguage);
if (!this->DeviceLinkObject.empty()) {
buildObjs += " " +
this->LocalGenerator->ConvertToOutputFormat(
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index cb567ff..3c2dbf6 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -327,14 +327,14 @@ void cmMakefileLibraryTargetGenerator::WriteNvidiaDeviceLibraryRules(
this->CreateLinkLibs(
linkLineComputer.get(), linkLibs, useResponseFileForLibs, depends,
- cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink);
+ linkLanguage, cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink);
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
this->CreateObjectLists(
useLinkScript, false, // useArchiveRules
- useResponseFileForObjects, buildObjs, depends, false,
+ useResponseFileForObjects, buildObjs, depends, false, linkLanguage,
cmMakefileTargetGenerator::ResponseFlagFor::DeviceLink);
std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
@@ -700,7 +700,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
linkLineComputer->SetRelink(relink);
this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
- useResponseFileForLibs, depends);
+ useResponseFileForLibs, depends, linkLanguage);
}
// Construct object file lists that may be needed to expand the
@@ -708,7 +708,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string buildObjs;
this->CreateObjectLists(useLinkScript, useArchiveRules,
useResponseFileForObjects, buildObjs, depends,
- useWatcomQuote);
+ useWatcomQuote, linkLanguage);
if (!this->DeviceLinkObject.empty()) {
buildObjs += " " +
this->LocalGenerator->ConvertToOutputFormat(
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 2b817c3..e217dd9 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -2176,16 +2176,16 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries(
std::string cmMakefileTargetGenerator::CreateResponseFile(
const std::string& name, std::string const& options,
- std::vector<std::string>& makefile_depends)
+ std::vector<std::string>& makefile_depends, std::string const& language)
{
// FIXME: Find a better way to determine the response file encoding,
// perhaps using tool-specific platform information variables.
// For now, use the makefile encoding as a heuristic.
codecvt::Encoding responseEncoding =
this->GlobalGenerator->GetMakefileEncoding();
- // Non-MSVC tooling may not understand a BOM.
+ // Non-MSVC tooling doesn't understand BOM encoded files.
if (responseEncoding == codecvt::UTF8_WITH_BOM &&
- !this->Makefile->IsOn("MSVC")) {
+ (language == "CUDA" || !this->Makefile->IsOn("MSVC"))) {
responseEncoding = codecvt::UTF8;
}
@@ -2222,7 +2222,7 @@ cmMakefileTargetGenerator::CreateLinkLineComputer(
void cmMakefileTargetGenerator::CreateLinkLibs(
cmLinkLineComputer* linkLineComputer, std::string& linkLibs,
bool useResponseFile, std::vector<std::string>& makefile_depends,
- ResponseFlagFor responseMode)
+ std::string const& linkLanguage, ResponseFlagFor responseMode)
{
std::string frameworkPath;
std::string linkPath;
@@ -2240,8 +2240,9 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
// Create this response file.
std::string responseFileName =
(responseMode == Link) ? "linkLibs.rsp" : "deviceLinkLibs.rsp";
- std::string link_rsp =
- this->CreateResponseFile(responseFileName, linkLibs, makefile_depends);
+ std::string responseLang = (responseMode == Link) ? linkLanguage : "CUDA";
+ std::string link_rsp = this->CreateResponseFile(
+ responseFileName, linkLibs, makefile_depends, responseLang);
// Reference the response file.
linkLibs = cmStrCat(responseFlag,
@@ -2253,7 +2254,8 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
void cmMakefileTargetGenerator::CreateObjectLists(
bool useLinkScript, bool useArchiveRules, bool useResponseFile,
std::string& buildObjs, std::vector<std::string>& makefile_depends,
- bool useWatcomQuote, ResponseFlagFor responseMode)
+ bool useWatcomQuote, std::string const& linkLanguage,
+ ResponseFlagFor responseMode)
{
std::string variableName;
std::string variableNameExternal;
@@ -2282,7 +2284,7 @@ void cmMakefileTargetGenerator::CreateObjectLists(
// Create this response file.
std::string objects_rsp = this->CreateResponseFile(
- responseFileName, object_strings[i], makefile_depends);
+ responseFileName, object_strings[i], makefile_depends, linkLanguage);
// Separate from previous response file references.
buildObjs += sep;
@@ -2334,8 +2336,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
}
std::string name = cmStrCat("includes_", lang, ".rsp");
std::string arg = std::move(responseFlag) +
- this->CreateResponseFile(name, includeFlags,
- this->FlagFileDepends[lang]);
+ this->CreateResponseFile(name, includeFlags, this->FlagFileDepends[lang],
+ lang);
this->LocalGenerator->AppendFlags(flags, arg);
} else {
this->LocalGenerator->AppendFlags(flags, includeFlags);
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 5d614fe..98c3a0e 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -160,7 +160,8 @@ protected:
response file name. */
std::string CreateResponseFile(const std::string& name,
std::string const& options,
- std::vector<std::string>& makefile_depends);
+ std::vector<std::string>& makefile_depends,
+ std::string const& language);
bool CheckUseResponseFileForObjects(std::string const& l) const;
bool CheckUseResponseFileForLibraries(std::string const& l) const;
@@ -175,13 +176,14 @@ protected:
void CreateLinkLibs(cmLinkLineComputer* linkLineComputer,
std::string& linkLibs, bool useResponseFile,
std::vector<std::string>& makefile_depends,
+ std::string const& linkLanguage,
ResponseFlagFor responseMode = ResponseFlagFor::Link);
/** Create lists of object files for linking and cleaning. */
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
std::vector<std::string>& makefile_depends,
- bool useWatcomQuote,
+ bool useWatcomQuote, std::string const& linkLanguage,
ResponseFlagFor responseMode = ResponseFlagFor::Link);
/** Add commands for generate def files */