[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
This commit is contained in:
Pavel Labath 2017-01-09 09:57:08 +00:00
parent be2d68f774
commit c9fa114b28
8 changed files with 29 additions and 16 deletions

View File

@ -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)

View File

@ -4,6 +4,6 @@ add_lld_library(lldConfig
ADDITIONAL_HEADER_DIRS
${LLD_INCLUDE_DIR}/lld/Config
LINK_LIBS
LLVMSupport
LINK_COMPONENTS
Support
)

View File

@ -12,6 +12,6 @@ add_lld_library(lldCore
ADDITIONAL_HEADER_DIRS
${LLD_INCLUDE_DIR}/lld/Core
LINK_LIBS
LLVMSupport
LINK_COMPONENTS
Support
)

View File

@ -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)

View File

@ -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
)

View File

@ -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}
)

View File

@ -1,6 +1,9 @@
add_lld_library(lldYAML
ReaderWriterYAML.cpp
LINK_COMPONENTS
Support
LINK_LIBS
lldCore
LLVMSupport
)

View File

@ -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