unittests: Fix build with LLVM_LINK_LLVM_DYLIB=ON

The build system was linking the PluginsTests unittest against libLLVM.so
and LLVMAsmParser which was causing the test to fail with this error:

LLVM ERROR: inconsistency in registered CommandLine options

We need to add llvm libraries to LLVM_LINK_COMPONENTS so that
they are dropped from the linker arguments when linking with
LLVM_LINK_LLVM_DYLIB=ON

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D105523
This commit is contained in:
Tom Stellard 2021-07-06 19:46:21 -07:00
parent feef171f76
commit 2e4ec3e5d6
1 changed files with 2 additions and 2 deletions

View File

@ -12,12 +12,12 @@ endif()
# work with DLLs on Windows (where a shared library can't have undefined
# references), so just skip this testcase on Windows.
if (NOT WIN32)
set(LLVM_LINK_COMPONENTS Support Passes Core)
set(LLVM_LINK_COMPONENTS Support Passes Core LLVMAsmParser)
add_llvm_unittest(PluginsTests
PluginsTest.cpp
)
export_executable_symbols_for_plugins(PluginsTests)
target_link_libraries(PluginsTests PRIVATE LLVMAsmParser LLVMTestingSupport)
target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
set(LLVM_LINK_COMPONENTS)
foreach(PLUGIN TestPlugin DoublerPlugin)