summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorĐoàn Trần Công Danh <congdanhqx@gmail.com>2021-06-24 21:58:51 +0700
committerBrad King <brad.king@kitware.com>2021-06-25 08:45:47 -0400
commitd7159f9591282d719ec7e43af0fa3e49639f14c1 (patch)
tree3ac9a54b6a238732f9ba35e5c13194b80b2d9916 /Source
parent4a0e68266b74479275ca62aca258ca876bc15fc4 (diff)
downloadcmake-d7159f9591282d719ec7e43af0fa3e49639f14c1.tar.gz
Ninja: Fix LINK_WHAT_YOU_USE link flag placement
Move `-Wl,--no-as-needed` from the `<FLAGS>` placeholder to `<LINK_FLAGS>`, as it is in the Makefile generators. Fixes: #22342
Diffstat (limited to 'Source')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx9
1 files changed, 3 insertions, 6 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 9a48047be0..5a4c6521d8 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -1156,16 +1156,15 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
this->AddModuleDefinitionFlag(linkLineComputer.get(), vars["LINK_FLAGS"],
config);
+ if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
+ vars["LINK_FLAGS"] += " -Wl,--no-as-needed";
+ }
vars["LINK_FLAGS"] = globalGen->EncodeLiteral(vars["LINK_FLAGS"]);
vars["MANIFESTS"] = this->GetManifests(config);
vars["AIX_EXPORTS"] = this->GetAIXExports(config);
vars["LINK_PATH"] = frameworkPath + linkPath;
- std::string lwyuFlags;
- if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
- lwyuFlags = " -Wl,--no-as-needed";
- }
// Compute architecture specific link flags. Yes, these go into a different
// variable for executables, probably due to a mistake made when duplicating
@@ -1174,7 +1173,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
std::string t = vars["FLAGS"];
localGen.AddArchitectureFlags(t, gt, this->TargetLinkLanguage(config),
config);
- t += lwyuFlags;
vars["FLAGS"] = t;
} else {
std::string t = vars["ARCH_FLAGS"];
@@ -1182,7 +1180,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
config);
vars["ARCH_FLAGS"] = t;
t.clear();
- t += lwyuFlags;
localGen.AddLanguageFlagsForLinking(
t, gt, this->TargetLinkLanguage(config), config);
vars["LANGUAGE_COMPILE_FLAGS"] = t;