From 645b57b8cd9add9624f34e599070e65a98e10790 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Oct 2024 16:49:09 -0400 Subject: Tests/RunCMake/CMP0156: Match expected results more precisely --- Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-result.txt | 2 +- Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-stdout.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-result.txt b/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-result.txt index b18168c..d197c91 100644 --- a/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-result.txt +++ b/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-result.txt @@ -1 +1 @@ -.+ +[^0] diff --git a/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-stdout.txt b/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-stdout.txt index ea3b5c1..28dfd44 100644 --- a/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-stdout.txt +++ b/Tests/RunCMake/CMP0156/CMP0156-OLD-AppleClang-build-stdout.txt @@ -1,3 +1,3 @@ -ld: warning: ignoring duplicate libraries: '.*liblib1.a', '.*liblib2.a' +ld: warning: ignoring duplicate libraries: '[^']*liblib1\.a', '[^']*liblib2\.a' ld: fatal warning\(s\) induced error \(-fatal_warnings\) (cc|clang): error: linker command failed with exit code 1 \(use -v to see invocation\) -- cgit v0.12 From 262c27719767a3f5262dd9327d5f8c8ecf013e0e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Oct 2024 15:31:14 -0400 Subject: Revert "Ensure imported targets in sibling dirs are deduplicated" Revert commit 502610733f (Ensure imported targets in sibling dirs are deduplicated, 2024-09-15, v3.31.0-rc1~92^2). Also revert the change from a copy of the logic made by commit cd418d4bb6 (Static libraries de-duplication: keep first occurrence, 2024-09-29, v3.31.0-rc1~30^2). The logic was de-duplicating based on the target name rather than based on the library file path. Fixes: #26371 Issue: #26284 --- Source/cmComputeLinkDepends.cxx | 35 ++-------------------- ...MP0156-NEW-AppleClang-Imported-build-result.txt | 1 + ...MP0156-NEW-AppleClang-Imported-build-stdout.txt | 3 ++ Tests/RunCMake/CMP0156/RunCMakeTest.cmake | 2 +- 4 files changed, 7 insertions(+), 34 deletions(-) create mode 100644 Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-result.txt create mode 100644 Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-stdout.txt diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 5d92549..ab2557b 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -33,7 +33,6 @@ #include "cmState.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" -#include "cmSystemTools.h" #include "cmTarget.h" #include "cmValue.h" #include "cmake.h" @@ -477,7 +476,6 @@ public: this->Target->GetPolicyStatusCMP0179() == cmPolicies::NEW) { // keep the first occurrence of the static libraries std::set emitted{ this->Emitted }; - std::set importedEmitted; for (auto index : libEntries) { LinkEntry const& entry = this->Entries[index]; if (!entry.Target || @@ -485,20 +483,7 @@ public: entries.emplace_back(index); continue; } - if (this->IncludeEntry(entry)) { - entries.emplace_back(index); - continue; - } - if (entry.Target->IsImported()) { - if (emitted.insert(index).second && - importedEmitted - .insert(cmSystemTools::GetRealPath(entry.Item.Value)) - .second) { - entries.emplace_back(index); - } - continue; - } - if (emitted.insert(index).second) { + if (this->IncludeEntry(entry) || emitted.insert(index).second) { entries.emplace_back(index); } } @@ -604,22 +589,7 @@ private: { for (auto index : libEntries) { LinkEntry const& entry = this->Entries[index]; - if (this->IncludeEntry(entry)) { - this->FinalEntries.emplace_back(entry); - continue; - } - if (entry.Target && entry.Target->IsImported()) { - // Different imported targets can point to the same library so check - // also library paths - if (this->Emitted.insert(index).second && - this->ImportedEmitted - .insert(cmSystemTools::GetRealPath(entry.Item.Value)) - .second) { - this->FinalEntries.emplace_back(entry); - } - continue; - } - if (this->Emitted.insert(index).second) { + if (this->IncludeEntry(entry) || this->Emitted.insert(index).second) { this->FinalEntries.emplace_back(entry); } } @@ -632,7 +602,6 @@ private: EntryVector& Entries; EntryVector& FinalEntries; std::set Emitted; - std::set ImportedEmitted; const std::map>* Groups = nullptr; }; } diff --git a/Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-result.txt b/Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-stdout.txt b/Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-stdout.txt new file mode 100644 index 0000000..c602967 --- /dev/null +++ b/Tests/RunCMake/CMP0156/CMP0156-NEW-AppleClang-Imported-build-stdout.txt @@ -0,0 +1,3 @@ +ld: warning: ignoring duplicate libraries: '[^']*liblib1\.a' +ld: fatal warning\(s\) induced error \(-fatal_warnings\) +(cc|clang): error: linker command failed with exit code 1 \(use -v to see invocation\) diff --git a/Tests/RunCMake/CMP0156/RunCMakeTest.cmake b/Tests/RunCMake/CMP0156/RunCMakeTest.cmake index 052547c..a58fc88 100644 --- a/Tests/RunCMake/CMP0156/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0156/RunCMakeTest.cmake @@ -34,6 +34,6 @@ run_cmake_and_build(CMP0156-NEW-Imported) if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "15.0") - # special case for Apple: with CMP0156=OLD, linker will warning on duplicate libraries + # special case for Apple: FIXME(#26284): linker will warning on duplicate libraries run_cmake_and_build(CMP0156-NEW-AppleClang-Imported) endif() -- cgit v0.12