Skip to content

Commit

Permalink
Merge topic 'revert-link-dedup-imported-targets' into release-3.31
Browse files Browse the repository at this point in the history
262c277 Revert "Ensure imported targets in sibling dirs are deduplicated"
645b57b Tests/RunCMake/CMP0156: Match expected results more precisely

Acked-by: Kitware Robot <[email protected]>
Tested-by: buildbot <[email protected]>
Merge-request: !9909
  • Loading branch information
bradking authored and kwrobot committed Oct 17, 2024
2 parents fb1a327 + 262c277 commit 67aef2b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 36 deletions.
35 changes: 2 additions & 33 deletions Source/cmComputeLinkDepends.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -477,28 +476,14 @@ class EntriesProcessing
this->Target->GetPolicyStatusCMP0179() == cmPolicies::NEW) {
// keep the first occurrence of the static libraries
std::set<size_t> emitted{ this->Emitted };
std::set<std::string> importedEmitted;
for (auto index : libEntries) {
LinkEntry const& entry = this->Entries[index];
if (!entry.Target ||
entry.Target->GetType() != cmStateEnums::STATIC_LIBRARY) {
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);
}
}
Expand Down Expand Up @@ -604,22 +589,7 @@ class EntriesProcessing
{
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);
}
}
Expand All @@ -632,7 +602,6 @@ class EntriesProcessing
EntryVector& Entries;
EntryVector& FinalEntries;
std::set<size_t> Emitted;
std::set<std::string> ImportedEmitted;
const std::map<size_t, std::vector<size_t>>* Groups = nullptr;
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[^0]
Original file line number Diff line number Diff line change
@@ -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\)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.+
[^0]
Original file line number Diff line number Diff line change
@@ -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\)
2 changes: 1 addition & 1 deletion Tests/RunCMake/CMP0156/RunCMakeTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 67aef2b

Please sign in to comment.