diff options
author | Đoàn Trần Công Danh <congdanhqx@gmail.com> | 2021-07-31 07:17:35 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-08-03 15:21:26 (GMT) |
commit | 93eb4a7bd17f0da02a5ea71426bed5c2056e9ea0 (patch) | |
tree | d3efd0740fa33f0afb68c868df99bea3482601ab /Source | |
parent | f7cf69e34a1607e8ea2b6d10fef6a6058377c24e (diff) | |
download | CMake-93eb4a7bd17f0da02a5ea71426bed5c2056e9ea0.zip CMake-93eb4a7bd17f0da02a5ea71426bed5c2056e9ea0.tar.gz CMake-93eb4a7bd17f0da02a5ea71426bed5c2056e9ea0.tar.bz2 |
Ninja: Revert accidental LINK_WHAT_YOU_USE impl for static libraries
In commit d7159f9591, (Ninja: Fix LINK_WHAT_YOU_USE link flag placement,
2021-06-24), we fixed usage of -Wl,--no-as-needed to override
-Wl,--as-needed from LDFLAGS. However, that change also passes
-Wl,--no-as-needed to `ar`, which is incorrect flag for `ar`.
Let's check the target type before passing down the flags.
Fixes: #22487
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5a4c652..61cfa11 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -1156,7 +1156,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( this->AddModuleDefinitionFlag(linkLineComputer.get(), vars["LINK_FLAGS"], config); - if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { + if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE") && + (gt->GetType() == cmStateEnums::TargetType::EXECUTABLE || + gt->GetType() == cmStateEnums::TargetType::SHARED_LIBRARY || + gt->GetType() == cmStateEnums::TargetType::MODULE_LIBRARY)) { vars["LINK_FLAGS"] += " -Wl,--no-as-needed"; } vars["LINK_FLAGS"] = globalGen->EncodeLiteral(vars["LINK_FLAGS"]); |