From c9fa114b284a406827ba6c3238a524e01774a331 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 9 Jan 2017 09:57:08 +0000 Subject: [PATCH] [lld][cmake] Fix LLVM_LINK_LLVM_DYLIB build Summary: Lld's build had a couple of issues which prevented a successfull LLVM_LINK_LLVM_DYLIB compilation. - add_llvm_library vs llvm_add_library: One adds a library to libLLVM.so, other one doesn't. Lld was using the wrong one, causing symbols to be mupltiply defined in things linking to libLLVM. - confusion when to use LINK_LIBS vs LINK_COMPONENTS in llvm_add_library - not using LLVM_LINK_COMPONENTS for add_lld_tool With these fixes lld compiles and it's test suite passes both in LLVM_LINK_LLVM_DYLIB mode and without it. Reviewers: ruiu, beanz Subscribers: llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D28397 llvm-svn: 291432 --- lld/cmake/modules/AddLLD.cmake | 2 +- lld/lib/Config/CMakeLists.txt | 4 ++-- lld/lib/Core/CMakeLists.txt | 4 ++-- lld/lib/Driver/CMakeLists.txt | 8 +++++--- lld/lib/ReaderWriter/CMakeLists.txt | 6 ++++-- lld/lib/ReaderWriter/MachO/CMakeLists.txt | 11 +++++++---- lld/lib/ReaderWriter/YAML/CMakeLists.txt | 5 ++++- lld/tools/lld/CMakeLists.txt | 5 ++++- 8 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake index 752ca7f6b43c..906b2952a943 100644 --- a/lld/cmake/modules/AddLLD.cmake +++ b/lld/cmake/modules/AddLLD.cmake @@ -1,5 +1,5 @@ macro(add_lld_library name) - add_llvm_library(${name} ${ARGN}) + llvm_add_library(${name} ${ARGN}) set_target_properties(${name} PROPERTIES FOLDER "lld libraries") endmacro(add_lld_library) diff --git a/lld/lib/Config/CMakeLists.txt b/lld/lib/Config/CMakeLists.txt index e971b0b7aa62..3e142b66f578 100644 --- a/lld/lib/Config/CMakeLists.txt +++ b/lld/lib/Config/CMakeLists.txt @@ -4,6 +4,6 @@ add_lld_library(lldConfig ADDITIONAL_HEADER_DIRS ${LLD_INCLUDE_DIR}/lld/Config - LINK_LIBS - LLVMSupport + LINK_COMPONENTS + Support ) diff --git a/lld/lib/Core/CMakeLists.txt b/lld/lib/Core/CMakeLists.txt index d89ca4a63d72..7f4c47f14b90 100644 --- a/lld/lib/Core/CMakeLists.txt +++ b/lld/lib/Core/CMakeLists.txt @@ -12,6 +12,6 @@ add_lld_library(lldCore ADDITIONAL_HEADER_DIRS ${LLD_INCLUDE_DIR}/lld/Core - LINK_LIBS - LLVMSupport + LINK_COMPONENTS + Support ) diff --git a/lld/lib/Driver/CMakeLists.txt b/lld/lib/Driver/CMakeLists.txt index 1bd1f2125816..be75872869e6 100644 --- a/lld/lib/Driver/CMakeLists.txt +++ b/lld/lib/Driver/CMakeLists.txt @@ -8,15 +8,17 @@ add_lld_library(lldDriver ADDITIONAL_HEADER_DIRS ${LLD_INCLUDE_DIR}/lld/Driver + LINK_COMPONENTS + Object + Option + Support + LINK_LIBS lldConfig lldMachO lldCore lldReaderWriter lldYAML - LLVMObject - LLVMOption - LLVMSupport ) add_dependencies(lldDriver DriverOptionsTableGen) diff --git a/lld/lib/ReaderWriter/CMakeLists.txt b/lld/lib/ReaderWriter/CMakeLists.txt index 4408d9c18b8b..8751d569b754 100644 --- a/lld/lib/ReaderWriter/CMakeLists.txt +++ b/lld/lib/ReaderWriter/CMakeLists.txt @@ -11,9 +11,11 @@ add_lld_library(lldReaderWriter ADDITIONAL_HEADER_DIRS ${LLD_INCLUDE_DIR}/lld/ReaderWriter + LINK_COMPONENTS + Object + Support + LINK_LIBS lldCore lldYAML - LLVMObject - LLVMSupport ) diff --git a/lld/lib/ReaderWriter/MachO/CMakeLists.txt b/lld/lib/ReaderWriter/MachO/CMakeLists.txt index 6a1064d6dfb5..3b0698525aa5 100644 --- a/lld/lib/ReaderWriter/MachO/CMakeLists.txt +++ b/lld/lib/ReaderWriter/MachO/CMakeLists.txt @@ -18,13 +18,16 @@ add_lld_library(lldMachO StubsPass.cpp TLVPass.cpp WriterMachO.cpp + + LINK_COMPONENTS + DebugInfoDWARF + Object + Support + Demangle + LINK_LIBS lldCore lldYAML - LLVMDebugInfoDWARF - LLVMObject - LLVMSupport - LLVMDemangle ${PTHREAD_LIB} ) diff --git a/lld/lib/ReaderWriter/YAML/CMakeLists.txt b/lld/lib/ReaderWriter/YAML/CMakeLists.txt index 5c25444e5dbc..0e63574a63d2 100644 --- a/lld/lib/ReaderWriter/YAML/CMakeLists.txt +++ b/lld/lib/ReaderWriter/YAML/CMakeLists.txt @@ -1,6 +1,9 @@ add_lld_library(lldYAML ReaderWriterYAML.cpp + + LINK_COMPONENTS + Support + LINK_LIBS lldCore - LLVMSupport ) diff --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt index 0c946a3f8ce0..2df10697ff66 100644 --- a/lld/tools/lld/CMakeLists.txt +++ b/lld/tools/lld/CMakeLists.txt @@ -1,3 +1,7 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + add_lld_tool(lld lld.cpp ) @@ -6,7 +10,6 @@ target_link_libraries(lld lldDriver lldCOFF lldELF - LLVMSupport ) install(TARGETS lld