Merge topic 'fix_link-line-dedup_regression'
4db31095 Fix link line order when shared libraries are de-duplicated
This commit is contained in:
commit
70c2432887
@ -263,21 +263,26 @@ cmComputeLinkDepends::Compute()
|
|||||||
this->OrderLinkEntires();
|
this->OrderLinkEntires();
|
||||||
|
|
||||||
// Compute the final set of link entries.
|
// Compute the final set of link entries.
|
||||||
|
// Iterate in reverse order so we can keep only the last occurrence
|
||||||
|
// of a shared library.
|
||||||
std::set<int> emmitted;
|
std::set<int> emmitted;
|
||||||
for(std::vector<int>::const_iterator li = this->FinalLinkOrder.begin();
|
for(std::vector<int>::const_reverse_iterator
|
||||||
li != this->FinalLinkOrder.end(); ++li)
|
li = this->FinalLinkOrder.rbegin(),
|
||||||
|
le = this->FinalLinkOrder.rend();
|
||||||
|
li != le; ++li)
|
||||||
{
|
{
|
||||||
int i = *li;
|
int i = *li;
|
||||||
LinkEntry const& e = this->EntryList[i];
|
LinkEntry const& e = this->EntryList[i];
|
||||||
cmTarget const* t = e.Target;
|
cmTarget const* t = e.Target;
|
||||||
// Entries that we know the linker will re-use for symbols
|
// Entries that we know the linker will re-use do not need to be repeated.
|
||||||
// needed by later entries do not need to be repeated.
|
|
||||||
bool uniquify = t && t->GetType() == cmTarget::SHARED_LIBRARY;
|
bool uniquify = t && t->GetType() == cmTarget::SHARED_LIBRARY;
|
||||||
if(!uniquify || emmitted.insert(i).second)
|
if(!uniquify || emmitted.insert(i).second)
|
||||||
{
|
{
|
||||||
this->FinalLinkEntries.push_back(e);
|
this->FinalLinkEntries.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Reverse the resulting order since we iterated in reverse.
|
||||||
|
std::reverse(this->FinalLinkEntries.begin(), this->FinalLinkEntries.end());
|
||||||
|
|
||||||
// Display the final set.
|
// Display the final set.
|
||||||
if(this->DebugMode)
|
if(this->DebugMode)
|
||||||
|
@ -51,3 +51,4 @@ add_subdirectory(Case1)
|
|||||||
add_subdirectory(Case2)
|
add_subdirectory(Case2)
|
||||||
add_subdirectory(Case3)
|
add_subdirectory(Case3)
|
||||||
add_subdirectory(Case4)
|
add_subdirectory(Case4)
|
||||||
|
add_subdirectory(Case5)
|
||||||
|
8
Tests/Dependency/Case5/CMakeLists.txt
Normal file
8
Tests/Dependency/Case5/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
project(CASE5 C)
|
||||||
|
|
||||||
|
add_library(case5Foo SHARED foo.c)
|
||||||
|
add_library(case5Bar STATIC bar.c)
|
||||||
|
target_link_libraries(case5Bar case5Foo)
|
||||||
|
|
||||||
|
add_executable(case5 main.c)
|
||||||
|
target_link_libraries(case5 case5Foo case5Bar)
|
12
Tests/Dependency/Case5/bar.c
Normal file
12
Tests/Dependency/Case5/bar.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifdef _WIN32
|
||||||
|
__declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
void foo(void);
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void bar(void)
|
||||||
|
{
|
||||||
|
foo();
|
||||||
|
printf("bar()\n");
|
||||||
|
}
|
9
Tests/Dependency/Case5/foo.c
Normal file
9
Tests/Dependency/Case5/foo.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
__declspec(dllexport)
|
||||||
|
#endif
|
||||||
|
void foo(void)
|
||||||
|
{
|
||||||
|
printf("foo()\n");
|
||||||
|
}
|
7
Tests/Dependency/Case5/main.c
Normal file
7
Tests/Dependency/Case5/main.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
void bar(void);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
bar();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user